Linux LVM Commands Reference

pvcreate, vgcreate, lvcreate and lvm management commands with common flags.

Searchable LVM command reference covering physical volume (pv), volume group (vg), logical volume (lv) and snapshot operations with the create, display, extend, resize and remove commands and their key flags. It runs free in your browser on Gera Tools, with nothing uploaded.

Last updated Source: Gera Tools

What are the three LVM layers?

Physical Volumes (PVs) are raw disks or partitions initialised with pvcreate. Volume Groups (VGs) pool one or more PVs into a single storage space with vgcreate. Logical Volumes (LVs) are carved out of a VG with lvcreate and act like partitions you format and mount. The pv*, vg* and lv* command families map to these layers.

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

CommandWhat it shows
pvsShort per-PV summary (size, VG, free)
vgsShort per-VG summary (PVs, LVs, size, free)
lvsShort per-LV summary (name, VG, size, attributes)
pvdisplayFull details for each PV
vgdisplayFull details for each VG
lvdisplayFull 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 -r resizes the filesystem in one step — no separate resize2fs.
  • -l 100%FREE consumes all remaining extents; -L takes a fixed human size.
  • Use pvmove before vgreduce to 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 vgscan and vgchange -ay on a new system before expecting LVM to activate volume groups from disks moved from another machine.