How to resize a Google Cloud drive

Writing this up as got caught by a wrong command on the actual Google docs - was resizing a disk from 100Gb to 300Gb.

You resize the disk in the Google Cloud admin console. Then use "growpart" to resize the partition, then use "resize2fs" to resize the file system.

root@server:/var/www/html# growpart /dev/sda 1
CHANGED: partition=1 start=227328 old: size=209487839 end=209715167 new: size=631015391,end=631242719

If you have a look with "fdisk /dev/sda" you'll see the partition size has changed, BUT the filesystem size has not.

root@server:/var/www/html# fdisk /dev/sda
/dev/sda1 227328 838860766 838633439 399.9G Linux filesystem
root@server:/var/www/html# df -k .
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda1 101445540 79288364 22140792 79% /

So next you run the resize2fs command :

root@server:~# resize2fs /dev/sda1
resize2fs 1.44.1 (24-Mar-2018)
Filesystem at /dev/sda1 is mounted on /; on-line resizing required
old_desc_blocks = 13, new_desc_blocks = 50
The filesystem on /dev/sda1 is now 104829179 (4k) blocks long.
root@server:/var/www/html# df -k .
Device Start End Sectors Size Type /dev/sda1 227328 631242718 631015391 300.9G Linux filesystem


Leave a Reply