gcloud compute instances attach-disk
wants a disk name, but it doesn't show up on my Disks page. It seems silly to create and pay for another disk when this one has much more storage than I plan to use.
Is it possible to mount the persistent disk that comes with CloudShell on another VM?
758 Views Asked by danben At
2
There are 2 best solutions below
2

As per the GCP article enter here, you can attach-detach disk to the VM instance from gcloud shell.
To detach a disk from a instance:
gcloud compute instances detach-disk [INSTANCE_NAME] --disk=[DISK_NAME]
To attach a disk to another instance:
gcloud compute instances attach-disk [INSTANCE_NAME] --disk=[DISK_NAME] --boot
Notice that the Cloud Shell is intended for interactive usage and that in general the disk is intended to be recycled, as you can't manage it and it will be deleted after 120 days of inactivity. You'll need to consider a different solution, such as Cloud Storage if you wish the data to persist in time. So you'd need to store your data in Cloud Storage and then create a new disk to store the information, as the Cloud Shell is a tool meant for rapid testing and prototyping and not as a development machine for persistent storage.