df -h only shows 10GB, but I've assigned a 500GB disk to the GCE instance

Solution 1:

It seems Google Compute Engine does offer automatic resizing of root partitions on most operating systems (I'm usually using Debian, so never had such issues), CentOS it seems is not one of them.

See: https://cloud.google.com/compute/docs/disks/persistent-disks#repartitionrootpd

In my case, manual repartition is needed, see: https://cloud.google.com/compute/docs/disks/persistent-disks#manualrepartition

After going through the steps, my disk size is now 500GB

lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0  500G  0 disk 
└─sda1   8:1    0  500G  0 part /

Solution 2:

Here are the steps in you have single xfs (/dev/sda1) partition.

Don`t forget to make snapshot before trying!

First re-create your root partition, type this command:

(echo d; echo n; echo p; echo 1; echo ; echo; echo w) | sudo fdisk /dev/sda

Then restart your server. Once restarted, grow your partition

xfs_growfs /dev/sda1

Verify with:

df -h