Shrink ext4 filesystem and reduce the size of a Logical Volume in Linux

Hello guys,
I would like to ask you kindly if you don't know some quick and safe method how to shrink ext4 filesystem and reduce the size of a Logical Volume in Linux, please?
Thank you very much.

Welcome los_bandidos,

You need to be able to unmount the filesystem. If that is not possible, then you are a bit stuck, but it is still possible however it will mean downtime.

What OS are you using? Assuming it is RHEL or similar, the command would be based on lvreduce

You can use a selection of flags, the most important one is -r which deals with the filesystem residing on the logical volume. This will unmount it, coalesce the files to the early par of the filesystem and then reduce the size. It then reduces the size of the logical volume and remounts the filesystem.

Depending on how large, how full and how fragmented the filesystem is, it can take a while to run.

Other options that are very common would be -l or -L , lower and upper case L which set the size. The manual page will give you the details on how to use each.

So, your eventual command might become:-

lvreduce -r -L 20G /dev/mapper/vg_data-lv_stockbook

Does this help?

Robin

1 Like

Hello,
I know very quick and safe method to shrink ext2, ext3 and ext4 filesystem and reduce the size of a Logical Volume with basically just one command.
Please watch it here:
Shrink ext2 ext3 and ext4 file system and reduce the size of a logical volume with only one command. - YouTube

Thanks.

1 Like