Skip to content
Search AlmaLinux

    Browse this documentation

    AlmaLinux 9: grow an LVM volume and XFS (tested on a real host)

    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”.

    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.

    Terminal window
    sudo dnf install -y lvm2 xfsprogs
    truncate -s 2G /var/tmp/lvm-lab.img
    LOOP=$(sudo losetup -f --show /var/tmp/lvm-lab.img)
    sudo pvcreate -y "$LOOP"
    sudo vgcreate vglab "$LOOP"
    sudo lvcreate -y -L 1G -n lvdata vglab
    sudo mkfs.xfs -q /dev/vglab/lvdata
    Physical volume "/dev/loop0" successfully created.
    Volume group "vglab" successfully created
    Logical volume "lvdata" created.
    Terminal window
    sudo mkdir -p /mnt/lvmlab
    sudo mount /dev/vglab/lvdata /mnt/lvmlab
    df -h /mnt/lvmlab | tail -1
    /dev/mapper/vglab-lvdata 960M 39M 922M 5% /mnt/lvmlab

    A 1 GiB LV formatted with XFS shows about 960 MB usable (metadata overhead).

    Terminal window
    sudo lvextend -L +512M /dev/vglab/lvdata
    df -h /mnt/lvmlab | tail -1
    Size 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/lvmlab

    The 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”
    Terminal window
    sudo xfs_growfs /mnt/lvmlab | tail -3
    df -h /mnt/lvmlab | tail -1
    data blocks changed from 262144 to 393216
    /dev/mapper/vglab-lvdata 1.5G 43M 1.4G 3% /mnt/lvmlab

    xfs_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”
    Terminal window
    sudo umount /mnt/lvmlab
    sudo lvremove -y vglab/lvdata
    sudo vgremove -y vglab
    sudo pvremove -y "$LOOP"
    sudo losetup -d "$LOOP"
    rm -f /var/tmp/lvm-lab.img

    Order matters: unmount → remove LV → remove VG → remove PV → detach the loop device.

    • lvextend without growing the filesystem: df never changes — the point of this page;
    • xfs_growfs on ext4: it fails outright; ext4 needs resize2fs;
    • Wrong argument to xfs_growfs: passing the device instead of the mount point reports “not a mounted XFS”.
    Terminal window
    sudo dnf install -y lvm2 xfsprogs
    truncate -s 2G /var/tmp/lab.img
    LOOP=$(sudo losetup -f --show /var/tmp/lab.img)
    sudo pvcreate -y "$LOOP" && sudo vgcreate vglab "$LOOP"
    sudo lvcreate -y -L 1G -n lvdata vglab
    sudo mkfs.xfs -q /dev/vglab/lvdata
    sudo mkdir -p /mnt/lvmlab && sudo mount /dev/vglab/lvdata /mnt/lvmlab
    sudo lvextend -L +512M /dev/vglab/lvdata
    sudo xfs_growfs /mnt/lvmlab
    df -h /mnt/lvmlab

    Checks:

    1. lvs vglab → the LV is 1.50g
    2. df -h /mnt/lvmlab → about 1.5G
    3. xfs_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.