How to install Oracle Linux 8 on GCE using startup scripts

I like to combine existing features to ease my life. There are no public OL images in Google Cloud.
But there are Rocky Linux images which are free, open, community enterprise operating system designed to be 100% bug-for-bug compatible with Red Hat Enterprise Linux .
And my colleague Andy Colvin from Google mentioned about the document to Switch From CentOS to Oracle Linux.
So why not combine them together to get an OL instance on GCE with a simple startup script

  gcloud compute instances create new-ol8 --machine-type=e2-medium \
 --image-project=rocky-linux-cloud --image-family=rocky-linux-8-optimized-gcp \
 --metadata=startup-script='#!/bin/bash
 if [[ $(grep NAME /etc/os-release) = *Rocky* ]]; then   
    curl -O https://raw.githubusercontent.com/oracle/centos2ol/main/centos2ol.sh   
    bash centos2ol.sh &> /var/log/centos2ol.log   
    reboot 
 fi' 

In order to check the result:
SSH to the new-ol8 machine and run this command to check the progress:

 tail -f /var/log/centos2ol.log 

This process will take up to 30 minutes and will finish with a reboot.

 cat /etc/os-release 
 
NAME="Oracle Linux Server"
VERSION="8.7"
ID="ol"
ID_LIKE="fedora"
VARIANT="Server"
VARIANT_ID="server"
VERSION_ID="8.7"
PLATFORM_ID="platform:el8"
PRETTY_NAME="Oracle Linux Server 8.7"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:oracle:linux:8:7:server"
HOME_URL="https://linux.oracle.com/"
BUG_REPORT_URL="https://bugzilla.oracle.com/"
ORACLE_BUGZILLA_PRODUCT="Oracle Linux 8"
ORACLE_BUGZILLA_PRODUCT_VERSION=8.7
ORACLE_SUPPORT_PRODUCT="Oracle Linux"
ORACLE_SUPPORT_PRODUCT_VERSION=8.7

As a next step you may create a custom image from this machine in order to use in the future.

Leave a Comment