Increase the Size of Root Volume in Google Cloud Platform — GCP

Google cloud platform is one of the popular public cloud providers out there. It has a lots of mind blowing features. But in this post, I’ll cover a small part related to VM Instances.
Recently, we faced an issue of low storage in our server. Generally, when we create a VM instance, we size it according to our current need. Although, upfront sizing of storage for future needs, that may arise, is not a trouble creator, when you’re using providers like Google.
However, you can still increase the storage size whenever you feel like, without any downtime.
Lets go through step by step.
Lets say, you have an instance, which has a root volume, and has 10G of storage space. You want to increase the size to 80G.
- Login to the instance and run command,
df -h
This command will show you the root volume size.

You need to login as admin or use sudo su to run as admin
2. Then to view the instance properties, run
gcloud compute instances describe [INSTANCE NAME] |grep disk
[INSTANCE NAME]: It is the name of your server. Here in my case, its production.

3. Then you need to specify the desired size you want. For that, run
gcloud compute disks resize [INSTANCE NAME] — size [SIZE]GB
[INSTANCE NAME]: It is the name of your server. Here in my case, its production.
[SIZE]: Mention the size of the disk you want.

Always mention a size greater than the current size.
4. Our disk is resized, and operating system is well aware of this fact. How to confirm? You can simply execute the below command and see that the operating system has already detected the new disk size.
fdisk -l

5. Now, df -h will still show the old size for /dev/sda1 (which is our root volume), because we have yet not changed our partition size. The tool that will help us do that is called as “growpart”. Growpart will extend the size of a partition to whatever you like. If you do not specify any size, it will use all the available space in our disk (/dev/sda) to increase the size of our partition (/dev/sda1). Run,
growpart /dev/sda 1

6. The command/tool that will help us here is called as resize2fs. resize2fs can be used to resize ext2, ext3, and ext4 file systems.
resize2fs /dev/sda1

7. Finally to verify, run df -h again.

And you’re done.
Did you find this post interesting, a clap will be appreciated. Cheers!!
#NextPostTopic What would you like to know about? Let me know in comments.
