Disk is full, and I can't SSH to instance

You have different options to fix this issue:

  1. Check if your operating system supports automatic resizing: If so, using Cloud Console you can edit VM's root disk and increase its size. Your virtual machine instance can automatically resize the partition to recognize the additional space after you restart the instance.

  2. Use Interactive Serial Console feature to login to your VM and clean up your VM's disk or copy them to another storage, if you would need them later.

  3. If you know what data you want to delete, you can configure a startup script to remove the files and reboot your VM to run the script (e.g. rm /tmp/*).

  4. You can detach the persistent disk and attach this disk to another machine as an additional disk. On the temporary machine, you can mount it and clean up your data or copy them to another storage, if you would need them later. Finally recreate the original instance with the same boot disk. You can follow the same steps described in this video to add your disk to another Linux VM but add your existing boot disk instead of creating a new disk.

  5. Check if your operating system supports automatic resizing: If yes, then create a snapshot of your persistent disk, create a new persistent disk with larger size from the snapshot. Finally recreate the original instance with this larger boot disk.


For anyone else that runs into this problem!

Simplest solution as I just had to deal with this (going from full cannot access ssh 10 GB Boot SSD on centos 7 instance to 20 GB Boot SSD)

Using the Cloud Console:

  1. create snapshot of the boot disk : https://console.cloud.google.com/compute/snapshots
  2. create new boot disk from snapshot just created but set the new disk size to 20 GB (or whatever you feel you may need) : https://console.cloud.google.com/compute/disks
  3. Next Stop the instance : https://console.cloud.google.com/compute/instances
  4. Once stopped edit the instance and click the 'X' to the right of the boot disk and the "ADD" button will become available, click that and select your newly created boot disk and save - this will detach the overloaded disk you cannot access and attach your newly created boot disk with a complete partition at your new size no need to extend a 10 gb partition to 20 as it is auto-magic

This seams to solve multiple issues related with a boot disk with no remaining space.

If you like me saw the ssh login notice saying you should switch to oslogin because it couldn't connect by web ssh and then set it up properly only to find out "even tho you can access the instance over ssh it is extremely limited because it cannot add the user to the sudo group policy and it can't create a home directory - so you get errors trying to do anything including extending the boot disk which I also tried (but didn't have permissions to get to the home directory I need to in order to delete files to allow a connection without errors to extend the boot drive or add the necessary tools thru yum) this will definitely fix all that as well.

Once completed "if your on a budget" I recommend deleting the snapshot and old boot disk that is no-longer attached to anything.

Supporting links: How to Create a Snapshot: https://cloud.google.com/compute/docs/disks/create-snapshots#creating_snapshots

How to create boot persistent disk from a snapshot: https://cloud.google.com/compute/docs/disks/create-root-persistent-disks#applying_snapshots

How to Update a boot disk for an instance: https://cloud.google.com/compute/docs/disks/detach-reattach-boot-disk#updating_a_boot_disk_for_an_instance