Please disable Adblock!

Resize the persistent disk in the Google Cloud Platform Console:

Resize the persistent disk in the Google Cloud Platform Console:
  1. Go to the Compute Engine page.
  2. Click on "Disks" in the sidebar
  3. Click the name of the disk that you want to resize.
  4. At the top of the disk details page, click "Edit".
  5. In the "Size" field, enter the new size for your disk.
  6. At the bottom of the disk details page, click "Save" to apply your changes to the disk.
  7. After you resize the disk, you must resize the disk partitions so that the operating system can access the additional space.

Resize your persist disk on Google Cloud on the fly

How many time do you have to stop your VM and attach a new disk because you ran out of space when downloading a huge dataset or training a model.
Well, you don’t have to do so. Cloud computing has been evolving for many years and resize disk on the fly is now a trivial task for users to do. I believe Cloud provider has developed pretty advanced virtual disk technology, but I’ll skip that since I’m not an expert.
This post is a pretty short step-by-step guide on how to do so on Google Cloud Compute Engine. It only applies for arguably the most common case — The entire disk is reserved for a single partition /.

Step 0.1: Check remaining disks available

$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 77G 0 77G 0% /dev
tmpfs 16G 9.1M 16G 1% /run
/dev/sda1 970G 552G 418G 57% /
tmpfs 77G 228K 77G 1% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 77G 0 77G 0% /sys/fs/cgroup
Line starting with /dev/sda1 is the one you’re looking for. From the example above, you notice that you have used more than half of the disk mounted as /
If you see the use rate is over 80%, that’s probably a dangerous sign.

Step 0.2: Check partition

$ sudo lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 1000G 0 disk 
└─sda1 8:1 0 1000G 0 part /
You noticed that device sda only contains one partition sda1, which made things much simpler.

Step 1: Increase disk size

In your VM . instance setting, click on the disk (either boot disk or additional disk), then increase the capacity by the amount you need.

Step 2: Grow the partition

Go to your VM console
$ sudo growpart /dev/sda 1
CHANGED: partition=1 start=2048 old: size=419428319 end=419430367 new: size=2097149919
,end=2097151967

Step 3: Resize file system

$ sudo resize2fs /dev/sda1
resize2fs 1.42.13 (17-May-2015)
Filesystem at /dev/sda1 is mounted on /; on-line resizing required
old_desc_blocks = 13, new_desc_blocks = 63
The filesystem on /dev/sda1 is now 262143739 (4k) blocks long.

Step 4: Verify

$ df -h
All done. Enjoy!