LVM stacking.
Logical Volume Manager turns physical disks into pools you can carve, grow, snapshot, and migrate without downtime. Build the stack layer by layer; then extend live and snapshot. Maps to the RH134 storage objectives.
LVM (Logical Volume Manager) explained with animations. Physical volumes, volume groups, logical volumes, filesystems, extension, and snapshots. Covers the RHCSA EX200 exam objectives on LVM storage.LVM is a layer between your disks and your filesystem. The payoff: combine multiple disks into one pool, carve flexible "virtual partitions" out of it, grow them online, and snapshot for backup. Build the stack one layer at a time.
- ·Mounting a filesystem (mount, /etc/fstab)
- ·Reading block devices with lsblk and df
- ·Comfortable as root or with sudo
Build a Volume Group, carve a Logical Volume out of it, format/mount it, then extend it online and snapshot it for backup — explaining each layer.
pace: 8 minutes
Before LVM — bare disks
Without LVM, you'd partition each disk with fdisk/parted and put a filesystem directly on the partition. Need more space? Back up, repartition, restore — usually with downtime.
$lsblkThe LVM commands all start with the layer they operate on: pv* for physical volumes, vg* for volume groups, lv* for logical volumes. Master the naming and the rest follows: pvs / pvdisplay, vgs / vgdisplay / vgextend, lvs / lvdisplay / lvextend / lvreduce / lvremove.
$pvs / pvdisplay$pvcreate /dev/sdX1$vgs / vgdisplay$vgcreate vg_data /dev/sdX1 /dev/sdY1$vgextend vg_data /dev/sdZ1$lvs / lvdisplay$lvcreate -L 10G -n NAME vg_data$lvcreate -l 100%FREE -n NAME vg_data$lvextend -L +5G --resizefs /dev/vg/NAME$lvreduce -L -2G --resizefs /dev/vg/NAME$lvcreate -s -L 2G -n NAME_snap /dev/vg/NAME$lvremove /dev/vg/NAME$vgrename / lvrename$pvmove /dev/sdoldWhich LVM layer pools multiple physical volumes into a single space?
Your /var/www LV is full. Disk has free space. One-line fix?
You want to take a consistent backup of /var/www without stopping writes. What's the LVM move?
Which file system can NOT be shrunk online (or at all without unusual tools)?
These aren't graded — they're just for active recall, which is what actually makes the lesson stick.
Read this lesson as text7 chapters · quiz answers
01Before LVM — bare disks
Without LVM, you'd partition each disk with fdisk/parted and put a filesystem directly on the partition. Need more space? Back up, repartition, restore — usually with downtime.
$ lsblk— show what's attached
02pvcreate — mark disks as LVM-managed
pvcreate writes LVM metadata to the start of each block device. Now it's a Physical Volume. The data area is still empty — we haven't allocated anything.
$ pvcreate /dev/sda1 /dev/sdb1 /dev/sdc1— create PVs from partitions$ pvs— list PVs and how full they are
03vgcreate — pool the PVs
Volume Group: a storage pool made from one or more PVs. The VG sees the combined capacity as one space. PVs can be added or removed without recreating it.
$ vgcreate vg_data /dev/sda1 /dev/sdb1 /dev/sdc1— create a VG$ vgs— show VGs$ vgextend vg_data /dev/sdd1— later: add another PV
04lvcreate — carve out a logical volume
Logical Volume: a virtual partition inside the VG. It can span multiple PVs invisibly. To apps it looks like any block device at /dev/mapper/<vg>-<lv>.
$ lvcreate -L 10G -n lv_web vg_data— carve a 10G LV called lv_web$ lvs— show LVs
05mkfs + mount — make it usable
Format the LV with a filesystem (XFS by default on RHEL), add it to /etc/fstab, mount it. Now apps can read and write.
$ mkfs.xfs /dev/mapper/vg_data-lv_web— format as XFS$ mkdir -p /var/www && mount /dev/mapper/vg_data-lv_web /var/www— mount it$ echo '/dev/mapper/vg_data-lv_web /var/www xfs defaults 0 0' >> /etc/fstab— make it survive reboot
06lvextend — grow it live
The killer LVM feature: extend an LV (and its filesystem) without unmounting. Add +5G with --resizefs and the XFS grows online. Zero downtime.
$ lvextend -L +5G --resizefs /dev/mapper/vg_data-lv_web— grow LV + filesystem in one step$ xfs_growfs /var/www— manual XFS grow (if needed separately)$ df -h /var/www— see the new size
07Snapshot — backup without locking
Create a copy-on-write snapshot of an LV. The snapshot starts as a pointer to the original; only changed blocks consume snapshot space. Take a backup from the snapshot while production keeps writing.
$ lvcreate -s -L 2G -n lv_web_snap /dev/mapper/vg_data-lv_web— create a 2G CoW snapshot$ mount /dev/mapper/vg_data-lv_web_snap /mnt/snap— mount the snapshot read-only-ish$ lvremove /dev/mapper/vg_data-lv_web_snap— delete when done
Quiz — answers
- Which LVM layer pools multiple physical volumes into a single space?
- →Volume Group (VG)The Volume Group is the pool. PVs feed into it; LVs are carved out of it.
- Your /var/www LV is full. Disk has free space. One-line fix?
- →lvextend -L +5G --resizefs /dev/vg/lv_web--resizefs grows both the LV and the filesystem online. No unmounting needed for XFS.
- You want to take a consistent backup of /var/www without stopping writes. What's the LVM move?
- →lvcreate -s -L 2G -n lv_web_snap /dev/vg/lv_web, then back up from the snapshotSnapshots are copy-on-write. The snapshot is a frozen view of the LV at one instant; production keeps writing to the original.
- Which file system can NOT be shrunk online (or at all without unusual tools)?
- →XFSXFS supports growing but not shrinking. If you need to shrink, use ext4 — or migrate the data.
keep going — these pair well with what you just learned.
SELinux contexts
Why Apache can't read your file. Watch the policy engine decide — and learn the workflow for fixing denials. RHCSA-ready.
Linux boot process
From power button to login prompt. Every stage in the chain — UEFI, GRUB, kernel, initramfs, systemd — with the rescue moves that save you. RHCSA-ready.
systemd targets
How systemd organizes services with dependencies and targets. Visual dependency graph, target nesting, and the isolate trick. RHCSA-ready.