Linux/LVM how to decrease file system size

From voipsupport
Jump to: navigation, search

In this example the /home file system (ext4) is being reduced. Before starting backup the data.

1. find the logical volume being used for /home


2. Unmount the file system (any program accessing the file system needs to be stopped first)

umount /home

3. Check file system

e2fsck -f /dev/VolGroup/LogVol02

4. Resize the file system (resize to less than you will reduce the Logical Volume)

resize2fs /dev/VolGroup/LogVol02 6G

5. Resize the Logical Volume in this case by 2G (be careful without the - in front of 2G the new file system will be only 2G)

lvreduce -L -2G /dev/VolGroup/LogVol02

6. Resize the file system back to the new logical volume size

resize2fs /dev/VolGroup/LogVol02

7. Remount the file system

mount /home

If you need to decrease the size of the root file system, you will need to boot into rescue mode first, skip mounting filesystems and then at the prompt activate lvm with

vgchange -a y

At that point you can change the root volume file system size.