Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detach disk from stopped instance

Is there a way via the Google Console to detach a disk from a stopped instance ? (its SSD Persistent if it makes any difference)

I have created an instance via the Console, done some configuation on it, and stopped it. I have done this on an f1-micro machine whilst testing.

I was hoping to do some further testing on a higher spec instance, and was expecting to be able to just change this (assuming its in a stopped state).

However, I can't see any option to do this, as it says the disk is still attached to the stopped instance.

Is there any way to detach and use the existing disk on a new instance, or do I have to delete the instance every time ? Ideally I'm looking to do this via the Console, but gcloud commands may be ok.

Or is it best to take a Snapshot, and start a new instance from that, or something else?

like image 655
Ian Avatar asked Oct 18 '25 15:10

Ian


2 Answers

Hot-remove of the root disk is currently not supported for Google Compute Engine instances. As such, you have the following workarounds, which you also have mentioned in your question.

  1. Delete the instance by keeping the boot disk and recreating another instance with this disk.
  2. Taking the snapshot of this boot disk and recreating another instance/disk with this snapshot.

I would recommend the second workaround because you always will have a backup of your disk, in if anything goes wrong (e.g. boot disk deleted by mistake etc). Both of these workarounds can be accomplished through developer console or gcloud.

like image 191
Faizan Avatar answered Oct 22 '25 04:10

Faizan


I think the issue you were running into is that you were trying to detach the boot disk of your instance, and at the time, that was unsupported.

Detaching boot disks is now supported in Beta (docs). After shutting down instance, try: gcloud beta compute instances detach-disk INSTANCE_NAME --disk DISK_NAME

To re-attach a boot disk to another: gcloud beta compute instances attach-disk INSTANCE_NAME --disk DISK_NAME --boot

like image 37
Sirui Sun Avatar answered Oct 22 '25 03:10

Sirui Sun