AlmaLinux 9: grow an LVM volume and XFS (tested on a real host)
Test scope
Section titled “Test scope”On a real AlmaLinux 9.8 host (kernel 5.14.0-687.54.1.el9_8, 4 vCPU / 3 GB RAM) a 2 GB file was attached as a loop device, then: pvcreate → vgcreate → lvcreate -L 1G → mkfs.xfs → mount → df → lvextend -L +512M → df (unchanged) → xfs_growfs → df (grown) → unmount and remove LV/VG/PV/loop. Log: plans/content-expansion/evidence/logs/alma-storage-lvm.log.
Partition-level growth on a real disk (parted/growpart) is not covered here; this page only covers “the PV already exists, grow the LV and the filesystem”.
Why practise on a loop device
Section titled “Why practise on a loop device”Practising LVM on the system disk means one wrong pvcreate is an outage. A file-backed loop device behaves like a separate disk, and losetup -d reclaims it without touching real partitions. Every output below comes from such a 2 GB loop disk.
Create PV / VG / LV
Section titled “Create PV / VG / LV”sudo dnf install -y lvm2 xfsprogstruncate -s 2G /var/tmp/lvm-lab.imgLOOP=$(sudo losetup -f --show /var/tmp/lvm-lab.img)sudo pvcreate -y "$LOOP"sudo vgcreate vglab "$LOOP"sudo lvcreate -y -L 1G -n lvdata vglabsudo mkfs.xfs -q /dev/vglab/lvdataPhysical volume "/dev/loop0" successfully created.Volume group "vglab" successfully createdLogical volume "lvdata" created.Mount and record the starting size
Section titled “Mount and record the starting size”sudo mkdir -p /mnt/lvmlabsudo mount /dev/vglab/lvdata /mnt/lvmlabdf -h /mnt/lvmlab | tail -1/dev/mapper/vglab-lvdata 960M 39M 922M 5% /mnt/lvmlabA 1 GiB LV formatted with XFS shows about 960 MB usable (metadata overhead).
Grow the LV: df does not change yet
Section titled “Grow the LV: df does not change yet”sudo lvextend -L +512M /dev/vglab/lvdatadf -h /mnt/lvmlab | tail -1Size of logical volume vglab/lvdata changed from 1.00 GiB (256 extents) to 1.50 GiB (384 extents).Logical volume vglab/lvdata successfully resized.
/dev/mapper/vglab-lvdata 960M 39M 922M 5% /mnt/lvmlabThe classic trap: the LV is already 1.5 GiB, but the filesystem does not know and df still shows 960M.
Grow the filesystem: xfs_growfs makes it visible
Section titled “Grow the filesystem: xfs_growfs makes it visible”sudo xfs_growfs /mnt/lvmlab | tail -3df -h /mnt/lvmlab | tail -1data blocks changed from 262144 to 393216
/dev/mapper/vglab-lvdata 1.5G 43M 1.4G 3% /mnt/lvmlabxfs_growfs takes the mount point, not the LV path; for XFS the mount point is the only accepted argument.
Clean up: unmount and reclaim the loop device
Section titled “Clean up: unmount and reclaim the loop device”sudo umount /mnt/lvmlabsudo lvremove -y vglab/lvdatasudo vgremove -y vglabsudo pvremove -y "$LOOP"sudo losetup -d "$LOOP"rm -f /var/tmp/lvm-lab.imgOrder matters: unmount → remove LV → remove VG → remove PV → detach the loop device.
Common traps
Section titled “Common traps”lvextendwithout growing the filesystem:dfnever changes — the point of this page;xfs_growfson ext4: it fails outright; ext4 needsresize2fs;- Wrong argument to
xfs_growfs: passing the device instead of the mount point reports “not a mounted XFS”.
Practice: run it safely on any host
Section titled “Practice: run it safely on any host”sudo dnf install -y lvm2 xfsprogstruncate -s 2G /var/tmp/lab.imgLOOP=$(sudo losetup -f --show /var/tmp/lab.img)sudo pvcreate -y "$LOOP" && sudo vgcreate vglab "$LOOP"sudo lvcreate -y -L 1G -n lvdata vglabsudo mkfs.xfs -q /dev/vglab/lvdatasudo mkdir -p /mnt/lvmlab && sudo mount /dev/vglab/lvdata /mnt/lvmlabsudo lvextend -L +512M /dev/vglab/lvdatasudo xfs_growfs /mnt/lvmlabdf -h /mnt/lvmlabChecks:
lvs vglab→ the LV is 1.50gdf -h /mnt/lvmlab→ about 1.5Gxfs_info /mnt/lvmlab | grep data→ blocks changed to 393216
常见问题
Why is df unchanged after lvextend?
Growing takes two steps: lvextend grows the logical volume (the block device), while the filesystem keeps using its old size. For XFS run xfs_growfs <mountpoint>; ext4 uses resize2fs <device>.
Can XFS shrink?
No. XFS supports online growth only. A smaller filesystem means backup and recreate, so plan capacity before choosing XFS.
What should I check before growing an LV in production?
Confirm free extents in the VG (vgs, VFree), confirm the mount point and filesystem type (findmnt), and take a snapshot or backup when possible. Growing the LV is online-safe, but do not interrupt the mount before growing the filesystem.
Next steps
Section titled “Next steps”- Swap and capacity: swap sizing
- Post-install checks: 7 checks after install
- Transaction rollback: dnf history undo