Skip to content

Instantly share code, notes, and snippets.

@TomTasche
Created August 1, 2021 20:10
Show Gist options
  • Save TomTasche/886d7034d1cc875c4536c6850c6f6e1c to your computer and use it in GitHub Desktop.
Save TomTasche/886d7034d1cc875c4536c6850c6f6e1c to your computer and use it in GitHub Desktop.
Recreating boot disk of a live instance from last snapshot on Google Cloud Platform
# stop instance
gcloud compute instances stop YOURINSTANCE --zone=YOURZONE
# remove boot disk from instance
gcloud compute instances detach-disk YOURINSTANCE --zone=YOURZONE --disk YOURDISK
# delete old boot disk
gcloud compute disks delete YOURDISK --zone=YOURZONE
# find last snapshot
gcloud compute snapshots list --sort-by=~creationTimestamp --limit=1
# create disk from last snapshot
gcloud beta compute disks create YOURDISK --type=pd-balanced --size=100GB --zone=YOURZONE --source-YOURSNAPSHOT
# attach new disk to instance
gcloud compute instances attach-disk YOURINSTANCE --zone=YOURZONE --disk YOURDISK --boot
# start instance
gcloud compute instances start YOURINSTANCE --zone=YOURZONE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment