I have a machinr image with all disks attached. I want to export this machine image to a tar file in cloud storage bucket and then a create a image out of it.
I dont see an option to export from machine images, can some one please help me with the steps
Hi @priyag,
Welcome to Google Cloud Community!
If the gcloud compute images create
and gcloud compute images export
commands do not meet your requirements, you can manually create and export an image from a Compute Engine instance.
This method involves separate steps to first create a snapshot of the disk and then export it. You can follow the instructions in the "Create and export an image manually", this process shows how to create a tar file of your image and upload it to the Cloud Storage bucket.
You must first customize the files on the image disk (Steps 1-8) before creating an image from the tar file in Cloud Storage (Step 9). Start by creating a raw disk file on a temporary disk. The raw disk image should be named disk.raw:
sudo dd if=/dev/disk/by-id/google-image-disk of=/mnt/tmp/disk.raw bs=4096
Then create the tar.gz file:
cd /mnt/tmp
sudo tar czvf myimage.tar.gz disk.raw
This command creates an image of the instance in the following location:
/mnt/tmp/myimage.tar.gz
After creating a tar file for your image, upload the image into Cloud Storage to export the tar file to Cloud Storage bucket(step 10).
Once you've exported your file to Cloud Storage, you can share the image with others or use the tar file to add a new image to a Google Cloud project.
Was this helpful? If so, please accept this answer as “Solution”. If you need additional assistance, reply here within 2 business days and I’ll be happy to help.