How to resize a VM disk in Google Cloud Compute Engine
Introduction
I’ve lately found myself having to increase the disk size on a debian virtual machine in my Google Cloud, more specifically in compute engine.
Here I will show you, step by step, how to do it, it’s quite simple.
1. Resize the VM disk
First, we need to resize the disk that is linked to the VM.
This can be easily done from the Web GUI for Compute Engine.
- In the left panel, go to Disks:

- Click on the disk that is linked to your VM (usually it has the same name as the VM)

- Click on “Edit” at the top right

- In “Size”, increase it to the desired size. I will increase it from 10 GB to 32 GB:

ℹ️ As you can see, you can only increase the size, not decrease it.
- Hit save at the bottom
2. Resize the partition inside the VM
The size of the disk has increased, but our VM partition is still the same, we need to increase it as well.
To do this:
-
SSH into your VM.
-
Verify the current disk state by running
lsblk, you should see the following:sda 32G <-- disk is now 32 GB └─sda1 10G <-- filesystem still 10GBℹ️ If you see any other partitions, that is completely normal.
-
Extend the partition:
sudo growpart /dev/sda 1With this command, we tell the system to expand the
sda1partition to occupy as much of the main disk as it can.ℹ️ If you don’t have growpart installed you can do so by running:
sudo apt install cloud-guest-utils -
Verify the partition by running
lsblkagain:sda 32G └─sda1 32G <-- filesystem is now 32GB -
Now we need to expand the debian filesystem. We can do it by resizing it depending on the format:
If you’re on ext4 (most standard Debian systems):
sudo resize2fs /dev/sda1If you’re on xfs:
sudo xfs_growfs -d / -
Done! You should now have the 32 GB (or whatever you wanted) available in your filesystem!