LVM Explained: Logical Volume Management on Linux

Partitioning a disk the traditional way locks you into fixed sizes decided at install time. LVM adds a flexible abstraction layer between physical disks and the filesystems you actually use, letting you resize, extend across multiple disks, and snapshot volumes without unmounting anything.

The Three-Layer Model

  • Physical Volumes (PV) — actual disks or partitions, initialized for LVM use.
  • Volume Groups (VG) — a pool combining one or more PVs into a single storage pool.
  • Logical Volumes (LV) — the “virtual partitions” carved out of a VG, which you actually format and mount.

A Practical Walkthrough

# Turn a raw disk into a physical volume
sudo pvcreate /dev/sdb

# Create a volume group from it
sudo vgcreate data-vg /dev/sdb

# Carve out a 50GB logical volume
sudo lvcreate -L 50G -n app-data data-vg

# Format and mount it like any normal partition
sudo mkfs.ext4 /dev/data-vg/app-data
sudo mount /dev/data-vg/app-data /mnt/app-data

The Killer Feature: Live Resizing

# Extend the logical volume by 20GB (assuming free space in the VG)
sudo lvextend -L +20G /dev/data-vg/app-data

# Grow the filesystem to match, without unmounting (ext4)
sudo resize2fs /dev/data-vg/app-data

# Add a second disk to the volume group to grow the pool itself
sudo pvcreate /dev/sdc
sudo vgextend data-vg /dev/sdc

Snapshots for Safe Testing

LVM snapshots let you capture a point-in-time copy-on-write image of a volume before a risky operation (a major upgrade, a schema migration), then roll back instantly if something goes wrong — a capability plain partitions simply don’t offer.