Linux Filesystem Ext* LVM

resize2fs — resize ext2/3/4 filesystems

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.

What resize2fs is good for

Danger: Shrinking filesystems is riskier and usually requires unmounting plus a clean e2fsck. Always verify the correct device (especially with LVM) before resizing.

Install

resize2fs is part of e2fsprogs.

# Debian/Ubuntu
sudo apt install e2fsprogs

# Fedora/RHEL
sudo dnf install e2fsprogs

# Arch
sudo pacman -S e2fsprogs

10 Practical Examples

1) Grow an ext filesystem to fill the device

sudo resize2fs /dev/sdX1

If the underlying partition was extended, this grows the filesystem to the new maximum.

2) Grow an ext filesystem on an LVM logical volume

sudo resize2fs /dev/mapper/vg0-lvdata

Very common after lvextend.

3) Typical LVM growth workflow (safe and common)

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

4) One-liner: extend LV and filesystem together

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.

5) Check filesystem first (recommended before risky operations)

sudo e2fsck -f /dev/vg0/lvdata

Especially important before shrinking, or if the filesystem was not cleanly unmounted.

6) Grow to an explicit size (advanced)

sudo resize2fs /dev/vg0/lvdata 200G

Specifies a target filesystem size (units depend on version; verify with man page).

7) Show estimated minimum size needed (for shrinking planning)

sudo resize2fs -P /dev/vg0/lvdata

Prints minimum size the filesystem can be shrunk to (in blocks).

8) Safe shrink workflow (overview)

# 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).

9) Verify the new size

df -hT /mnt/data
lsblk -f

Confirm mountpoint and filesystem sizes are aligned.

10) Identify the correct device names in LVM

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.

Notes & Gotchas

Related commands: lvextend, lvreduce, lvs, pvs, vgs, e2fsck, tune2fs