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.

LayerCreateInspect
PVpvcreate /dev/sdb1pvs / pvdisplay
VGvgcreate vg_data /dev/sdb1vgs / vgdisplay
LVlvcreate -L 10G -n lv_web vg_datalvs / 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: lvextend only 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 (resize2fs for ext4, xfs_growfs for xfs) or df -h will keep reporting the old, smaller size even though lvs shows the LV is bigger. One more asymmetry to remember: xfs_growfs can only grow a filesystem, never shrink it - shrinking an XFS filesystem isn't supported at all.