resize2fs grows or shrinks an ext2/3/4 filesystem. It’s commonly used after expanding a partition or LVM logical volume. For many ext filesystems, online growth (while mounted) is supported — but shrinking is more restrictive.
e2fsck.
Always verify the correct device (especially with LVM) before resizing.
resize2fs is part of e2fsprogs.
# Debian/Ubuntu sudo apt install e2fsprogs # Fedora/RHEL sudo dnf install e2fsprogs # Arch sudo pacman -S e2fsprogs
sudo resize2fs /dev/sdX1
If the underlying partition was extended, this grows the filesystem to the new maximum.
sudo resize2fs /dev/mapper/vg0-lvdata
Very common after lvextend.
# 1) Extend the LV by 20G sudo lvextend -L +20G /dev/vg0/lvdata # 2) Grow the filesystem to match sudo resize2fs /dev/vg0/lvdata
On ext4, this is often online (can be mounted). Confirm your FS supports online resize.
sudo lvextend -r -L +10G /dev/vg0/lvdata
-r attempts to resize the filesystem as part of the LV change. Exact behavior depends on distro tooling.
sudo e2fsck -f /dev/vg0/lvdata
Especially important before shrinking, or if the filesystem was not cleanly unmounted.
sudo resize2fs /dev/vg0/lvdata 200G
Specifies a target filesystem size (units depend on version; verify with man page).
sudo resize2fs -P /dev/vg0/lvdata
Prints minimum size the filesystem can be shrunk to (in blocks).
# 1) Unmount sudo umount /mnt/data # 2) Check filesystem sudo e2fsck -f /dev/vg0/lvdata # 3) Shrink filesystem FIRST (to smaller than the final LV size) sudo resize2fs /dev/vg0/lvdata 150G # 4) Then shrink the LV sudo lvreduce -L 150G /dev/vg0/lvdata # 5) Final check (optional but wise) sudo e2fsck -f /dev/vg0/lvdata
Rule: shrink filesystem first, then LV. Growing is the reverse (LV first, then filesystem).
df -hT /mnt/data lsblk -f
Confirm mountpoint and filesystem sizes are aligned.
sudo pvs sudo vgs sudo lvs -a -o +devices lsblk -f
Use these before resizing so you don’t hit the wrong LV or partition.
lvextend, lvreduce, lvs, pvs, vgs, e2fsck, tune2fs