Pcornel
Linux

LVM

Cheat sheet · https://pcornel.dk/topic.php?topic=368

Back to the Topic

Answer

LVM pools disks into a volume group and carves logical volumes out of it. A filesystem sits on a logical volume, which can be grown without regard to where the physical disks end.

Remember

Three layers: physical volume, volume group, logical volume — plus the filesystem on top, which must be grown too (lvextend -r does both). The free space that counts is VFree in vgs. XFS cannot shrink. A snapshot is not a backup.

First checks

  • pvs — physical volumes and the group each belongs to.
  • vgs — volume groups; VFree is what is left to allocate.
  • lvs -a -o +devices — logical volumes and the disks under them.
  • lsblk -f — the whole stack from disk to mount point.
  • df -h <mount> — the filesystem's own view.

Commands

pvcreate
Initialize a block device or partition as an LVM physical volume.
vgcreate
Create an LVM volume group from one or more physical volumes.
lvcreate
Allocate and create an LVM logical volume inside a volume group.
pvs
vgs
lvs -a -o +devices
lvs

Verify in this order

disk or partition → physical volume → volume group with free extents → logical volume extended → filesystem grown → df shows the new size

Where it usually breaks

First mismatch in hardware/block device → kernel driver/mapper/RAID/LVM → filesystem → mount namespace/options → path permissions/MAC → consumer I/O; preserve identity/native diagnostic/pre-state before mutation.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=368

Confirmation

Confirm action

Continue?