RHEL LVM, Swap and Safe Storage Growth
LVM separates application storage from physical placement, which makes growth and replacement easier only when each layer is understood. Extending a logical volume changes the block device; growing the filesystem is a separate operation unless a reviewed command deliberately combines them. Reducing capacity is much riskier and may be impossible for the filesystem. Swap is emergency and workload memory capacity, not a universal performance defect to disable.
Map capacity at every LVM layer
A physical volume contributes extents to a volume group. Logical volumes allocate those extents and expose block devices. Filesystems allocate their own structures inside an LV. Free space in the volume group is not filesystem free space, and extending an LV without growing its filesystem does not make additional file capacity visible.
LVM snapshots use copy-on-write storage and must have enough capacity for changed blocks. They are not independent backups: loss of the origin or underlying storage affects them, and a full snapshot becomes unusable. Use snapshots for bounded consistency workflows only when the application and backup design support them.
Track capacity from memory to persistent data
| Layer | Question to answer | Evidence |
|---|---|---|
| Physical volume | Which device/extents contribute? | pvs with UUID, size and free extents |
| Volume group | What shared capacity and policy exist? | vgs, free space and ownership |
| Logical volume | Which workload owns allocated extents? | lvs, path, size, attributes and devices |
| Filesystem/swap | How is the LV formatted and consumed? | findmnt, filesystem tools or swapon |
| Application | What growth, latency and recovery objective apply? | Capacity forecast, backup and acceptance evidence |
Grow an LVM-backed filesystem safely
- Resolve the application mount. Map mountpoint to filesystem, LV, VG and physical devices.
- Confirm available and recoverable capacity. Check VG free extents, platform allocation and backup/restore state.
- Forecast the requested size. Leave capacity for other owned volumes and operational needs.
- Extend the exact LV. Use an explicit size or increment and capture before/after metadata.
- Grow the filesystem with its supported tool. XFS grows while mounted; ext4 growth follows its supported state and tooling.
- Accept and monitor. Verify capacity, application writes, latency, backup coverage and alert thresholds.
Inspect LVM, filesystems and swap pressure
pvs -o pv_name,pv_uuid,vg_name,pv_size,pv_free
vgs -o vg_name,vg_uuid,vg_size,vg_free
lvs -a -o lv_path,lv_uuid,vg_name,lv_size,lv_attr,devices,data_percent,metadata_percent
findmnt -T /srv/application
df -hT /srv/application
lsblk -f
swapon --show --output=NAME,TYPE,SIZE,USED,PRIO
free -h
vmstat 1 5
cat /proc/pressure/memory
lvextend --test -L +10G /dev/vgapp/lvdata
xfs_growfs /srv/application- The
lvextend --testexample performs a dry-run style metadata check; it cannot prove the later filesystem operation or workload impact. - Do not run the growth commands until the exact LV, mount and backup are verified. Replace sample names deliberately.
- Swap used is not the same as active swap pressure. Inspect paging rate, memory pressure, latency and workload behavior over time.
- For thin pools, monitor both data and metadata percentages. Exhausting either can disrupt multiple logical volumes.
Evidence and acceptance criteria
| Evidence | Healthy result | Failure meaning |
|---|---|---|
| Layer mapping | Mount, filesystem, LV, VG and PV chain is exact | Capacity may be added to the wrong workload |
| VG capacity | Enough free extents remain after planned reserve | Growth can consume recovery or sibling workload capacity |
| Filesystem support | Selected grow operation matches type and mount state | LV grows while filesystem remains unchanged or is damaged |
| Swap evidence | Paging and pressure align with workload diagnosis | Disabling swap can convert pressure into OOM termination |
| Backup | Expanded dataset remains within backup and restore objectives | Capacity change silently exceeds recovery design |
Worked scenario: LV extended but application still reports full
An operator extends an LV by 100 GB and sees the larger block device in lvs, but df and the application show no new capacity. The filesystem was never grown. Repeating lvextend consumes more VG space without addressing the missing layer.
The team maps the mount to the exact LV, identifies XFS, verifies the backup and runs xfs_growfs against the mounted filesystem. It records filesystem capacity and application write evidence, then updates monitoring and backup forecasts. The incident runbook now requires proof at every layer.
Practical how-to cases
Case 1: Build an LVM stack
Create PV, VG, LV and XFS on one disposable disk while retaining free extents. Resolve every PV and LV by identity and preserve a current backup before changing allocation.
sudo pvcreate /dev/vdc
sudo vgcreate vgapp /dev/vdc
sudo lvcreate -L 4G -n lvdata vgapp
sudo mkfs.xfs /dev/vgapp/lvdata
sudo mkdir -p /srv/app
sudo mount /dev/vgapp/lvdata /srv/app
pvs; vgs; lvs -a -o +devices| Checkpoint | What to establish |
|---|---|
| Expected result | The layered identities are visible, /srv/app mounts, and the VG retains planned free space. |
| If it fails | A wrong PV destroys signatures; confirm disk identity and backup before pvcreate. |
| Safe recovery | Restore LVM metadata from the automatic archive only with verified device identity; restore application data from its tested backup. |
Case 2: Grow XFS online
Measure demand, extend the LV, then grow the mounted filesystem as separate operations. Resolve every PV and LV by identity and preserve a current backup before changing allocation.
df -hT /srv/app
vgs vgapp
sudo lvextend --test -L +2G /dev/vgapp/lvdata
sudo lvextend -L +2G /dev/vgapp/lvdata
sudo xfs_growfs /srv/app
df -hT /srv/app| Checkpoint | What to establish |
|---|---|
| Expected result | Both the block device and XFS show the added capacity while the filesystem remains mounted. |
| If it fails | Extending the LV alone does not enlarge every filesystem; XFS cannot be shrunk. |
| Safe recovery | Restore LVM metadata from the automatic archive only with verified device identity; restore application data from its tested backup. |
Case 3: Add persistent swap
Create a dedicated swap LV and verify priority and reboot persistence. Resolve every PV and LV by identity and preserve a current backup before changing allocation.
sudo lvcreate -L 1G -n lvswap vgapp
sudo mkswap /dev/vgapp/lvswap
sudo swapon /dev/vgapp/lvswap
swapon --show
free -h
sudo blkid /dev/vgapp/lvswap| Checkpoint | What to establish |
|---|---|
| Expected result | The swap device is active with understood priority and has an fstab entry by stable identity. |
| If it fails | Swap use alone is not failure; sustained memory pressure and workload latency determine urgency. |
| Safe recovery | Restore LVM metadata from the automatic archive only with verified device identity; restore application data from its tested backup. |
Case 4: Use a snapshot with limits
Create a short-lived snapshot for a consistent operation and monitor copy-on-write use. Resolve every PV and LV by identity and preserve a current backup before changing allocation.
sudo lvcreate -s -L 1G -n lvdata_snap /dev/vgapp/lvdata
lvs -o lv_name,origin,lv_size,data_percent,metadata_percent
sudo mkdir -p /mnt/snap
sudo mount -o ro,nouuid /dev/vgapp/lvdata_snap /mnt/snap
findmnt /mnt/snap| Checkpoint | What to establish |
|---|---|
| Expected result | The snapshot mounts read-only with XFS nouuid and data usage remains below its limit. |
| If it fails | A full snapshot becomes invalid; a snapshot is not an independent backup. |
| Safe recovery | Restore LVM metadata from the automatic archive only with verified device identity; restore application data from its tested backup. |
Independent practice tasks
- Extend an ext4 LV with the correct filesystem step.
- Move extents from one disposable PV to another.
- Create two swap devices with explicit priorities and prove selection.
- Trigger snapshot growth in a lab and monitor the failure boundary.
For this lesson on RHEL LVM and Swap Administration, complete each task without copying the worked command sequence. Record the initial state, exact change, verification, negative test and recovery command. A task is unfinished if it works now but does not survive a reboot where persistence is required.
Troubleshooting by symptom
| Symptom | Inspect first | Defensible next action |
|---|---|---|
| LV larger but df unchanged | Filesystem type, mountpoint and grow history | Run the supported filesystem grow only after exact mapping |
| VG has no free extents | PV capacity, unused LVs, platform storage and forecast | Add verified storage or migrate; do not delete an unidentified LV |
| Swap use grows | Paging rate, PSI, working set and application allocation | Correct leak/capacity or tune based on evidence, not blanket swapoff |
| Thin pool near full | Data/metadata percent and autoextend policy | Add monitored capacity before write failure affects tenants |
| Snapshot invalid | Snapshot data percentage and origin health | Use independent backup; recreate only after understanding change rate |
Unsafe operations and recovery boundaries
- Unsafe:
lvreducecan truncate live filesystem data. Never reduce without filesystem support, offline procedure, exact mapping and tested backup. - Unsafe:
swapoffwithout enough available memory can trigger severe reclaim or OOM kills. Measure headroom and workload behavior. - Unsafe: treating an LVM snapshot as the only backup ties recovery to the same origin and storage failure domain.
Rewritten knowledge checks
Guided lab and acceptance test
- Create loop-backed disposable devices or attach a lab disk; record exact identity.
- Create a PV, VG and small LV, then format it with XFS and mount by UUID.
- Write sample data and capture PV/VG/LV/filesystem capacity.
- Extend the LV first and observe that filesystem capacity has not changed.
- Grow XFS, verify data and capacity, and monitor the layered evidence.
- Add a small lab swap LV, observe it with
swapon, then remove all lab mappings in dependency order.