Home / OCI

OCIRunbookAdvanced

Upgrading an OCI Oracle Linux 7 instance to Oracle Linux 8 in place with Leapp: backup, preupgrade inhibitors and post-upgrade cleanup

Upgrade an OCI Oracle Linux 7 compute instance to Oracle Linux 8 with Leapp. Back up the boot volume, rehearse on a clone, clear inhibitors, run the upgrade from the serial console, then clean up.

Deepak Bhardwaj7 min read

Applies toOCI Compute, Oracle Linux 7.9 to Oracle Linux 8 (x86_64 and aarch64), leapp-upgrade, OCI CLI 3.x

Goal

You have Oracle Linux 7 instances on OCI that you can't rebuild yet. OL7 is in Extended Support, and you need it on OL8 without a new IP, new volumes or an application reinstall. Leapp upgrades the instance in place. Oracle ships an OCI preset, --oci, that enables the right OL8 repositories for cloud instances.

The upgrade is intrusive. It reboots several times, drops SSH, and can leave the instance unbootable if an inhibitor is ignored. Run it as a change with a tested rollback.

Caution

Take a boot volume backup and rehearse on a clone first. The rollback is "restore the boot volume". There is no leapp rollback.

1. Before the change window

Back up and clone the boot volume

INSTANCE=ocid1.instance.oc1..xxxx
AD=$(oci compute instance get --instance-id $INSTANCE --query 'data."availability-domain"' --raw-output)
COMP=$(oci compute instance get --instance-id $INSTANCE --query 'data."compartment-id"' --raw-output)

BV=$(oci compute boot-volume-attachment list --compartment-id $COMP \
  --availability-domain "$AD" --instance-id $INSTANCE \
  --query 'data[0]."boot-volume-id"' --raw-output)

oci bv boot-volume-backup create --boot-volume-id $BV --type FULL \
  --display-name "pre-leapp-$(hostname)-$(date +%F)" --wait-for-state AVAILABLE

Back up attached block volumes and any databases too. Then restore the backup to a new boot volume, launch a test instance from it in an isolated subnet, and do the whole runbook there first. A clean rehearsal on a real copy is the best predictor of the production run.

Check the blockers you can see without Leapp

Check Command Why it matters
Fully patched OL7 sudo yum update -y && sudo reboot Leapp expects the latest OL7 packages
Not running a debug kernel uname -r Debug kernels are not supported; remove kernel-debug* and kernel-uek-debug*
Secure Boot state sudo mokutil --sb-state Secure Boot must be off, and it can't be disabled on an OCI instance that has it on; such instances must be rebuilt
Version locks sudo yum versionlock list Clear them with sudo yum versionlock clear
Network filesystems findmnt -t nfs,nfs4 and iSCSI mounts in /etc/fstab Unmount them and comment them out in /etc/fstab for the upgrade
Docker rpm -q docker-engine docker Docker is removed in the upgrade; plan for Podman
OS Management Hub sudo systemctl status oracle-cloud-agent plus the console Attach the "Leapp Upgrade Utilities for Oracle Linux 7" and OL8 AppStream software sources, or unregister the instance

Confirm console access

The serial console is required. SSH drops during the upgrade and you can't log back in until it finishes. Create the console connection now and test that you can log in with a local password, not just a key.

2. Install Leapp and run the preupgrade

Make sure ol7_leapp and ol7_latest are enabled, then install:

sudo yum-config-manager --enable ol7_leapp ol7_latest
sudo yum install -y leapp-upgrade

If yum update left an oracle-linux-ol7.repo.rpmnew, merge it so the ol7_leapp repo definition is present.

Run the assessment. It changes nothing and can be repeated as often as you like:

sudo leapp preupgrade --oci

If the instance uses NetworkManager and you want to keep it that way after the upgrade, set LEAPP_OCI_NM=1 for both the preupgrade and upgrade runs:

sudo LEAPP_OCI_NM=1 leapp preupgrade --oci

--oci enables ol8_baseos_latest, ol8_appstream, ol8_UEKR6, ol8_addons, ol8_ksplice and ol8_oci_included. Add others with --enablerepo, for example --enablerepo ol8_mysql80 if you run MySQL from Oracle's repos.

Read the report

The preupgrade writes its output to /var/log/leapp/:

File Contents
leapp-report.txt Findings by risk. High-risk findings that block the upgrade are inhibitors
answerfile Questions that must be answered before the upgrade proceeds
leapp-upgrade.log Full process log
leapp-report.json The same report, for scripts
sudo grep -B2 -A12 'Risk Factor: high (inhibitor)' /var/log/leapp/leapp-report.txt
sudo cat /var/log/leapp/answerfile

Answer questions with leapp answer, or uncomment and set confirm = True in the answerfile. The section name comes from the answerfile itself:

sudo leapp answer --section remove_pam_pkcs11_module_check.confirm=True

Fix, then re-run leapp preupgrade --oci until there are no inhibitors.

Common inhibitors and fixes

Finding Fix
pam_pkcs11 or pam_krb5 in the PAM stack Disable them before the upgrade. If you leave them in, you can lock yourself out
winbind/wins in /etc/nsswitch.conf Remove them for the upgrade and restore them after
Network filesystem in /etc/fstab Unmount it and comment out the entry
Unsupported or removed drivers Check the report for the module name; drivers like e1000 inhibit the upgrade
Overlay too small (large package sets) Raise LEAPP_OVL_SIZE (default 4096 MB); keep it to 25% of the root filesystem or less
Leftover third-party repos Disable them; Leapp can't map them to OL8

3. Run the upgrade

In the change window, stop the application, then work from the serial console:

sudo leapp upgrade --oci
# or, keeping NetworkManager:
sudo LEAPP_OCI_NM=1 leapp upgrade --oci

Check the summary at the end. If it reports new inhibitors, fix them and run it again before you reboot. When it's clean:

sudo reboot

The instance boots into a temporary upgrade environment, upgrades the packages and reboots several more times. Don't interrupt it, and don't stop or reboot the instance from the console while it's running. Wait for the login prompt on the serial console. Rehearsal timings are your best estimate for the window. Durations vary a lot with package count and disk performance.

Warning

If the instance doesn't come back, don't keep power-cycling it. Capture the serial console history for the case, then roll back: stop the instance and use the boot volume replace action with the pre-upgrade backup, or restore the backup and launch a new instance from it.

4. Verify

cat /etc/oracle-release
uname -r                     # should contain el8 (UEK R6 or later)
sudo grubby --default-kernel
ip addr
curl -s -H "Authorization: Bearer Oracle" http://169.254.169.254/opc/v2/instance/ | head -5
sudo dnf repolist
sudo systemctl --failed

Check that the Oracle Cloud Agent plugins are running again:

oci instance-agent plugin list --compartment-id $COMP --instanceagent-id $INSTANCE \
  --query 'data[].{name:name,status:status}' --output table

5. Post-upgrade cleanup

The upgrade leaves several jobs for you:

# SELinux is left in permissive mode
sudo setenforce enforcing
sudo sed -i 's/^SELINUX=.*/SELINUX=enforcing/' /etc/selinux/config

# Host firewall
sudo systemctl enable --now firewalld

# Python default
sudo alternatives --set python /usr/bin/python3

# Leftover el7 and Leapp packages (they get no updates)
rpm -qa | grep el7 | grep -v kernel
rpm -qa | grep leapp
sudo dnf remove <packages from the lists above>
sudo rm -rf /root/tmp_leapp_py3
  • Remove the exclude= line for Leapp packages from /etc/dnf/dnf.conf, and move any proxy setting from /etc/yum.conf into /etc/dnf/dnf.conf.
  • On OCI, replace the dhclient hostname exit hook with the OL8 version from the Oracle Leapp docs (/etc/dhcp/exit-hooks.d/dhclient-exit-hook-set-hostname.sh).
  • Re-enable the NFS and iSCSI entries in /etc/fstab, then run sudo mount -a.
  • If ports stop answering, check for a leftover direct REJECT rule: sudo firewall-cmd --direct --get-all-passthroughs.
  • For OS Management Hub, attach the OL8 software sources so the OL7 and Leapp sources stop being used.
  • Re-apply your crypto policy and hardening baseline, then re-run your vulnerability scan.

Tip

OL8 to OL9 uses the same Leapp workflow with different repositories and prerequisites, including UEK R7. Follow the Oracle Linux 9 Leapp guide for that hop rather than reusing these repo names.

Prevent it next time

  • Track OS end-of-life dates in your CMDB and plan the upgrades a year ahead.
  • Keep production instances on stock repos and Oracle-provided kernels. Third-party repos and custom kernels are what usually block Leapp.
  • Script steps 1 and 5 and keep the preupgrade report with the change record.
  • For stateless tiers, build OL8 or OL9 images and roll the instance pool instead of upgrading in place.