HOWTO Reduce a LVM ext4 filesystem

We all know the pain of fitting filesystems down in size, many avoid it, but recently I was forced to do a refitting of some big production filesystem, so I went in with Google and Red Hat articles. This resulted in me writing this lines, and I found that they worked well. I love storeage, and I love LVM. I find it fascinating to administrating storage with LVM.

1. First you unmount the filesystem
[root@system ~]# umount /filesystem-to-reduce

2. Then you check the filesystem, in this case ext4
[root@system ~]# fsck.ext4 -f /dev/mapper/lv

3. Instead of calculating on how much you can shave off you ask the system to reduce to minimal size
[root@system ~]# resize4fs -M /dev/vg_blah/lv_blah

4. Mount the filesystem.
[root@system ~]# mount /dev/mapper/lv

5.  Read out the size to do you baseline for reduction
[root@system ~]# df -h /filesystem

6. Readout the size and put 10% on to it
Add 10% to used space

7. Unmount the filesystem to begin your reduction of the fileystem
[root@system ~]# umount /filesystem

8. do the reduction of the lv in this case I add 1% more on top of it (To be safe)
[root@system ~]# lvreduce /dev/mapper/lv -L -[used space + 11%]

9. Resize the filesystem (ext4)
[root@system ~]# resize4fs /dev/vg_blah/lv_blah

10. Mount the fileystem to see the result
[root@system ~]# mount /filesystem-to-reduce

Share

Comments are closed.