How do I shrink a Linux filesystem?

WARNING: storage maintenance, especially reducing filesystems, can potentially result in errors or data loss. Plan and act accordingly. Always create backups and follow best practices.

For this example, we’ll be using the standard /dev/datavg/eclipse LV that’s mounted at /u2/eclipse. We’ll be shrinking the filesystem to 50GB.

Begin by unmounting the file system:

umount /u2/eclipse

Force a filesystem check:

e2fsck -f /dev/datavg/eclipse

Reduce the file system. The number specified here is the final, target size of the filesystem, not the amount by which it is reduced.

resize2fs /dev/datavg/eclipse 50G

The logical volume must also be reduced by the same amount:

lvreduce -L 50G /dev/datavg/eclipse

Mount the filesystem and run df to verify the change was made:

mount /u2/eclipse
df -h /u2/eclipse

Resources:

  • https://access.redhat.com/kb/docs/DOC-5531
  • http://blog.shadypixel.com/how-to-shrink-an-lvm-volume-safely/