resize2fs / xfs_growfs — growing a filesystem
Grow ext4/xfs after a volume grows — online growth, shrinking only on ext4 offline.
Cheat sheet
6 commands Printable version-
sudo lvextend -L +10G /dev/labvg/datagrow the volume first (see lvm) -
sudo resize2fs /dev/labvg/dataext4: fill all free space in the volume -
sudo resize2fs /dev/labvg/data 20Gext4: to a specific size -
sudo xfs_growfs -d /dataxfs: mountpoint, not the device! -
sudo lvextend -r -L +10G /dev/labvg/datavolume + filesystem in one command -
df -h /datacheck the result
Overview
After lvextend (or growing a cloud disk's partition), the block device has
more free space, but the filesystem on it doesn't — not until you grow it with
a separate command:
- ext4/ext3/ext2 →
resize2fs, grows online (on a mounted filesystem). - xfs →
xfs_growfs, also online, but it takes the mountpoint, not the device name.
lvextend -r does both steps in one command (see lvm) — but it's worth
knowing them separately: a cloud disk grows the same way, and so does a
filesystem that isn't on LVM at all.
Options
6Below are the main flags of resize2fs and xfs_growfs; the full list is in
man resize2fs/man xfs_growfs.
| Option | What it does | Example |
|---|---|---|
-d SIZE |
Grow the data section (the part of XFS you can never shrink back). | xfs_growfs -d /data |
-p |
Show progress while resizing. | resize2fs -p /dev/labvg/data |
SIZE SIZE |
Target size (K/M/G/T); with no argument, grow to fill the partition/LV. | resize2fs /dev/labvg/data 20G |
-n |
Report the current filesystem geometry without changing anything. | xfs_growfs -n /data |
-M |
Shrink the filesystem to the smallest size it can be (before shrinking the volume). dangerous | resize2fs -M /dev/labvg/data |
-f |
Force the resize even if the filesystem was not unmounted cleanly. dangerous | resize2fs -f /dev/labvg/data |
Nothing found. Try a shorter query.
Recipes
3xfs: xfs_growfs
Both steps at once
Troubleshooting
4xfs_growfs: "specified file is not on device"
You passed the device name (/dev/labvg/data) instead of the mountpoint.
xfs_growfs takes the mount path (/data), unlike resize2fs.
df -h doesn't show the new size after lvextend
The volume grew, but the filesystem didn't yet: the separate resize2fs/
xfs_growfs step (or lvextend -r) is missing.
resize2fs: "New size smaller than minimum"
The target size is smaller than the data already on the filesystem. Find the
minimum: sudo resize2fs -P /dev/labvg/data (in filesystem blocks).
The resize hangs or complains about space
Free space is needed at the volume group level, not just the logical
volume: sudo vgs (free space in the VG) and sudo lvs — if the VG is empty,
vgextend/add a disk first (see lvm).
Danger zone
2XFS can only grow, never shrink
xfs_growfs has no reverse operation: shrinking XFS is not possible with
standard tools at all. To reduce a partition holding XFS, create a smaller
filesystem and migrate the data (back up, mkfs.xfs, restore) — there's no
shortcut.
Shrinking ext4 — offline, and with margin
resize2fs can shrink ext4, but only on an unmounted filesystem and
before shrinking the volume itself (lvreduce), never after — otherwise
it truncates live data. Run e2fsck -f first (see filesystems) and back
up beforehand: a wrong size calculation corrupts the filesystem irreversibly.
See also
- lvm — PV → VG → LV; flexible disk management, extending and snapshots.
- mount — Mounting and fstab — mountpoints, UUIDs, bind mounts and tmpfs.
- disk-usage — Where did the space and inodes go — df, du, finding large files.
Found an inaccuracy? Report an error in the article