skip to content
Ruban Selvarajah

Resizing a disk in Compute Engine is not that simple

/ 1 min read

Maybe it’s obvious in hindsight but you can’t just update the disk size through the dashboard. Well technically you can but there’s a bit more work to be done before it’s reflected in your VM. Just follow the steps.

Let’s 🚀

In Cloud Console

Goto Compute Engine > Disks > Edit

  • Update to a different size and save
  • I’m resizing mine from 10GB to 50GB

In the VM shell

1. Resize the partition

Terminal window
sudo parted /dev/sda
Partition number? 3
End? 100%

2. Get PV information

Terminal window
# Note the PV_NAME and Logical volume
sudo pvdisplay -m

3. Resize physical volume

Terminal window
# sudo pvresize PV_NAME
sudo pvresize /dev/sda3

4. Resize Logical volume

Terminal window
# sudo lvresize Logical volume
sudo lvresize /dev/ubuntu-vg/ubuntu-lv -L +40g

5. Expand fs to use the space

Terminal window
sudo resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
df -h

Voilà, my disk is now utilising all the extra space I allocated through the Cloud Console earlier.