LVM concepts - PV, VG, LV, and the storage stack
What you'll learn
- Explain the LVM storage stack: PV, VG, LV, LE
- Choose between LVM and direct partition usage
- Plan LVM for production workloads
- Recognise when LVM adds value and when it adds complexity
- Size and monitor a classic LVM snapshot so its fixed COW space does not fill
Prerequisites
Verified against Ubuntu 24.04 LTS · Debian 12 (Bookworm) · RHEL 9.x · Rocky Linux 9.x · AlmaLinux 9.x · Linux kernel 6.1 LTS / 6.6 LTS · systemd 255+ · OpenSSH 8.7p1 (RHEL 9) / 9.6p1 (Ubuntu 24.04) · nftables 1.0.x · chrony 4.x · Pacemaker 2.1.x · Corosync 3.1.x · 2026-08-09
LVM (Logical Volume Manager) sits between the block device and the filesystem. It provides a layer of indirection that decouples the filesystem from the physical disk, enabling flexible resize, span across disks, and snapshots.
The storage stack
$ pvs; echo ---; vgs; echo ---; lvs PV VG Fmt Attr PSize PFree
/dev/sda2 vg0 lvm2 a-- 99.00g 4.00g
/dev/sdb1 vg0 lvm2 a-- 500.00g 205.00g
--- VG #PV #LV #SN Attr VSize VFree
vg0 2 3 0 wz--n- 599.00g 209.00g
--- LV VG Attr LSize
root vg0 -wi-ao---- 5.00g
var vg0 -wi-ao---- 90.00g
data vg0 -wi-ao---- 295.00gWhen to use LVM
$ lsblk -o name,size,type,fstype,mountpointNAME SIZE TYPE FSTYPE MOUNTPOINT
sda 100G disk
├─sda1 1G part ext4 /boot
└─sda2 99G part LVM2_member
├─vg0-root 5G lvm ext4 /
└─vg0-var 90G lvm ext4 /var
sdb 500G disk
└─sdb1 500G part LVM2_member
└─vg0-data 295G lvm xfs /dataUse LVM when:
- Filesystems need to grow or shrink over time.
- Storage spans multiple physical disks.
- Snapshots are needed (LVM snapshots, not btrfs).
- The operations team needs flexible storage management.
Do not use LVM when:
- A single disk with a single fixed-size partition is enough.
- The performance overhead of LVM is unacceptable (rare on modern kernels).
- The team has no LVM experience and the workload is simple.
LVM commands
$ pvcreate /dev/sdc1; vgcreate vg_data /dev/sdc1; lvcreate -L 100G -n data vg_data; mkfs.ext4 /dev/vg_data/data; mount /dev/vg_data/data /dataPhysical volume '/dev/sdc1' successfully created.
Volume group 'vg_data' successfully created
Logical volume 'data' successfully created$ lvextend -L +50G /dev/vg_data/data; resize2fs /dev/vg_data/dataSize of logical volume vg_data/data changed from 100.00g to 150.00g
resize2fs 1.47.0 (5-Feb-2023)
Resizing the filesystem on /dev/vg_data/data to 39321600 (4k) blocks.
The filesystem on /dev/vg_data/data is now 39321600 (4k) blocks long.LVM snapshots
$ lvcreate -L 5G -s -n data-snap /dev/vg_data/dataLogical volume 'data-snap' successfully createdMonitor the fill level for the life of the snapshot. Data% is
the percentage of the COW space consumed:
$ lvs -o lv_name,origin,lv_size,data_percent,lv_attr vg_data LV Origin LSize Data% Attr
data 100.00g owi-aos---
data-snap data 5.00g 62.40 swi-a-s---
old-snap data 2.00g 100.00 swi-I-s---Illustrative output
Two operational consequences follow. First, a snapshot is a
temporary object: take it, do the work, then lvremove it. A
forgotten snapshot fills silently and also slows every write to
the origin, because each first overwrite of a block costs an
extra read and write. Second, alert on Data% the same way you
alert on filesystem usage.
If you want the safety net, turn it on explicitly:
# /etc/lvm/lvm.conf
activation {
snapshot_autoextend_threshold = 70
snapshot_autoextend_percent = 20
}
sudo systemctl enable --now lvm2-monitor
Auto-extend can still fail if the VG has no free extents, so keep headroom in the VG. It reduces the risk; it does not remove the need to size the snapshot properly.
Knowledge check
Knowledge check · 5 questions
Q1. What are the three layers of LVM?
Q2. LVM snapshots are an effective backup mechanism.
Q3. Which of the following are correct uses of LVM? Select all that apply.
Q4. The size given to lvcreate -s is a fixed copy-on-write allocation, and nothing extends it unless dmeventd is monitoring the volume.
Q5. You take a 10G snapshot of a 500G database LV as a rollback point, then run a migration that rewrites about 40G. The migration goes wrong. What state is your rollback in?
Passing score: 75%. Answers are checked in this browser.