Instiq
Chapter 2 · Filesystems and storage management·v1.0.0·Updated 7/7/2026·~12 min

What's changed: Initial version (topic 2.02, subtopics 2.02.1–2.02.3)

2.3Configuring and Managing LVM

Key points

Learn flexible storage management with LVM (Logical Volume Manager): the overall lvm command and lvm.conf, and the three-layer structure of pv commands for physical volumes (PV), vg commands for volume groups (VG), and lv commands for logical volumes (LV), plus practical resizing and extension.

Formatting a partition directly makes it hard to flexibly grow or shrink capacity later. LVM adds a layer of abstraction over physical disk constraints, enabling volumes to be extended, shrunk, and spread across multiple disks—even while the system is running—an indispensable tool in real operations.

2.3.1The three-layer LVM structure

  • A physical volume (PV) is LVM's bottom-layer entity (a partition or a whole disk). Handled with pv commands: pvcreate (initialize as a PV), pvdisplay (detailed view), pvs (concise listing), pvremove (release a PV).
  • A volume group (VG) is the middle layer that pools multiple PVs together. Handled with vg commands: vgcreate (build a VG from PVs), vgextend (grow a VG by adding a PV), vgreduce (remove a PV), vgdisplay/vgs (display).
  • A logical volume (LV) is carved out of the VG pool as needed and is what actually gets a filesystem. Handled with lv commands: lvcreate (create from a VG), lvextend (grow), lvreduce (shrink), lvremove (delete), lvdisplay/lvs (display).

2.3.2The lvm command and lvm.conf

  • lvm can invoke every PV/VG/LV subcommand (pvcreate, etc.) through a single interactive shell / unified front end (used as lvm pvcreate ..., or entering interactive mode by running lvm alone).
  • lvm.conf controls LVM's overall behavior (which devices to scan, filters, logging, backup location, etc.). It typically runs fine at defaults; you edit it for special narrowing, such as restricting LVM to specific devices only.
Exam point

The staples: the PV → VG → LV three layers; pvcreate is the first step, vgcreate builds from PVs, lvcreate builds from a VG; extending an LV uses lvextend, and the filesystem itself also needs a separate resize command afterward; extending a VG uses vgextend to add a PV. Accurately mapping the command prefix (pv/vg/lv) to its layer is directly tied to exam points.

LVM's real value is the operational flexibility to grow capacity without stopping the system when it runs low. Walk through a typical extension scenario. First add a disk, carve a partition, and turn it into a PV with pvcreate /dev/sdc1. Next, fold that PV into an existing VG (say vg_data) with vgextend vg_data /dev/sdc1growing the VG. At this point the pool (VG) has more free space, but the actual LV in use (e.g., /dev/vg_data/lv_home) is still its original size, so you extend the LV itself with something like lvextend -L +20G /dev/vg_data/lv_home. The step most often missed is the final one: resizing the filesystem itself. Even after LVM grows the block device's capacity, the ext4 or XFS layer on top still thinks "my size is unchanged," so you must separately run a filesystem-level resize commandresize2fs for ext-family, or xfs_growfs for XFS (notably, XFS growfs can run while mounted)—before the added space becomes usable. Shrinking runs the opposite way: you must shrink the filesystem before shrinking the LV (lvreduce), and getting the order wrong risks data loss, so shrinking demands more caution than growing (ext4 can grow while mounted but must be unmounted (offline) to shrink, while XFS notably cannot shrink at all—an important practical asymmetry).

LayerCreate commandExtend command
Physical volume (PV)pvcreate(PV itself is not extended)
Volume group (VG)vgcreatevgextend (add a PV)
Logical volume (LV)lvcreatelvextend (+ filesystem-level resize)
Warning

Trap: "extending an LV with lvextend automatically extends the filesystem on top of it" is wrong—resizing the LVM block device and resizing the filesystem are separate steps; for ext-family you must additionally run resize2fs, and for XFS xfs_growfs, or the added capacity stays unusable. Also, "vgcreate builds a VG directly from a physical disk" is wrong—a VG is built from PVs, so you must run pvcreate first to turn the disk into a PV.

The PV/VG/LV three-layer structure, the pvcreate/vgcreate/lvcreate and vgextend/lvextend extension flow, and its relationship to filesystem-level resize.
After extending an LV, resize2fs / xfs_growfs is also required

2.3.3Section summary

  • PV (pv*) → VG (vg*) → LV (lv*), three layers. Create in order pvcreate → vgcreate → lvcreate; extend by adding a PV with vgextend, then growing the LV with lvextend
  • After extending an LV, always also run a filesystem-level resize (resize2fs / xfs_growfs). When shrinking, the filesystem comes first. Overall behavior is controlled via lvm.conf

Sign in to track progress — Log in.

Quick check

(just a quick review)

Q1. You want to make newly added disk /dev/sdc usable by LVM and fold it into the existing volume group vg_data. What is the correct order of operations?

Q2. Logical volume /dev/vg_data/lv_home is running low on space. Right after extending it with lvextend -L +20G, what else must you do before applications can actually use the added capacity?

Q3. You need to shrink a logical volume's capacity. Which procedure is safe and correct?

Check your understandingPractice questions for Chapter 2: Filesystems and storage management