When working with LVM-managed EXT4 filesystems, many administrators discover the hard truth:
# resize2fs /dev/mapper/system-srv 2G
resize2fs 1.42.6 (21-Sep-2012)
Filesystem at /dev/mapper/system-srv is mounted on /srv; on-line resizing required
resize2fs: On-line shrinking not supported
This isn't just a version-specific limitation - it's a fundamental constraint of the EXT4 filesystem design. The error message is clear: online shrinking of EXT4 simply isn't implemented in the kernel.
The technical challenges include:
- Complex metadata adjustments required for shrinking
- Risk of data corruption if blocks are reallocated during operation
- No safe mechanism to handle active writes to shrinking areas
Here's the standard procedure for safely shrinking an EXT4 volume:
# Unmount the filesystem
umount /srv
# Run filesystem check
e2fsck -f /dev/mapper/system-srv
# Resize the filesystem first
resize2fs /dev/mapper/system-srv 2G
# Then resize the LVM volume
lvreduce -L 2G /dev/mapper/system-srv
# Remount the filesystem
mount /srv
For systems requiring minimal downtime:
- Use LVM snapshots to create a temporary copy
- Build a new smaller filesystem on another volume
- Rsync data while the system is live
- Switch to the new volume during brief maintenance window
If online shrinking is critical for your use case, consider:
- XFS: Supports online shrinking since kernel 4.9
- Btrfs: Native support for online shrink operations
- ZFS: Advanced volume management capabilities
Remember that shrinking any filesystem carries risks - always verify backups before proceeding.
When working with LVM-managed EXT4 filesystems, you might encounter the frustrating message:
# resize2fs /dev/mapper/system-srv 2G
resize2fs 1.42.6 (21-Sep-2012)
Filesystem at /dev/mapper/system-srv is mounted on /srv; on-line resizing required
resize2fs: On-line shrinking not supported
This is because EXT4 filesystems, unlike their expansion capabilities, don't support online shrinking due to potential data corruption risks during the process.
Here are the practical workarounds for safely shrinking your EXT4 volume:
Method 1: Offline Shrinking
# umount /srv
# e2fsck -f /dev/mapper/system-srv
# resize2fs /dev/mapper/system-srv 2G
# lvreduce -L 2G /dev/mapper/system-srv
# mount /srv
Method 2: LVM Snapshot Approach
# lvcreate -L 2G -s -n srv_snapshot /dev/mapper/system-srv
# mkdir /mnt/temp
# mount /dev/mapper/system-srv_snapshot /mnt/temp
# rsync -a /srv/ /mnt/temp/
# umount /srv
# lvremove /dev/mapper/system-srv
# lvcreate -L 2G -n srv /dev/system
# mkfs.ext4 /dev/mapper/system-srv
# mount /dev/mapper/system-srv /srv
# rsync -a /mnt/temp/ /srv/
Before attempting any resizing operations:
- Always have a complete backup
- Ensure sufficient free space in the filesystem
- Verify filesystem integrity with e2fsck
- Consider downtime requirements for your system
For large filesystems, monitor progress with:
# watch -n 1 pvs
# watch -n 1 df -h