Offline Upgrade From RHEL8 to RHEL9 using an ISO
Upgrading from Red Hat Enterprise Linux (RHEL) 8 to RHEL 9 in an offline environment requires two main stages: first, upgrading to the latest RHEL 8 version (8.10), followed by upgrading from RHEL 8 to RHEL 9. This guide will walk you through the necessary steps for each part of the process, addressing potential issues along the way, and is specifically designed for an offline upgrade using local ISO images.
The ISO images required for this upgrade are:
- RHEL 8.10:
rhel-8.10-x86_64-dvd.iso
- RHEL 9:
rhel-9.5-x86_64-dvd.iso
Part 1: Upgrading to RHEL 8.10
1. Mount the RHEL 8.10 ISO
Start by creating a directory to mount the RHEL 8.10 ISO:
mkdir /mnt/rhel8
mount -o loop /path/to/rhel-8.10-x86_64-dvd.iso /mnt/rhel8
2. Get the MediaID from the ISO
You can get the mediaid
required in the next step from the ISO by checking the .discinfo
file:
head -n1 /mnt/rhel8/.discinfo
3. Configure Repositories
Add the appropriate repository entries for both BaseOS
and AppStream
repositories to /etc/yum.repos..d/rhel8.repo:
[rhel8-BaseOS]
mediaid=1354216429.587870
name=RHEL8-BaseOS
baseurl=file:///mnt/rhel8/BaseOS
gpgkey=file:///mnt/rhel8/RPM-GPG-KEY-redhat-release
enabled=1
gpgcheck=1
[rhel8-AppStream]
mediaid=1354216430.587871
name=RHEL8-AppStream
baseurl=file:///mnt/rhel8/AppStream
gpgkey=file:///mnt/rhel8/RPM-GPG-KEY-redhat-release
enabled=1
gpgcheck=1
Ensure both repositories are enabled (enabled=1) and security checks are active (gpgcheck=1).
4. Update the System
Now, perform a system update using yum:
yum update
This will install the latest updates from the RHEL 8.10 ISO.
5. Unmount the ISO
After completing the update, unmount the ISO and remove the mount directory:
umount /mnt/rhel8
Your system is now updated to the latest RHEL 8 version (8.10) and ready for the next phase.
Don’t forget to reboot in order to boot on the latest version of the kernel available.
Part 2: Upgrading from RHEL 8 to RHEL 9
Now that your system is up-to-date with RHEL 8.10 and that you have rebooted, you can proceed with the upgrade to RHEL 9. This process uses the leapp
tool, which allows for an in-place upgrade.
1. Prepare for the Upgrade
Before you begin, make sure you have the leapp
utility installed, unmount all mounted filesystems and disable all repositories by commenting them out in the repository configuration files. This prevents any conflicting repositories from being used during the upgrade.
2. Run the Pre-Upgrade Check
Next, run the leapp pre-upgrade
check to ensure that there are no compatibility issues before proceeding with the upgrade:
leapp preupgrade --no-rhsm --iso /path/to/rhel-9.5-x86_64-dvd.iso
This command will check for potential issues and report if there are any blockers to the upgrade.
3. Proceed with the Upgrade
If the pre-upgrade check completes successfully, unmount again all mounted filesystems and proceed with the upgrade:
leapp upgrade --no-rhsm --iso /path/to/rhel-9.5-x86_64-dvd.iso
This command will initiate the upgrade, and your system will be upgraded from RHEL 8 to RHEL 9.
Troubleshooting Common Issues
Issue: sqlite3.OperationalError: unable to open database file
If you encounter like me the following error during the leapp preupgrade step:
Traceback (most recent call last):
File "/usr/bin/leapp", line 9, in <module>
load_entry_point('leapp==0.12.1', 'console_scripts', 'leapp')()
File "/usr/lib/python2.7/site-packages/leapp/cli/__init__.py", line 18, in main
cli.command.execute('leapp version {}'.format(VERSION))
...
sqlite3.OperationalError: unable to open database file
This error typically indicates an issue with the /var
directory. Here are some solutions to resolve it:
1. Check the existence of /var/lib/leapp:
Verify that the /var/lib/leapp
directory exists. If it doesn’t, reinstall the leapp
package:
yum -y reinstall leapp
2. Remount /var in read-write mode:
If the /var
filesystem is mounted in read-only mode, remount it in read-write mode:
mount -o remount,rw /var
3. Free Up Space on /var:
If the /var
filesystem is full, check disk space usage:
df -h | grep /var
If /var
is 100% full, delete unnecessary files or extend the logical volume to free up space.
4. Increase File Descriptor Limits:
If leapp
fails due to hitting the per-process file descriptor limit, increase the file descriptor limit temporarily:
ulimit -n 16384
Verify that the new limit has been applied:
ulimit -n
You can read more about increasing file descriptor limits in Red Hat’s documentation. Note that the file descriptor limit must be increased in every new Bash session before using the leapp utility, as the change is not persistent across logins.
5. Check for Too Many Logical Volumes (LVs):
If you have many LVs, leapp may hit system limits. You can use strace to diagnose this issue:
strace -fttTvyyo /tmp/leapp.strace -s 128 <leapp-command>
Then, search the log for EMFILE errors:
grep "1 EMFILE" /tmp/leapp.strace
If too many LVs are causing issues, consider reducing the number of LVs or raising the system’s file descriptor limit.
Conclusion
Upgrading from RHEL 8 to RHEL 9 in an offline environment can be tricky, especially if you’ve never done it before, like me. However, keeping your system up to date is important for maintaining functionality, even without internet access.
The steps provided should help you carry out the upgrade smoothly, and the troubleshooting tips address common issues you might encounter. In my case, the leapp utility had problems related to mounted filesystems, so I had to ensure nothing was mounted before starting. I also had to raise the file descriptor limit, which only applies to the current Bash session—so remember to reapply it after logging out or starting a new shell.