For the creation of virtual machine (instance), boot disk image file would be required and that image should be in compressed raw format. We can upload that compressed boot disk raw file in google bucket and later we can use that file to create an image for an instance.
Step 1: Create a local virtual machine from an iso file, use any virtualization method line VirtualBox or VMware for the virtualization platform and login inside that VM through the command line terminal.
Step 2: Check the boot disk with “lsblk” command
[root@localhost ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 8G 0 disk
└─sda1 8:1 0 8G 0 part /
sr0 11:0 1 1024M 0 rom
Step 3: Create a machine raw file from a boot disk in this scenario “sda” is our boot disk
[root@localhost ~]# dd if=/dev/sda of=/mnt/disk.raw bs=4M conv=sparse
2048+0 records in
2048+0 records out
8589934592 bytes (8.6 GB) copied, 41.8353 s, 205 MB/s
Step 4: Now change the directory and create a compressed tar.gz file from the raw boot disk image.
[root@localhost ~]# cd /mnt/
[root@localhost mnt]# tar -cvzf custom-centos7-image.tar.gz disk.raw
Step 5: Create a bucket in Google project, we will use that bucket for saving compressed raw boot disk image. Here we have created the bucket with “custom-image-datastore” name.
Step 6: Configure your google account and save the raw file into the bucket either by “
[root@localhost ]# gsutil cp custom-centos7-image.tar.gz gs://custom-image-datastore
Copying file://custom-centos7-image.tar.gz [Content-Type=application/x-tar]...
\ [1 files][ 1.9 GiB/ 1.9 GiB] 111.6 KiB/s
Operation completed over 1 objects/1.9 GiB.
Step 7: After the successful upload u can create your image like below,
Reference Links:
https://cloud.google.com/compute/docs/images/import-existing-image
One thought on “Create Google Cloud Image from Iso File”
Unique and Nice article.