Increase Standard / Extend Root Partition Using fdisk

Increase Standard / Extend Root Partition Using fdisk

Learn the step-by-step process of how to increase a standard partition & extend root partition using fdisk online in Linux without downtime or losing data

In this article, we will look at how to extend/increase a standard partition online (no downtime) without losing data and we will use the root partition (/) as an example.

How To Increase / Extend The Root (/) Partition In Linux Using The fdisk Utility

NOTE 1: Take a backup of your system if you can. If it a VM on Azure or any other cloud services provider, take the snapshot of the OS disk

NOTE 2: The reason for the backup is to roll back if anything goes wrong. If your filesystem is healthy, it is very rare for an issue to occur. These steps are the steps I usually take and have used in a production environment before and was successful. So, no worries.

NOTE 3: When you use the “d” option to delete the partition and use the “n” option afterward, what you are doing is actually creating a partition table and remains in memory and not deleting the whole partition, so no worries.

Step By Step Process

1. verify the root (/) filesystem size

2. verify the root(/) filesystem type

You can see that the root filesystem type is “xfs”

3. Initialize /dev/sda using the fdisk utility

enter the letter “p” to print all the partitions on sda

enter the letter “d”to delete a partition

enter the partition number 3 or press enter to leave it at default which is 3

NOW, ENTER THE LETTER “n” TO RECREATE THE PARTITION TO YOUR DESIRED SIZE

enter the letter “p” to make it a primary partition, yours might be secondary depending on the number of partitions you have. A disk can have only four partitions as primary partitions

enter the partition number which is 3 or press enter to leave at default which is 3

press the enter key again to get to the last sector

enter the new partition size or press the enter key to use the whole available space on sda. In this scenario, we are using the whole available space

enter “no” not to remove the signature

enter the letter “w” to write or save the changes and press enter

4. verify the partition increment

5. resize the filesystem,

If the filesystem is xfs, use the command,

If you get the error above, use the command,

If the filesystem is ext (2,3,4), use “resize2fs” instead

6. you may also run the command below to make immediate changes to the kernel

7. verify the filesystem new size

You can see that the size has increased.