-
Install Oracle Linux in VirtualBox
-
Before shutdown, be aware to do these things
- Edit /etc/default/grub
- Remove splash & quiet & rhgb
- Add console=ttyS0,38400n8d
- Update grub
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
- Add network script for eth0, in
/etc/sysconfig/network-scripts/
- You can copy from
/etc/sysconfig/network-scripts/ifcfg-eXX
- Be aware that DHCP and ONBOOT should be set to YES
- You can copy from
- Edit /etc/default/grub
-
Export disk
- Be aware that file name SHOULD BE disk.raw
- Clone boot disk to RAW format
VBoxManage clonemedium guest-image ~/disk.raw --format RAW
- Compress the RAW disk into tar.gz
sudo tar --format=oldgnu -Sczf /tmp/compressed-image.tar.gz disk.raw
- Noted that in macOS, you should use gnu-tar
brew install gnu-tar
sudo gtar --format=oldgnu -Sczf /tmp/compressed-image.tar.gz disk.raw
-
Upload compressed-image.tar.gz to GCS bucket
-
Create a GCE image from compressed-image.tar.gz in GCS bucket
gcloud compute images create image-name --source-uri gs://bucket-name/compressed-image.tar.gz
-
Provision a GCE VM instance to test.
- In boot disk, select Custom Image => select the image which is generated before.
-
You can go through serial console to see if boot is successful or not.
-
Refs: https://cloud.google.com/compute/docs/import/import-existing-image