How to reduce LVM filesystem in Linux
Unlike growing the filesystem, reducing the filesystem should be practiced carefully. In the example below, we will see - how to reduce LVM filesystem using the lvreduce command.
Note: Make sure to take the backup of the filesystem which will be reduced in size. This is important step before proceeding.
Note: Make sure that the Logical Volume is not mounted before proceeding with the steps below.
System utilities used:
1. lsblk 2. df 3. lsof 4. du 5. umount/mount 6. lvreduce
Follow the steps outlined below to reduce the logical volume:
1. Make sure that the device is readable by the Operating System
# lsblk
2. Verify filesystem’s type e.g. ext4:
# df -Th
3. Verify if there is a running process on top of the affected filesystems:
# lsof [directory mounpoint]
4. Unmount all filesystems on top of the affected directory:
# umount [directory]
5. Verify the size of the affected directory:
# du -sh
Note: Make sure that the new size is larger than the result of du -sh.
6. Unmount the affected directory:
# umount [directory]
7. Reduce the affected directory:
# lvreduce -L [size] -r [logical volume device]
8.Mount all back previously unmounted filesystems:
# mount [directory]