Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can I download a google compute engine image

How can I download a google compute engine image that was created from a snapshot of a persistent disk? There doesn't seem to be a direct way to do this through the console.

like image 296
sparker Avatar asked Jan 04 '15 19:01

sparker


People also ask

How do I download a GCP VM file?

In the Google Cloud console, go to the VM instances page. In the list of virtual machine instances, click SSH in the row of the instance that you want to connect to. After the connection is established, click the download icon download.

What is a Compute Engine image?

A machine image is a Compute Engine resource that stores all the configuration, metadata, permissions, and data from multiple disks of a virtual machine (VM) instance. You can use a machine image in many system maintenance, backup and recovery, and instance cloning scenarios.


2 Answers

There isn't a direct way to download a image or snapshot from GCE, but there's a way to save an image and store it in Google Cloud Storage(GCS) where it can be downloaded. You can use the standard gcimagebundle tool to do this.

You can also create this image using the dd command. On a temporary disk that’s bigger than the one you want to image, run this:

dd if=/dev/disk/by-id/google-diskname of=disk.img bs=5M

You can then run this command to copy it over to GCS:

gsutil cp disk.img gs://bucket/image.img

And later, you can:

gsutil cat gs://bucket/image.img | dd of=/dev/disk/by-id/google-newdisk bs=5M

This will allow you to make an image of your disk and then send it to GCS where you can download it using either the web interface or gsutil.

like image 166
Ali Avatar answered Oct 20 '22 13:10

Ali


As an addition to the current answer, you can it directly download a file using SSH / SCP, by adding your public key to the "SSH Keys". Then, using your own terminal :

sheryl:~ sangprabo$ scp [email protected]:/var/www/my-file.tar.gz . 
Enter passphrase for key '/Users/sangprabo/.ssh/id_rsa': 

I prefer that way so I don't need to create a bucket first. CMIIW.

like image 36
Prabowo Murti Avatar answered Oct 20 '22 11:10

Prabowo Murti