Resizing Linux root partitions without unmount on Google Cloud

Posted on 23-11-2017 by Nadir Latif


Virtual machines often run out of disk space and require resizing. Resizing root partitions without unmounting is always risky. It is recommended to take a backup of the partition's useful data before resizing the partition.

To resize the root partition we need to first increase the disk size in the virtual machine configuration. Next we need to enter the command sudo fdisk /dev/{root_partition_name}. This will open the root partition in the fdisk program.

The next step is to print the partition table using the command 'p'. Note the starting block number of the root partition. Next we need to delete the root partition using the command 'd'. Next we need to create the root partition using the command 'n'. We will need to enter the starting block number that we noted earlier. The size of the new partition should be set to the new size. Next we need to write the partition table using the 'w' command. After that we need to reboot the virtual machine.