What LVM does
The Linux Logical Volume Manager adds a flexible layer between physical disks
and filesystems. Raw disks become Physical Volumes, PVs are pooled into a
Volume Group, and Logical Volumes are carved from that pool — resizable,
movable and snapshottable without repartitioning. The command set mirrors these
layers: pv* for physical volumes, vg* for groups, lv* for logical volumes.
This reference lists the commands you actually use, with their key flags.
How it works
Provisioning flows top-down through the three layers, then you format and mount the resulting LV like any block device:
pvcreate /dev/sdb /dev/sdc # initialise disks as PVs
vgcreate datavg /dev/sdb /dev/sdc # pool them into a VG
lvcreate -L 50G -n web datavg # carve a 50G LV named "web"
mkfs.ext4 /dev/datavg/web # format it
mount /dev/datavg/web /srv/web # mount it
Growing later is two steps: lvextend -L +20G /dev/datavg/web then a filesystem
resize, or lvextend -r to do both. Snapshots (lvcreate -s) give you a
copy-on-write point-in-time view for backups.
Common operations with examples
Extending a logical volume online (ext4)
# Add 20 GiB to an existing LV and resize the filesystem in one command
lvextend -r -L +20G /dev/datavg/web
# Or manually: extend first, then resize
lvextend -L +20G /dev/datavg/web
resize2fs /dev/datavg/web
For XFS, replace resize2fs with xfs_growfs /srv/web (the mount point, not the device).
Taking a backup snapshot
# Create a 5 GiB copy-on-write snapshot of the "web" volume
lvcreate -s -L 5G -n web_snap /dev/datavg/web
# Mount it read-only to inspect or back it up
mkdir /mnt/snap
mount -o ro /dev/datavg/web_snap /mnt/snap
# When done, unmount and remove the snapshot
umount /mnt/snap
lvremove /dev/datavg/web_snap
Size the snapshot at roughly 15–20% of the origin volume for a short-lived backup window. If the snapshot fills completely, it becomes invalid and is automatically deactivated.
Removing a disk from a volume group
# First migrate all data off the disk
pvmove /dev/sdc
# Remove the empty PV from the group
vgreduce datavg /dev/sdc
# Remove the LVM label from the disk entirely
pvremove /dev/sdc
pvmove can take a long time on large, busy disks. It is safe to interrupt and resume — progress is tracked in the volume group metadata.
Key display commands
| Command | What it shows |
|---|---|
pvs | Short per-PV summary (size, VG, free) |
vgs | Short per-VG summary (PVs, LVs, size, free) |
lvs | Short per-LV summary (name, VG, size, attributes) |
pvdisplay | Full details for each PV |
vgdisplay | Full details for each VG |
lvdisplay | Full details for each LV |
Add -v to any of these for more verbose output, or -o +devices to see which physical extents back each LV.
Tips and notes
lvextend -rresizes the filesystem in one step — no separateresize2fs.-l 100%FREEconsumes all remaining extents;-Ltakes a fixed human size.- Use
pvmovebeforevgreduceto drain a disk you want to remove from a group. - Thin pools (
lvcreate --type thin-pool) allow over-provisioning — monitor pool usage closely to avoid running out of backing space. - Always run
vgscanandvgchange -ayon a new system before expecting LVM to activate volume groups from disks moved from another machine.