Cloud Services

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

1*Ynqs YuKQ5vCrV

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.

  1. Login to the instance and run command,

df -h

This command will show you the root volume size.

1* Zt r55pWG5czHmVSIhObA

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.

1*tsVLkR

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.

1*0irgoFHE0JaXQIi y5ObUA

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

1*ADwWD2O4nzkeDJ4emO3LRQ

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

1* Qvctg

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

1*338LxbCgQAJ zrejmSUAlg

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.

Rajesh Mishra

I'm a developer who loves sharing insights, technical how-tos, and lessons learned from the world of code. While much of what I write may not be groundbreaking, I believe in documenting for future me—and for anyone else who might find it useful. Beyond tech, I also dive into life's experiences and moments, reflecting on personal growth and sharing stories that resonate. Whether you're here for practical tips or a fresh perspective on life, I hope you find something meaningful.

Leave a Reply

Your email address will not be published. Required fields are marked *