LVM

Abstraktionsschicht, um Partitionen flexibel über mehrere physische Devices zu bilden. Fasst eine oder mehrere Disks zu einem Logical Volume zusammen. Mehrere Physical Volumes (Platten) bilden eine Volume Group. In der Volume Group werden Logical Volumes gebildet. In den LV werden die Dateisysteme angelegt.

Dateisystem (mkfs)
^^
Logical Volume (LV)
^^
Volume Group (VG)
^^
Physical Volume (PV, HDD1 -- HDD2)

pvdisplay zeigt alle Physical Volumes und die physischen Devices, auf denen sie liegen

root@tarapiroe /mnt # pvdisplay
  --- Physical volume ---
  PV Name               /dev/md3
  VG Name               data1
  PV Size               <2,66 TiB / not usable 2,31 MiB
  Allocatable           yes
  PE Size               4,00 MiB
  Total PE              696964
  Free PE               364164
  Allocated PE          332800
  PV UUID               JGWU94-FLRS-zV60-ZAzg-gRvE-ifmR-qLIdMs

  --- Physical volume ---
  PV Name               /dev/nbd0p5
  VG Name               ffes-vg
  PV Size               19,52 GiB / not usable 2,00 MiB
  Allocatable           yes (but full)
  PE Size               4,00 MiB
  Total PE              4997
  Free PE               0
  Allocated PE          4997
  PV UUID               jqhYf1-VhUf-ApgM-vPtW-alD3-EFkZ-etDGgz

vgdisplay zeigt die Volume Groups

root@tarapiroe /mnt # pvdisplay
  --- Physical volume ---
  PV Name               /dev/md3
  VG Name               data1
  PV Size               <2,66 TiB / not usable 2,31 MiB
  Allocatable           yes
  PE Size               4,00 MiB
  Total PE              696964
  Free PE               364164
  Allocated PE          332800
  PV UUID               JGWU94-FLRS-zV60-ZAzg-gRvE-ifmR-qLIdMs

  --- Physical volume ---
  PV Name               /dev/nbd0p5
  VG Name               ffes-vg
  PV Size               19,52 GiB / not usable 2,00 MiB
  Allocatable           yes (but full)
  PE Size               4,00 MiB
  Total PE              4997
  Free PE               0
  Allocated PE          4997
  PV UUID               jqhYf1-VhUf-ApgM-vPtW-alD3-EFkZ-etDGgz

lvddisplay zeigt die logical volumes in der Volume Group

root@tarapiroe /mnt # lvdisplay
  --- Logical volume ---
  LV Path                /dev/data1/VMs
  LV Name                VMs
  VG Name                data1
  LV UUID                ccDAJ2-sN1H-lRYL-fQFf-q11k-FtSB-7nSSQO
  LV Write Access        read/write
  LV Creation host, time ,
  LV Status              available
  # open                 1
  LV Size                300,00 GiB
  Current LE             76800
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

  --- Logical volume ---
  LV Path                /dev/data1/Backup
  LV Name                Backup
  VG Name                data1
  LV UUID                2aABCv-Dwp0-W9Wu-0SpK-Xrwy-fHVF-pDEpge
  LV Write Access        read/write
  LV Creation host, time ,
  LV Status              available
  # open                 1
  LV Size                1000,00 GiB
  Current LE             256000
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1

  --- Logical volume ---
  LV Path                /dev/ffes-vg/root
  LV Name                root
  VG Name                ffes-vg
  LV UUID                A9CTeG-Da3f-CtnJ-Hgkd-Yp6r-NpJ0-yaiwlT
  LV Write Access        read/write
  LV Creation host, time ffes, 2017-11-22 10:33:21 +0100
  LV Status              available
  # open                 0
  LV Size                <17,52 GiB
  Current LE             4485
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:2

  --- Logical volume ---
  LV Path                /dev/ffes-vg/swap_1
  LV Name                swap_1
  VG Name                ffes-vg
  LV UUID                tTYpH9-jJsi-0HsE-twF2-3UtO-NZQB-UWepLj
  LV Write Access        read/write
  LV Creation host, time ffes, 2017-11-22 10:33:21 +0100
  LV Status              available
  # open                 0
  LV Size                2,00 GiB
  Current LE             512
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:3

lvcreate legt neue Volumes in einer Volume Group an:

root@tokoeka ~ # lvcreate --name data2 --size 1.9T pve

Auf maximal verfügbare Grösse:

lvcreate -l 100%VG -n data2 pve

lvextend und lvreduce vergrößern und verkleinern die Volumes. lvscan zeigt alle Volumes in Kurzfassung:

root@tokoeka ~ # lvscan
  ACTIVE            '/dev/pve/swap' [8.00 GiB] inherit
  ACTIVE            '/dev/pve/root' [100.00 GiB] inherit
  ACTIVE            '/dev/pve/data' [100.00 GiB] inherit
  ACTIVE            '/dev/pve/vm-100-disk-0' [32.00 GiB] inherit
  ACTIVE            '/dev/pve/vm-100-disk-1' [500.00 GiB] inherit
  ACTIVE            '/dev/pve/backup' [1.00 TiB] inherit
  ACTIVE            '/dev/pve/data2' [1.90 TiB] inherit

lvrename benennt ein lv um:

lvrename /dev/pve/data2 /dev/pve/backup

Allerdings haben sie noch kein Filesystem, das legt man mit mkfs.ext4 an.

root@tokoeka ~ # mkfs.ext4 /dev/pve/vm-100-disk-1
mke2fs 1.43.4 (31-Jan-2017)
Creating filesystem with 131072000 4k blocks and 32768000 inodes
Filesystem UUID: 3c17dd79-ea84-47b8-82ec-7e94b3f394c8
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
        102400000

Allocating group tables: done
Writing inode tables: done
Creating journal (262144 blocks): done
Writing superblocks and filesystem accounting information: done

Wenn man das lv vergrößert hat, muss man auch das Filesystem vergrößern:

resize2fs -p /dev/mapper/pve-data

Erst danach sind alle lv's als Block Devices für den Kernel verfügbar:

root@tokoeka ~ # blkid
/dev/sda1: UUID="1e90e1fa-fd6c-db99-55cd-6e2107fd3f55" UUID_SUB="043a0140-ad1b-18d9-00e7-ff2cd6026917" LABEL="rescue:0" TYPE="linux_raid_member" PARTUUID="7abb39f4-17f5-49aa-80d2-ba5de6088a15"
/dev/sda2: UUID="0acd374c-f1fb-7065-ae31-6e5a6e12ad1b" UUID_SUB="6f1fe193-8a90-0f93-3d8a-e5633cf6e447" LABEL="rescue:1" TYPE="linux_raid_member" PARTUUID="3a15509a-dba2-4c11-8f51-ee7efc9512de"
/dev/sdb1: UUID="1e90e1fa-fd6c-db99-55cd-6e2107fd3f55" UUID_SUB="814a4156-e0ec-9058-7616-a77d0c82b134" LABEL="rescue:0" TYPE="linux_raid_member" PARTUUID="c3fcddd4-f3a8-419c-b87a-9ae914a9f207"
/dev/sdb2: UUID="0acd374c-f1fb-7065-ae31-6e5a6e12ad1b" UUID_SUB="1ca5f9db-589d-8dd1-23be-5561756d441c" LABEL="rescue:1" TYPE="linux_raid_member" PARTUUID="c6b17ac2-9103-4e50-9d23-8ce033cd6d08"
/dev/md0: UUID="b954b02a-56ab-466a-8178-c4a888301676" TYPE="ext4"
/dev/md1: UUID="BW0yGZ-89CR-q1m5-9RSe-qRXM-hq5s-4MaUI5" TYPE="LVM2_member"
/dev/mapper/pve-root: UUID="63888efc-9c72-44fe-ac6c-ca29d45bbc4c" TYPE="ext4"
/dev/mapper/pve-swap: UUID="82ea6ffd-47ef-4078-9130-9c4b2caf2aaa" TYPE="swap"
/dev/sda3: PARTUUID="0f73648a-562b-4a93-bc6a-c596a743167a"
/dev/sdb3: PARTUUID="5031ce48-d15d-4b55-acbd-9bf05f460d17"
/dev/mapper/pve-vm--100--disk--0: PTUUID="cc0d01a6" PTTYPE="dos"
/dev/mapper/pve-vm--100--disk--1: UUID="3c17dd79-ea84-47b8-82ec-7e94b3f394c8" TYPE="ext4"
/dev/mapper/pve-backup: UUID="b094a61f-6bee-4d36-97fb-29aed39ef2cc" TYPE="ext4"
/dev/mapper/pve-data2: UUID="3050b5e7-b457-48d2-9070-ff11241ebcf4" TYPE="ext4"

Oder noch schöner mit lsblk

root@tokoeka ~ # lsblk
NAME                           MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
sda                              8:0    1   3.7T  0 disk
├─sda1                           8:1    1   512M  0 part
│ └─md0                          9:0    0 511.4M  0 raid1 /boot
├─sda2                           8:2    1   3.7T  0 part
│ └─md1                          9:1    0   3.7T  0 raid1
│   ├─pve-root                 253:0    0   100G  0 lvm   /
│   ├─pve-swap                 253:1    0     8G  0 lvm   [SWAP]
│   ├─pve-data_tmeta           253:2    0   100M  0 lvm
│   │ └─pve-data-tpool         253:4    0   100G  0 lvm
│   │   ├─pve-data             253:5    0   100G  0 lvm
│   │   └─pve-vm--100--disk--0 253:6    0    32G  0 lvm
│   ├─pve-data_tdata           253:3    0   100G  0 lvm
│   │ └─pve-data-tpool         253:4    0   100G  0 lvm
│   │   ├─pve-data             253:5    0   100G  0 lvm
│   │   └─pve-vm--100--disk--0 253:6    0    32G  0 lvm
│   ├─pve-vm--100--disk--1     253:7    0   500G  0 lvm
│   ├─pve-backup               253:8    0     1T  0 lvm
│   └─pve-data2                253:9    0   1.9T  0 lvm
└─sda3                           8:3    1     1M  0 part
sdb                              8:16   1   3.7T  0 disk
├─sdb1                           8:17   1   512M  0 part
│ └─md0                          9:0    0 511.4M  0 raid1 /boot
├─sdb2                           8:18   1   3.7T  0 part
│ └─md1                          9:1    0   3.7T  0 raid1
│   ├─pve-root                 253:0    0   100G  0 lvm   /
│   ├─pve-swap                 253:1    0     8G  0 lvm   [SWAP]
│   ├─pve-data_tmeta           253:2    0   100M  0 lvm
│   │ └─pve-data-tpool         253:4    0   100G  0 lvm
│   │   ├─pve-data             253:5    0   100G  0 lvm
│   │   └─pve-vm--100--disk--0 253:6    0    32G  0 lvm
│   ├─pve-data_tdata           253:3    0   100G  0 lvm
│   │ └─pve-data-tpool         253:4    0   100G  0 lvm
│   │   ├─pve-data             253:5    0   100G  0 lvm
│   │   └─pve-vm--100--disk--0 253:6    0    32G  0 lvm
│   ├─pve-vm--100--disk--1     253:7    0   500G  0 lvm
│   ├─pve-backup               253:8    0     1T  0 lvm
│   └─pve-data2                253:9    0   1.9T  0 lvm
└─sdb3                           8:19   1     1M  0 part
  • lvm.txt
  • Zuletzt geändert: vor 4 Wochen
  • von thommie3