Burgaz
Burgaz

Reputation: 257

export image from GCE

I would like to export a VM (Windows) image from my google compute engine account. I found the relevant section explaining how to import an image TO CGE, but I failed to find the information about how to export an image from CGE. Do you nkow how it can be done and to which formats?

thanks, R.

Upvotes: 2

Views: 1843

Answers (1)

DoiT International
DoiT International

Reputation: 2435

The easiest way to export an instance's disk is by adding additional disk to your instance and create an image of that disk followed by copying that image to Google Cloud Storage bucket (so you can download it or share with others).

Steps:

  • Add one more disk of the same size as your boot disk (or a bit larger) using DevConsole
  • Format and mount the new disk

    sudo mkdir /mnt/tmp

    sudo mkfs.ext4 -F /dev/disk/by-id/google-temporary-disk

    sudo mount -o discard,defaults /dev/disk/by-id/google-temporary-disk /mnt/tmp

  • Create the image

    $ sudo dd if=/dev/disk/by-id/google-image-disk of=/mnt/tmp/disk.raw bs=4096

  • Then tar and gzip this file:

    sudo tar czvf myimage.tar.gz disk.raw

  • Finally, upload your image to a bucket:

    gsutil cp /mnt/tmp/myimage.tar.gz gs://BUCKET_NAME

Upvotes: 4

Related Questions