LVM - Logical Volume Manager
LVM
Scenario: A partition you created six months ago is nearly full, but the disk it lives on has no adjacent free space to grow into - with plain partitions, you'd be stuck resizing or reformatting. LVM exists precisely to avoid this trap.
LVM inserts a flexible layer of abstraction between raw disks and the filesystems built on top of them, so storage can be resized, combined, or moved around without unmounting or recreating anything:
Physical Volume (PV) → Volume Group (VG) → Logical Volume (LV) → filesystem
/dev/sdb1 vg_data lv_web
Walking through this chain: a Physical Volume is just a disk or partition LVM has claimed for its own use. Multiple PVs get pooled together into a single Volume Group - a shared pot of storage capacity that no longer cares which physical disk any particular gigabyte actually lives on. You then carve out Logical Volumes from that pool - and it's the LV, not any single physical disk, that finally gets a filesystem and a mount point.
| Layer | Create | Inspect |
|---|---|---|
| PV | pvcreate /dev/sdb1 | pvs / pvdisplay |
| VG | vgcreate vg_data /dev/sdb1 | vgs / vgdisplay |
| LV | lvcreate -L 10G -n lv_web vg_data | lvs / lvdisplay |
Grow a volume (the killer feature): because the VG is a shared pool, growing an LV is often just a matter of allocating more of that pool to it - no new disk required if the VG has spare capacity:
$ lvextend -L +5G /dev/vg_data/lv_web
$ resize2fs /dev/vg_data/lv_web # ext4 - grow the FS
# xfs_growfs /data # xfs equivalent (mounted)
Warning: Growing storage with LVM is always two separate steps, and forgetting the second one is a classic mistake:lvextendonly grows the logical volume's block-level allocation - the filesystem sitting on top of it has no idea it just got more room. You must also grow the filesystem itself (resize2fsfor ext4,xfs_growfsfor xfs) ordf -hwill keep reporting the old, smaller size even thoughlvsshows the LV is bigger. One more asymmetry to remember:xfs_growfscan only grow a filesystem, never shrink it - shrinking an XFS filesystem isn't supported at all.