LVM — Logical Volume Manager
Linux Filesystems
Chapter 5 · LVM — Logical Volume Manager
Btrfs and ZFS (fs1-3, fs1-4) manage volumes themselves, internally. This chapter is about the traditional alternative for filesystems that don't — ext4 and XFS most commonly — a separate layer purpose-built to sit between raw storage and the filesystem: LVM, the Logical Volume Manager. It's also the chapter that finally delivers on a promise grub1-8 deliberately left open.
The PV/VG/LV Model
- Physical Volume (PV) — a raw disk or partition initialized for LVM's use.
- Volume Group (VG) — a pool combining one or more PVs into a single pool of storage, potentially spanning multiple physical disks.
- Logical Volume (LV) — a "virtual partition" carved out of a VG — this is what actually gets formatted with a filesystem and mounted.
Why This Extra Layer Exists — Flexibility
The value LVM adds beyond a plain partition: a logical volume isn't tied to the physical geometry of a single disk. A volume group can span multiple physical disks, so a logical volume can be larger than any single disk in the machine. And, most importantly, logical volumes can be resized live — without unmounting, without downtime, and without the rigid fixed-size commitment a plain partition forces at creation time.
Live Resizing — LVM's Real Payoff
Growing a logical volume can be done while it's mounted and actively in use:
Shrinking is genuinely riskier, and the order matters: the filesystem must be shrunk first (resize2fs to the smaller target size), and only then can the logical volume itself be reduced (lvreduce). Doing it in the wrong order truncates the logical volume out from under data the filesystem still thinks it owns — see the warn-box below.
Delivering on grub1-8's Deferred Promise
grub1-8 deliberately deferred LVM considerations in the context of multi-boot partitioning. Here's the real answer: GRUB can boot a root filesystem that lives on an LVM logical volume — grub-mkconfig detects LVM automatically and writes the correct boot parameters. But /boot itself is commonly kept outside LVM, as its own small, plain partition, because GRUB's ability to parse LVM metadata directly to locate a kernel and initrd is more limited and more fragile than reading a plain partition — especially once LVM is layered on RAID, or the volume is encrypted. This is exactly why Debian's own default installer layout (seen back in linux1) carves out a small separate /boot partition even when the rest of the disk uses LVM.
In a real multi-boot setup, this makes LVM genuinely useful: each Linux distribution's own root filesystem can live in its own logical volume within a shared volume group, letting disk space be divided among multiple distros flexibly rather than requiring fixed-size partitions decided up front — while GRUB itself, and ideally /boot, stays on plain partitions for maximum compatibility across every OS involved.
A Worked Example — Growing a Live Filesystem
| Resizable live? | Spans multiple disks? | Snapshot support? | |
|---|---|---|---|
| Plain partition | No — fixed at creation | No | No |
| LVM logical volume | Grow: yes. Shrink: filesystem-dependent, order matters | Yes, via the volume group | Yes — LVM snapshots (COW-based, distinct from Btrfs/ZFS's own) |
pvs, vgs, and lvs each print a one-line-per-item summary of physical volumes, volume groups, and logical volumes respectively. pvdisplay/vgdisplay/lvdisplay give the full detail view for each when a summary isn't enough.
resize2fs to the smaller size, then lvreduce. Reducing the logical volume before the filesystem has been shrunk to fit truncates the space out from under data the filesystem still believes it owns, corrupting it. Also worth knowing: XFS cannot be shrunk at all — an XFS filesystem can only grow, never shrink, regardless of order.
Hands-On Exercises
A server has two physical disks, /dev/sdb and /dev/sdc, and needs one filesystem larger than either disk alone. Write the sequence of LVM commands needed to build this, from raw disks to a mounted filesystem.
📄 View solutionAn administrator runs lvreduce on a logical volume to shrink it before running resize2fs on the filesystem it holds. Explain what goes wrong and what the correct order should have been.
A user setting up a triple-boot machine (echoing grub1-8's own scenario) asks whether they can put GRUB's own /boot partition on an LVM logical volume alongside their distros' root filesystems. Using this chapter's own explanation, answer their question.
📄 View solutionChapter 5 Quick Reference
- PV → VG → LV — physical volume, volume group, logical volume, in that order
pvcreate/vgcreate/lvcreate— the creation commands for each layer- A volume group can span multiple physical disks — a logical volume can exceed any single disk's size
- Growing is live and safe:
lvextendthenresize2fs/xfs_growfs - Shrinking order matters: filesystem first (
resize2fs), thenlvreduce— reversed order corrupts data - XFS can only grow, never shrink, regardless of order
/bootis commonly kept outside LVM as a plain partition for GRUB compatibility, even when the rest of the disk uses LVMpvs/vgs/lvs— quick one-line-per-item summaries of each layer