How to resize a gcePersistentDisk on GKE

Sam Decrock
2 min readMar 11, 2020

--

If you’re like me and you defined your Google Persistent disk on GKE like this:

volumes:
- name: your-volume-name
gcePersistentDisk:
pdName: your-disk
fsType: ext4

Then, like me, you won’t have a partition table on this disk. Apparently it is possible to simply write to a disk without having a partition table.

Photo by Matti Johnson on Unsplash

To increase a persistent disk defined in this way, start by going to your Disks and increase its size:

I’m increasing the size to 80GB here

Next, hit Save and click the link In use by. This will take you to the VM where the disk is attached to.

Next, click the SSH button to start an SSH session with the virtual machine:

On the VM, you should be able to see your attached disk with:

$ sudo df -h | grep /dev/sdb
/dev/sdb 40G 27G 13G 69% /var/lib/kubelet/plugins/kubernetes.io/gce-pd/mounts/your-disk

As you can see, it is still 40GB instead of the resized 80GB.

Next, resize it with

$ sudo resize2fs /dev/sdb

Verify its size:

$ sudo df -h | grep /dev/sdb
/dev/sdb 79G 27G 52G 35% /var/lib/kubelet/plugins/kubernetes.io/gce-pd/mounts/your-disk

That’s it! Your Kubernetes cluster should now be able to use the extra disk space.

--

--

Sam Decrock
Sam Decrock

Written by Sam Decrock

Hardware and software (reverse) engineer. Passionate about new technologies. samdecrock.be

No responses yet