As a server administrator, it is common to find our root partition is filled up with files especially logs cause our server not able to run smoothly due to not enough space. This could happened when we create only one disk partition for OS installations especially for cloud server. The workaround to solve this kind of issue either we remove the unneeded files and logs or we resize the root partition if we have more space on our physical disk.

This tutorial will focus on the solution by increasing the root disk/partition. The two important command that we are going to use is


and also


the first step and the most important step before we start using the two commands is to backup all your data somewhere safe.
Once done, you can start check your actual physical disk size and available partition using

fdisk -l

Then what you need to do is to run growpart against you physical disk and partition. For example your disk is /dev/vda and your partition is 1, your partition will be displayed as /dev/vda1. What growpart does is actually extending the size of your partition to the maximum allowed physical disk size. You can run below command:

growpart /dev/vda 1

Once it finish you will see growpart has extend your partition table to the maximum available disk size. Now, you need to reboot your server.
When the server comes live again, you can run resize2fs command to extend the filesystem. below is the sample command.

resize2fs /dev/vda1

Since the /dev/vda1 is mounted. resize2fs will now try to extend the partition online, without having to unmount the partition first. Check your new partition size using

df -h

you should see the size of your partition and filesystem has been increase.

Show Buttons
Hide Buttons