How to Reduce/Shrink a ext[234] File System

In order to shrink a file system, the file system must be unmounted.

 

For example with a LVM Logical volume called testfilesystem in volume group testVG mount on  /opt/testfilesystem  ( /dev/testVG-testfilesystem or /dev/mapper/testVG-testfilesystem) that we want to make 162 GB in sise.

 

First unmount the filesystem:

umount /opt/testfilesystem

Then resize the filesystem:

resize2fs /dev/mapper/testVG-testfilesystem 162G

Check the file system integrety:

e2fsck -f /dev/mapper/testVG-testfilesystem

Now the logical volume can be shrunk to match the filesystem:

lvreduce -L 162G /dev/mapper/testVG-testfilesystem

Mount the file system again, assuming it is in /etc/fstab.

 

/opt/testfilesystem

Leave a Reply

Your email address will not be published. Required fields are marked *