Lesson 010 · Linux Administration Learning Path

RHEL LVM, Swap and Safe Storage Growth

· Published · 8 min read

Labelled RHEL Linux administration learning path highlighting physical volumes volume groups logical volumes filesystem growth swap pressure evidence and recovery

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

LayerQuestion to answerEvidence
Physical volumeWhich device/extents contribute?pvs with UUID, size and free extents
Volume groupWhat shared capacity and policy exist?vgs, free space and ownership
Logical volumeWhich workload owns allocated extents?lvs, path, size, attributes and devices
Filesystem/swapHow is the LV formatted and consumed?findmnt, filesystem tools or swapon
ApplicationWhat growth, latency and recovery objective apply?Capacity forecast, backup and acceptance evidence

Grow an LVM-backed filesystem safely

  1. Resolve the application mount. Map mountpoint to filesystem, LV, VG and physical devices.
  2. Confirm available and recoverable capacity. Check VG free extents, platform allocation and backup/restore state.
  3. Forecast the requested size. Leave capacity for other owned volumes and operational needs.
  4. Extend the exact LV. Use an explicit size or increment and capture before/after metadata.
  5. Grow the filesystem with its supported tool. XFS grows while mounted; ext4 growth follows its supported state and tooling.
  6. 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 --test example 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

EvidenceHealthy resultFailure meaning
Layer mappingMount, filesystem, LV, VG and PV chain is exactCapacity may be added to the wrong workload
VG capacityEnough free extents remain after planned reserveGrowth can consume recovery or sibling workload capacity
Filesystem supportSelected grow operation matches type and mount stateLV grows while filesystem remains unchanged or is damaged
Swap evidencePaging and pressure align with workload diagnosisDisabling swap can convert pressure into OOM termination
BackupExpanded dataset remains within backup and restore objectivesCapacity 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
CheckpointWhat to establish
Expected resultThe layered identities are visible, /srv/app mounts, and the VG retains planned free space.
If it failsA wrong PV destroys signatures; confirm disk identity and backup before pvcreate.
Safe recoveryRestore 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
CheckpointWhat to establish
Expected resultBoth the block device and XFS show the added capacity while the filesystem remains mounted.
If it failsExtending the LV alone does not enlarge every filesystem; XFS cannot be shrunk.
Safe recoveryRestore 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
CheckpointWhat to establish
Expected resultThe swap device is active with understood priority and has an fstab entry by stable identity.
If it failsSwap use alone is not failure; sustained memory pressure and workload latency determine urgency.
Safe recoveryRestore 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
CheckpointWhat to establish
Expected resultThe snapshot mounts read-only with XFS nouuid and data usage remains below its limit.
If it failsA full snapshot becomes invalid; a snapshot is not an independent backup.
Safe recoveryRestore LVM metadata from the automatic archive only with verified device identity; restore application data from its tested backup.

Independent practice tasks

  1. Extend an ext4 LV with the correct filesystem step.
  2. Move extents from one disposable PV to another.
  3. Create two swap devices with explicit priorities and prove selection.
  4. 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

SymptomInspect firstDefensible next action
LV larger but df unchangedFilesystem type, mountpoint and grow historyRun the supported filesystem grow only after exact mapping
VG has no free extentsPV capacity, unused LVs, platform storage and forecastAdd verified storage or migrate; do not delete an unidentified LV
Swap use growsPaging rate, PSI, working set and application allocationCorrect leak/capacity or tune based on evidence, not blanket swapoff
Thin pool near fullData/metadata percent and autoextend policyAdd monitored capacity before write failure affects tenants
Snapshot invalidSnapshot data percentage and origin healthUse independent backup; recreate only after understanding change rate

Unsafe operations and recovery boundaries

  • Unsafe: lvreduce can truncate live filesystem data. Never reduce without filesystem support, offline procedure, exact mapping and tested backup.
  • Unsafe: swapoff without 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

What is a physical volume?
A block device initialized for LVM that contributes extents to a volume group.
What does a volume group provide?
A pool of extents from which logical volumes are allocated.
Does extending an LV always grow its filesystem?
No. They are separate layers unless a reviewed command explicitly performs both.
Can XFS be reduced?
No supported shrink is available; migrate data to a correctly sized filesystem.
What does swap usage alone prove?
Very little about current pressure; inspect paging rate, PSI, latency and workload behavior.
Why can a thin-pool metadata shortage be serious?
Metadata exhaustion can prevent writes across multiple thin volumes even if data percentage seems acceptable.
Is an LVM snapshot a backup?
Not by itself. It depends on the origin and same storage and can fill under change.
What completes storage growth?
Filesystem capacity, application writes, monitoring, backup coverage and retained layer metadata all verify.

Guided lab and acceptance test

  1. Create loop-backed disposable devices or attach a lab disk; record exact identity.
  2. Create a PV, VG and small LV, then format it with XFS and mount by UUID.
  3. Write sample data and capture PV/VG/LV/filesystem capacity.
  4. Extend the LV first and observe that filesystem capacity has not changed.
  5. Grow XFS, verify data and capacity, and monitor the layered evidence.
  6. Add a small lab swap LV, observe it with swapon, then remove all lab mappings in dependency order.

Primary references

Advertisement