Oracle Linux 8 - Upgrading Systems With Leap
Oracle Linux 8 - Upgrading Systems With Leap
F36401-32
May 2024
Oracle Linux 8 Upgrading Systems With Leapp,
F36401-32
1 About Leapp
Supported Leapp Features 1-1
Upgrading Oracle Linux 7 Systems 1-1
Upgrading Oracle Linux 7 Oracle Cloud Infrastructure Instances 1-2
Upgrading Oracle Linux 7 Systems That Use RDMA 1-3
Upgrading Oracle Linux 7 KVM Hosts 1-3
Upgrading Oracle Linux 7 Systems with Oracle Databases 1-4
Requirements for Upgrading 1-4
Kernels Upgradeable With Leapp 1-5
iii
4 Completing Postupgrade Tasks
iv
Preface
Oracle Linux 8: Upgrading Systems With Leapp provides information about how to use the
Leapp utility to perform system upgrades from Oracle Linux 7 to the current Oracle Linux 8
release.
Documentation License
The content in this document is licensed under the Creative Commons Attribution–Share Alike
4.0 (CC-BY-SA) license. In accordance with CC-BY-SA, if you distribute this content or an
adaptation of it, you must provide attribution to Oracle and retain the original copyright notices.
Conventions
The following text conventions are used in this document:
Convention Meaning
boldface Boldface type indicates graphical user interface
elements associated with an action, or terms
defined in text or the glossary.
italic Italic type indicates book titles, emphasis, or
placeholder variables for which you supply
particular values.
monospace Monospace type indicates commands within a
paragraph, URLs, code in examples, text that
appears on the screen, or text that you enter.
Documentation Accessibility
For information about Oracle's commitment to accessibility, visit the Oracle Accessibility
Program website at [Link]
v
Preface
mindful of the necessity to maintain compatibility with our customers' existing technologies and
the need to ensure continuity of service as Oracle's offerings and industry standards evolve.
Because of these technical constraints, our effort to remove insensitive terms is ongoing and
will take time and external cooperation.
vi
1
About Leapp
The Leapp utility is a framework for updating and upgrading operating systems and
applications. The utility's component packages enable the creation of different workflows into
profiles for updating software.
Leapp operations consist of two phases:
• The preupgrade phase, where system checks are performed to verify if the software can
be upgraded.
• The actual upgrade, which process is based on configuration files that map packages
between previous and current versions of the software packages.
Caution:
Currently, the Leapp utility is used to upgrade the OSs only, namely, from the current
Oracle Linux 7 release to the current Oracle Linux 8 version. The procedures in this
document don't apply to and are unsupported on any other OSs or versions.
1-1
Chapter 1
Supported Leapp Features
1-2
Chapter 1
Supported Leapp Features
For details and instructions on obtaining newer versions of RDMA packages, see the latest
UEK release notes at Unbreakable Enterprise Kernel documentation.
Note:
The Oracle Linux KVM Image isn't an Oracle Cloud Infrastructureplatform image and
not supported by Leapp.
1-3
Chapter 1
Requirements for Upgrading
For repository mappings between preupgrade stage and postupgrade stage that involve KVM
clients, see Supported Repositories in Leapp Upgrades.
1-4
Chapter 1
Kernels Upgradeable With Leapp
1Unbreakable Enterprise Kernel Release 6 remains on the system or instance after the
upgrade. If preferred, the administrator can remove this kernel.
2RHCK in Oracle Linux 8 doesn't support the Btrfs file system.
3RHCK isn't distributed nor available for the aarch64 platform.
1-5
2
Preparing for the Upgrade
Complete the steps as applicable to prepare for an upgrade from Oracle Linux 7 to Oracle
Linux 8. Unless specified otherwise, all of the procedures for upgrading an Oracle Linux 7
system also apply upgrading an Oracle Linux 7 instance on Oracle Cloud Infrastructure.
1. Set up a means to connect remotely through a console.
This document assumes that you're performing a Leapp upgrade remotely. In this case, a
console is necessary so you can monitor the progress of the upgrade process, especially
as the upgrade performs automatic reboots.
The following list shows console connection options you can use:
• Oracle Cloud Infrastructure instance: Create a console connection by following the
instructions at [Link]
[Link]#Instance_Console_Connections.
• Oracle Linux server: Use Oracle Integrated Lights Out Manager (ILOM). See https://
[Link]/en/servers/management/ilom/[Link].
• Oracle Private Cloud Appliance: Use the Instance Console Connection. See https://
[Link]/en/engineered-systems/private-cloud-appliance/[Link].
• Oracle Linux Virtualization Manager or Oracle Linux Kernel based Virtual Machines
(KVM): User virt-viewer, virt-manager, or Cockpit Web Console. See Oracle Linux
Virtualization Manager documentation.
Note:
If you connect to the system by using SSH or by using VNC to a VNC service
running on the system, you're disconnected during the upgrade process and are
unable to log in until the upgrade is completed.
2. If you are upgrading an Oracle Linux instance on Oracle Cloud Infrastructure, verify if
Oracle OS Management Service is running on the instance. Do the following:
a. From Oracle Cloud Infrastructure, open the navigation menu and click Compute.
Under Compute, click Instances.
b. Select the instance you want to upgrade from Oracle Linux 7 to Oracle Linux 8.
c. From the Resources section, click OS Management.
• If the Oracle OS Management Service description specifies "No OS management
information is available for this resource," then the Oracle OS Management
Service agent is not running on the instance.
• If the description provides other information about the instance, then the Oracle
OS Management Service agent is running on the instance.
3. Do one of the following:
• If the instance is managed by Oracle OS Management Service:
a. From the Resources section, click OS Management.
2-1
Chapter 2
b. From the Overview tab, click the horizontal ellipsis (...) and select View OS
Management Details.
c. From the Resources area, select Software Sources.
d. Click Add and select the check box next to Leapp Upgrade Utilities for Oracle
Linux 7 Server.
e. Click Add.
• If the instance is not managed by Oracle OS Management Service, ensure that the
Oracle OS Management Service agent is disabled:
a. Select the Oracle Cloud Agent tab.
b. Disable the OS Management Service Agent process if it is enabled.
This process takes awhile to complete.
c. After waiting sufficiently, check for osms-agent processes and ensure that none
are running. Connect to the process with a terminal, and run the following
command:
Note:
An Oracle Linux system may run the Oracle OS Management Service agent, but
may not be managed by the Oracle OS Management Service. For more
information about Oracle OS Management Service, see [Link]
iaas/os-management/osms/[Link].
4. Perform a backup.
Always back up a system so that the system can be restored to its former state if the
upgrade fails. Oracle highly recommends making a full backup of your database, if your
instance of Oracle Linux includes a supported database version. For more information, see
Upgrading Oracle Linux 7 Systems with Oracle Databases.
Note:
For an Oracle Linux 7 instance in Oracle Cloud Infrastructure, perform a boot
volume backup. For instructions, see [Link]
Concepts/[Link].
5. Shut down all production workloads that have been set up to run on the system, as the
upgrade is intrusive and requires several reboots.
6. Disable Secure Boot if it's running.
To check the status of Secure Boot, choose from one of the following commands:
• Using bootctl status, for example:
sudo bootctl status
2-2
Chapter 2
...
Secure Boot: disabled
...
SecureBoot disabled
If Secure Boot is enabled, you would need to access the system's firmware at boot time to
disable the option.
Note:
It is not possible to disable Secure Boot if it is already enabled on an Oracle
Cloud Infrastructure instance.
7. If the system has network mounted file systems, unmount them and then insert related
entries in the /etc/fstab file inside comment marks.
See File Systems and Storage Issues.
8. If the system is behind a proxy, configure the proxy settings in /etc/[Link], for
example:
proxy=proxy-url:port
Note:
After the update is completed, the following message might be displayed:
warning: /etc/[Link].d/[Link]
created as /etc/[Link].d/[Link]
11. If you're upgrading Oracle Linux 7 KVM hosts, stop all the virtual machines that might be
running.
The command lists the virtual machines. From the list, stop specific virtual machines that
are running.
2-3
Chapter 2
b. From the list, stop individual virtual machines that are running.
sudo virsh shutdown vm-name
12. If the system is registered with ULN or a ULN mirror, unregister the system.
14. Install the Leapp utility while enabling certain repositories, using the following command:
sudo yum install -y leapp-upgrade --enablerepo=ol7_leapp,ol7_latest
2-4
3
Upgrading the System
This chapter discusses the different stages of a system upgrade, which are the assessment
phase and the upgrade phase. The main commands to use for these stages are leapp
preupgrade and leapp upgrade, and followed by command arguments. For a list of these
arguments, use the -help or --help argument, for example:
sudo leapp preupgrade --help
Unless specified otherwise, all the procedures for upgrading an Oracle Linux 7 system also
apply to upgrading an Oracle Linux 7 instance on Oracle Cloud Infrastructure.
Important:
Refer also to Known Issues to better prepare the system for a Leapp upgrade.
3-1
Chapter 3
Assessing the Capability of the System for Upgrading
For detailed information about the arguments, see Using Command Arguments to Enable
Repositories.
This process generates a process log, a report, and a file called answerfile.
As the example shows, for some risks, the report would suggest actions you should perform
after the upgrade. Therefore, the risk, although high, is not labeled as an inhibitor. The remedy
can be performed later.
If the command output lists only the Oracle Linux 7 public key gpg-pubkey-
ec551f03-53619141, the issue can be safely ignored. Otherwise, any other unsigned packages
or gpg-pubkey entries in the report must be manually analyzed, as they might be removed
during the upgrade.
3-2
Chapter 3
Assessing the Capability of the System for Upgrading
Note:
All verification checks listed in the answerfile must be answered. Unanswered items
cause the upgrade process to halt.
Based on the example, each verification check is identified with a section heading in square
brackets, such as remove_pam_pkcs11_module_check. The heading is followed by descriptions
of the issue and the valid responses to address the issue.
To provide responses to answerfile, choose from one of the following methods:
3-3
Chapter 3
Performing the Upgrade
Note:
Systems that use the Btrfs file system must also confirm in /var/log/leapp/
answerfile the switch to using UEK. As noted in Kernels Upgradeable With Leapp,
using the Btrfs file system in Oracle Linux 8 requires the UEK kernel. To confirm the
kernel upgrade, issue this command to update answerfile:
sudo leapp answer --section
confirm_UEK_install_and_default_boot_kernel.confirm=True
If the command doesn't work at first use, you might need to specify the -i path-to-
key option, for example:
ssh -i path-to-key -o ProxyCommand='ssh -i path-to-key additional-commands
For detailed information about the command arguments, see Using Command Arguments
to Enable Repositories.
3-4
Chapter 3
Verifying the Upgrade
At the completion of the boot process, the utility automatically proceeds with upgrading
packages. This operation takes awhile to complete and also includes multiple automatic
reboots.
Caution:
Do not interrupt the ongoing processes at this stage. Wait until the login screen
appears, which indicates that the entire upgrade process has completed. Only
then can you begin to use the system.
5. When the login screen appears on the console, log in with the proper credentials.
After the completion of an instance upgrade, the instance retains its Oracle Linux 7 base image
on the Instance Details page of the Oracle Cloud Infrastructure console, for example, Oracle-
Linux-7.9-2020-11.10-1. You can apply a custom tag so you can track the upgrades that
have been performed on the instance after its creation.
Important:
See Oracle Linux 8 documentation for information about new features, changes, and
deprecated items in Oracle Linux 8. Thus, you can identify post upgrade tasks that
you might need to complete. For example, after the upgrade, network configurations
and settings from Oracle Linux 7 continue to operate based on legacy network
scripts. However, network scripts are deprecated in Oracle Linux 8. Therefore,
consider reconfiguring the upgraded system's network settings to be managed by
NetworkManager. For more information, see Oracle Linux 8: Setting Up Networking.
To check the system's kernel version, type this command to verify that the kernel contains
the el8 substring:
uname -r
You can also identify the system's default kernel with the following command:
sudo grubby --default-kernel
3-5
4
Completing Postupgrade Tasks
Important:
The following tasks aren't comprehensive. Depending on the setup, you might need
to perform other procedures to return the newly upgraded system back into
operation. Review the /var/log/leapp/[Link] that's generated after the
upgrade. This report might contain more recommendations to ensure that the
upgraded system remains in a supported state.
3. Check that the network connections are operational, for example, by logging in to the
system by using SSH.
4. If you have an instance managed by Oracle OS Management Service, do the following:
a. From Oracle Cloud Infrastructure, open the navigation menu and click Compute.
Under Compute, click Instances.
b. Select the instance you upgraded from Oracle Linux 7 to Oracle Linux 8.
c. From the Resources section, click OS Management.
d. From the Overview tab, click the horizontal ellipsis (...) and select View OS
Management Details.
e. From the Resources area, select Software Sources.
f. Remove all Oracle Linux 7 sources. Select Select All then click Remove.
g. Add the Oracle Linux 8 Base OS Latest software source. This becomes the software
source for the upgraded managed instance.
h. Add any other required software sources.
4-1
Chapter 4
Note:
The Oracle OS Management Service can take some time to become aware of
the changes to the managed instance Oracle Linux version. For example, in
some cases this may take between 10 to 20 minutes. Additionally, the following
error messages may appear in the /var/log/oracle-cloud-agent/plugins/
osms/[Link] after upgrading an instance being managed by the Oracle OS
Management Service.
These error messages are resolved after running the sudo alternatives --set
python /usr/bin/python3 command in step 1.
5. If you had yum customizations before the upgrade, restore them in the upgraded
system's /etc/dnf/[Link] file, for example:
proxy=proxy-url:port
6. On upgraded Oracle Linux 7 instances on Oracle Cloud Infrastructure, update the script to
avoid losing SSH connectivity.
a. Use a text editor to open a new /etc/dhcp/exit-hooks.d/dhclient-exit-hook-set-
[Link]-ol8 file.
b. Add to this script the contents as provided in Updated dhclient Script.
c. Replace the current dhclient-exit-hook script with the updated file that you just
created. Type:
sudo cp /etc/dhcp/exit-hooks.d/[Link]-ol8 /etc/dhcp/
exit-hooks.d/[Link]
7. Restore network mounted file systems that you unmounted prior to the upgrade. See File
Systems and Storage Issues.
8. Confirm the Python installation.
Significant differences exist in how Python is used in Oracle Linux 8. Notably, you need to
explicitly select the Python version that you're using. Further, if you have installed third-
party libraries by using pip, you might need to manually clean and reinstall these libraries
as required. For more information, see Oracle Linux 8: Installing and Managing Python.
9. If upgrading KVM hosts, restart the KVM virtual machines.
sudo virsh start vm-name
During the upgrade, the Leapp utility sets SELinux to run in Permissive mode. To restore
the setting: To revert to Enforcing mode and verify the setting, type:
sudo setenforce enforcing
4-2
Chapter 4
Enforcing
To make this setting persist across system reboots, add the following line to /etc/
selinux/config:
SELINUX=enforcing
11. Reevaluate then reapply the security policies such as setting cryptographic policies.
If you disabled Secure Boot during the preparation steps, reenable it in the system's
firmware that you access at boot time.
12. Inspect the system for unneeded configurations and files.
Note:
Some of these unneeded files might be reported in the generated /var/log/
leapp/[Link] after the upgrade. Ensure that you review this report
and complete its post upgrade recommendations.
This step aims to ensure that the configurations are consistent with the new OS version.
The completion of this step would vary, depending on what you deem is important to retain
from the previous system's state. Consider the following guidelines:
• Remove kernels and kernel modules that are no longer applicable. For example, if the
system uses the Btrfs file system, then you can only use the UEK kernel. Therefore,
consider removing the RHCK kernel and any earlier versions of the UEK kernel. Also,
you can also rebuild the rescue kernel.
• If you remove kernels, you might also need to update the GRUB menu so that the
menu options only reflect the actual kernels on the system.
• Review /etc/[Link].d for entries that might need to be addressed, such as
customized repositories.
For example, during system updates, *.rpmnew files might be created to prevent
overwriting corresponding existing *.rpm files. You would need to use the contents of
the *.rpmnew files to guide you when modifying the corresponding *.rpm files.
• Remove residual packages from the previous Oracle Linux version.
a. Edit /etc/dnf/[Link] by removing or commenting out exclude= lines that refer
to leapp packages, for example:
#exclude=python2-leapp,snactor,leapp-upgrade-el7toel8,leapp
b. Use commands such as rpm -qa to list packages that can be removed.
rpm -qa | grep el7
rpm -qa | grep leapp
c. Use the sudo dnf remove command to remove the packages listed by the queries.
Caution:
Residual el7 packages that remain on the system do not receive updates.
Vulnerability scanners or other security audits might report warnings or failures
about these packages.
4-3
Chapter 4
14. If you removed the system from ULN to perform the upgrade, register the system again
and configure the appropriate channels.
For more information, see Registering an Oracle Linux System With ULN and ULN
Channel Subscription Management in Oracle Linux: Managing Software on Oracle Linux.
4-4
5
Troubleshooting Oracle Linux Upgrades
This chapter provides troubleshooting information and describes known issues that might affect
the upgrade process.
Known Issues
The following are known issues that you might encounter when upgrading an Oracle Linux 7
system to Oracle Linux 8.
Upgrade Issues
• Optional Resilient Storage group isn't supported with Leapp
Leapp doesn't support the optional Resilient Storage group. The presence in the system of
certain packages from that group might prevent a leapp upgrade to complete.
For example, the Resilient Storage group includes the lvm2-cluster package. In an
Oracle Linux 7 installation, this package can be optionally added as part of either the
Infrastructure Server and File profile or the Print Server profile. However, the package is an
inhibitor and would cause the Leapp upgrade to fail.
BugID 33573562
• Leapp might report missing packages that are marked for installation
The /var/log/[Link] or /var/log/[Link] files might report
a warning similar to the following:
Warning: Packages marked by Leapp for install not found in repositories
metadata: rpcgen python3-pyxattr libnsl2-devel rpcsvc-proto-devel
5-1
Chapter 5
Known Issues
These packages are in the Oracle Linux8 Codeready Builder repository, which is a
developer repository and is disabled by default.
If the system requires these packages, then during the preupgrade or the upgrade phase,
add the --enablerepo ol8_codeready_builder option to the appropriate Leapp
command, for example:
sudo leapp upgrade --oraclelinux --enablerepo ol8_codeready_builder
Repositories that have been enabled during the Leapp upgrade remain enabled on the
Oracle Linux 8 system after the upgrade completes.
Alternatively, after completing the upgrade, you can manually install the packages required
for your installation by using the dnf command.
Bug ID 32827043
• MySQL-related *.el7 packages might remain after an upgrade
In an Oracle Cloud Infrastructure instance, existing MySQL packages might remain after
the upgrade is completed. You can verify their existence with the following command:
rpm -qa | grep el7 | grep -v leapp | grep -v kernel
mysql-community-client-plugins-8.0.25-1.el7.x86_64
To ensure that these packages are correctly updated, enable the ol8_MySQL80 repository
also when you run the upgrade.
sudo leapp upgrade --oci --enablerepo ol8_mysql80
The VMD module doesn't apply to the Arm architecture and therefore, the error message
can be safely ignored.
Bug ID 34172552
5-2
Chapter 5
Known Issues
TCP Wrappers aren't available in Oracle Linux 8. If you're using TCP Wrappers to control
network traffic in the Oracle Linux 7 system through /etc/[Link] and /etc/
[Link] files, then after the upgrade you must create applicable firewall rules to
implement the same control in Oracle Linux 8.
For more information about implementing firewall rules, see Oracle Linux 8: Configuring
the Firewall.
• Oracle Linux 7 authentication configuration not converted after upgrade
Leapp does not convert Oracle Linux 7 authentication configuration that uses the
deprecated authconfig utility to the corresponding Oracle Linux 8 authentication that
uses the authselect command. After the upgrade, you need to reconfigure
authentication appropriately in Oracle Linux 8.
For more information about using the authselect utility, see Oracle Linux 8: Setting Up
System Users and Authentication.
• Upgrade blocked if system has configured pam_krb5 and pam_pkcs11 PAM modules
The deprecated pam_krb5 and pam_pkcs11 PAM modules in Oracle Linux 7 are removed
during the upgrade process. Before performing the upgrade, you must first reconfigure the
system's PAM configuration to disable these modules. Otherwise, the system becomes
locked.
For instructions to disable these modules, see Oracle Linux 7: Setting Up System
Accounts and Authentication. See also the discussion about these modules in Providing
Information to the Leapp Answerfile.
The report is a known but harmless issue, which you can ignore. After the upgrade is
completed, Ksplice continues to operate normally.
5-3
Chapter 5
Known Issues
Networking Issues
• Possible upgrade error if system has several NICs with the same prefix as NIC that's
used by kernel
The in-place upgrade process might cause an error if the system to be upgraded has more
than one NIC that shares the same prefix as the NIC that's used by the kernel, for example
eth. After the upgrade, the system's network connectivity is lost.
For more information, see About Network Interface Names in Oracle Linux 8: Setting Up
Networking.
• NetworkManager might not start after the upgrade completes
After the upgrade, the system's NetworkManager might not start because of the failure of its
name resolution service. The failure can be verified by checking the status of the service.
systemctl status [Link]
5-4
Chapter 5
Known Issues
Created symlink
/etc/systemd/system/[Link]/[Link] →
/usr/lib/systemd/system/[Link].
You can also adopt other methods that are more consistent with the network name
resolution model that you're using for the specific setup. For useful information, see About
Network Interface Names in Oracle Linux 8: Setting Up Networking.
Furthermore, listing available snapshots from prior to the upgrade generates an empty list.
sudo virsh snapshot-list previous-snapshot-file
As a workaround, reboot the system. At the end of the boot process, the snapshots are
listed and available again.
• libvirtd service might fail to restart in nested virtualization configurations
In nested virtualization setups, the libvrtd service might not restart in the nested KVM
host after the upgrade.
As a workaround, reboot the nested KVM host.
• Some KVM virtual machines might not start after the upgrade
If the KVM host is running the RHCK kernel, virtual machines or guests that existed before
the upgrade might not start after the Leapp upgrade completes. When start these guests,
an error message similar to the following might be displayed:
sudo virsh start domain-name
This error is reported because the RHCK kernel disables Intel Transactional
Synchronization Extensions (TSX) by default and can't provide the Hardware Lock Elision
(HLE) and Restricted Transactional Memory (RTM) features that the guest is expecting.
As a workaround, perform the following steps:
1. Edit /etc/default/grub by adding tsx=on to the GRUB_CMDLINE_LINUX directive,
as shown in the following example in bold:
5-5
Chapter 5
Known Issues
...
GRUB_CMDLINE_LINUX="LANG=en_US.UTF-8 … tsx=on"
As a workaround, increase the LEAPP_OVL_SIZE variable. The default size is 4096. The
actual size you would need might be larger depending on the specific setup. Use the
following command:
sudo export LEAPP_OVL_SIZE=new-size
5-6
A
Supported Repositories in Leapp Upgrades
This appendix shows repositories that are used in a system or instance upgrade that uses the
Leapp utility.
Repository Mappings
The following table shows repository correspondences between Oracle Linux 7 and Oracle
Linux 8. The table helps you to identify the corresponding repositories that the Leapp utility
makes available after the host has completed upgrading to Oracle Linux 8.
This table shows the repository mappings for the Oracle Linux KVM Stack.
A-1
Appendix A
Using Command Arguments to Enable Repositories
Oracle has provided the following convenience switches or arguments that can be used with
the Leapp preupgrade or upgrade commands. When used, these arguments automatically
apply the --enablerepo subcommand to repositories that are appropriate to the host that
you're upgrading.
--oraclelinux
This argument is used on system upgrades that you perform either locally or remotely. The
argument detects the system's architecture and automatically uses the repositories that are
applicable to the architecture.
When you use this argument, the following repositories are automatically enabled:
• ol8_baseos_latest
• ol8_appstream
• ol8_UEKR6 1
--oci
This argument is used on Oracle Cloud Infrastructure instance upgrades. The repositories
covered by this argument are a superset of the --oraclelinux argument.
When you use this argument, the following repositories are automatically enabled:
• ol8_baseos_latest
• ol8_appstream
• ol8_UEKR6 1
• ol8_addons
• ol8_ksplice
• ol8_oci_included
1 For aarch64 platforms, the ol8_UEKR6 repository does not exist. Instead, UEK R6 is part of
the ol8_baseos repository.
Caution:
The --oraclelinux and --oci arguments for enabling default repositories are
mutually exclusive.
For example, the preupgrade --oraclelinux command would be equivalent to
the following syntax:
sudo leapp preupgrade --enablerepo 'ol8_baseos_latest' --enablerepo
'ol8_appstream' --enablerepo 'ol8_UEKR6'
Use the --enablerepo option to enable more required repositories that aren't in the default
list of repositories that are enabled by the argument that you're using. You must use the option
for every additional repository you want to enable, for example:
sudo leapp preupgrade --oraclelinux --enablerepo 'ol8_addons' --enablerepo
'ol8_codeready_builder' ...
A-2
B
Updated dhclient Script
The [Link]-ol8 is intended for use on Oracle Linux instances
on Oracle Cloud Infrastructure that have been upgraded from Oracle Linux 7 to Oracle Linux 8.
This script includes code for the proper handling of connectivity to those upgraded instances.
#!/bin/bash
#
# Copyright (C) 2022 Oracle. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation, version 2. This program is distributed in the hope that it will
# be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details. You should have received a copy of the GNU
# General Public License along with this program; if not, write to the Free
# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 021110-1307, USA.
log () {
logger -t "${0##*/}" "$*"
}
OPC_CONF="/etc/[Link]"
function retry_command()
{
retry_attempts=30
retry_interval_sec=2
while [ "$retry_attempts" -gt 0 ]; do
command_success=true
"$@" || { command_success=false; }
if [ "$command_success" == false ]; then
(( retry_attempts-- ))
log "Error occurred running command $@. Will retry in $retry_interval_sec seconds"
sleep $retry_interval_sec
else
B-1
Appendix B
#Usage: add_entries <file name> <keyword> <an array of the corresponding values for the
keyword>
#We pass array by name so if the array name is 'arr', pass it as 'arr' instead of $arr
#This function can be used to add entries to files with a mapping format.
#For example, /etc/hosts has <ip> mapped to <fqdn/host alias>
#The function checks to see if a line containing the given 'keyword' is in the file
#If so, we check the given array of values against the existing values for the keyword
in that line.
#Append the values specified in the array to the line if it doesn't already exist.
#If the file does not contain a line with the given keyword,
#the function will add a new line with the given keyword mapped to all values in the
given array.
function add_entries()
{
local file=${1}
local keyword=${2}
local values=$3[@]
values=("${!values}")
if ! grep -qw "^$keyword" $file; then
log "Line with '$keyword' not found in $file"
new_entry="$keyword"
for value in "${values[@]}"
do
new_entry="$new_entry $value"
done
log "Adding '$new_entry' to $file"
echo "$new_entry" >> $file
else
log "Found line with '$keyword'"
target_line=$(grep -w "^$keyword" $file)
for value in "${values[@]}"
do
#First case needs spaces around $value to make sure it's not the prefix or
suffix of another value
#Second case checks if $value is at the end of the line
if [[ $target_line == *" $value "* ]] || [[ $target_line == *" $value" ]];
then
log "'$value' already exists in line"
else
log "Adding '$value' to line"
sed -i "s/^\<$keyword\>.*$/& $value/g" $file
fi
done
fi
}
B-2
Appendix B
fi
}
# Retry params
fqdn_success=1
retries=12
B-3
Appendix B
old_host_values=("$old_fqdn" "$old_host_name")
else
# get subnet_domain_name
subnet_domain_name=${fqdn#$new_host_name.}
B-4
Appendix B
new_host_values=("$fqdn" "$new_host_name")
# Pass array by name
add_entries "/etc/hosts" "$new_ip_address" new_host_values
# 3. Update /etc/[Link]
# This is a temp fix till we have a resolution for a proper dhcp response
new_search_domains=("$subnet_domain_name" "$vcn_domain_name")
add_entries "/etc/[Link]" "search" new_search_domains
echo -e "[main]\ndns = none\n" > /run/NetworkManager/conf.d/10-oci-
[Link]
fi
fi
}
# Retry params.
retries=12
fqdn_success=1
use_ipcalc_hostname=0
if [ "$host_name" = "$ipcalc_name" ]; then
# either one will do
B-5
Appendix B
fqdn=$ipcalc_name
else
# Likely that ipcalc has a user changed hostname.
# This will not match the new_host_name one.
# Use the one from host. But before that confirm
# that host has returned a valid name.
if [[ "$host_name" != *.*.*.*.* ]]; then
log "Invalid hostname $host_name from host command"
fqdn=$ipcalc_name
# get subnet_domain_name
if [[ "$use_ipcalc_hostname" -eq 1 ]]; then
subnet_domain_name=${fqdn#$ipcalc_host_name.}
else
subnet_domain_name=${fqdn#$new_host_name.}
fi
# Update /etc/[Link]
new_search_domains=("$subnet_domain_name" "$vcn_domain_name")
add_entries "/etc/[Link]" "search" new_search_domains
echo -e "[main]\ndns = none\n" > /run/NetworkManager/conf.d/10-oci-
[Link]
fi
fi
}
# This function adds NM_CONTROLLED=no entry to the primary interface config file
# So that network manger does not take cotrol when installed.
# Arguments:
# Arg1 -- primary_ip
function disable_NMcontrol()
{
local primary_ip=${1}
B-6
Appendix B
os_version=0
if [ -f /etc/os-release ]; then
os_string=$(grep -w VERSION /etc/os-release | awk -F "\"" '{print $2}')
log "INFO: Obtained $os_string from /etc/os-release"
if [[ "$os_string" == "8."* || "$os_string" == "8"* ]]; then
os_version=8
elif [[ "$os_string" == "7."* || "$os_string" == "7"* ]]; then
os_version=7
elif [[ "$os_string" == "6."* ]]; then
os_version=6
fi
fi
if [ $os_version == 0 ]; then
log "INFO: Getting OS version via uname -mrs"
kernel_version=$(uname -mrs)
if [[ "$kernel_version" == *"el8"* ]]; then
os_version=8
elif [[ "$kernel_version" == *"el7"* ]]; then
os_version=7
elif [[ "$kernel_version" == *"el6"* ]]; then
os_version=6
fi
fi
if [ $os_version == 0 ]; then
log "ERROR: Could not obtain valid OS version. Exiting.."
exit 1
fi
# For non-OL8 OSs get the primary vnic ip only if interface has been
# initialized.
B-7
Appendix B
# Ref: [Link]
if [ "$os_version" == 8 -o "$reason" != "PREINIT" ]; then
primary_ip=$(retry_command curl -H "Authorization: Bearer Oracle" http://
[Link]/opc/v2/vnics/ -sf | jq -r '.[0] | .privateIp')
log "$(date): Primary IP obtained: $primary_ip"
fi
# reason why this hook was invoked. It is set by dhclient script when
# the OS is non-ol8
log "reason=$reason"
# [Link]
if [ "$reason" = "BOUND" ] || [ "$reason" = "RENEW" ] || [ "$reason" =
"REBIND" ] || [ "$reason" = "REBOOT" ]; then
log "os version = $os_version"
#These variables are set by dhclient script
log "new_ip_address=$new_ip_address"
log "new_host_name=$new_host_name"
log "new_domain_name=$new_domain_name"
else
log "Not updating because reason=$reason"
fi
fi
# Will get retrieved for ol8 since we do not have DHCP provided vars.
if [ -z $new_ip_address ]; then
new_ip_address=$(retry_command curl -H "Authorization: Bearer Oracle" http://
[Link]/opc/v2/vnics/ -sf | jq -r '.[0] | .privateIp')
fi
if [ -z $new_host_name ]; then
echo "ERROR: new_host_name is empty after retrieving it from metadata json.
Exiting."
exit_status=1
B-8
Appendix B
else
log "new_ip_address=$primary_ip"
if [[ $PRESERVE_HOSTINFO -eq 0 ]]; then
# update the hostname with new hostname
update_hostname $os_version $new_host_name
# update hosts and resolv conf files
update_hosts_resolv $new_ip_address $new_host_name
elif [[ $PRESERVE_HOSTINFO -eq 1 ]]; then
log "Skip updating hostname as per"
log "PRESERVE_HOSTINFO=${PRESERVE_HOSTINFO} setting"
# update hosts and resolv conf files
update_hosts_resolv $new_ip_address $new_host_name
elif [[ $PRESERVE_HOSTINFO -eq 3 ]]; then
log "Skip updating hostname and /etc/hosts as per"
log "PRESERVE_HOSTINFO=${PRESERVE_HOSTINFO} setting"
log "Updating subnet in /etc/resolv"
# update resolv conf file alone
update_resolv $new_ip_address $new_host_name
fi
fi
fi
log "sethostname, /etc/hosts, /etc/[Link] END"
B-9