It is possible to modify a partition size on EXT filesystem thanks to some few commands.
We will take here a simple example:
- We have a /dev/sda5 partition mounted on /home
- Its size is currently 150G and we want to reduce it to 100G
Let’s check the current config (mounting point and size):
Filesystem Size Used Avail Use% Mounted on /dev/sda1 28G 3.3G 23G 8% / /dev/sda2 477M 112M 341M 25% /boot /dev/sda3 4.7G 12M 4.5G 1% /tmp /dev/sda4 32G 470M 30G 2% /var /dev/sda5 148G 87M 140G 1% /home
We need to first unmount the partition:
# umount /dev/sda5
If you can’t unmount it, double check what process is using it with the lsof command:
# lsof /home
Then proceed with a check with e2fsck command and resize the partition with resize2fs by defining the new size (M for Megabytes, G for Gigabytes, and so on…)
# e2fsck -f /dev/sda5 # resize2fs /dev/sda5 100G
Mount your partition back to your system:
# mount /home
And check again your partition sizes :
Filesystem Size Used Avail Use% Mounted on /dev/sda1 28G 3.3G 23G 8% / /dev/sda2 477M 112M 341M 25% /boot /dev/sda3 4.7G 12M 4.5G 1% /tmp /dev/sda4 32G 470M 30G 2% /var /dev/sda5 99G 87M 94G 1% /home
We can see that the partition /home has now a size of 100G as expected!