This document outlines the step-by-step process of upgrading a RHEL 8 system to RHEL 9, including package removal, kernel configuration, and bootloader management.
Step 1: Identifying Installed RHEL 8 Packages
Before upgrading, identify and list all installed packages specific to RHEL 8.
rpm -qa | grep -e '\.el[78]' | grep -vE '^(gpg-pubkey|libmodulemd|katello-ca-consumer)' | sort
Explanation:
rpm -qalists all installed RPM packages.grep -e '\.el[78]'filters packages from RHEL 7 and RHEL 8.grep -vE '^(gpg-pubkey|libmodulemd|katello-ca-consumer)'excludes system key and module-related packages.sortarranges the output for easy review.
To count the number of RHEL 8-specific packages:
rpm -qa | grep -e '\.el[78]' | grep -vE '^(gpg-pubkey|libmodulemd|katello-ca-consumer)' | sort | wc -l
This will return the total count of relevant packages.
Step 2: Exporting Package List and Removing RHEL 8 Packages
Before removing, save the package list:
rpm -qa | grep -e '\.el[78]' | grep -vE '^(gpg-pubkey|libmodulemd|katello-ca-consumer)' | sort >> rhel8pkg.txt
This ensures that you have a backup reference of the packages being removed.
To remove these packages, execute:
dnf remove $(cat rhel8pkg.txt)
Explanation:
dnf removeuninstalls packages.$(cat rhel8pkg.txt)feeds the package list into the command.
Step 3: Cleaning Up Upgrade-Related Files
Remove any residual upgrade files that might interfere with the upgrade:
rm -rf /var/log/leapp /root/tmp_leapp_py3 /var/lib/leapp
Explanation:
rm -rfforcefully deletes unnecessary files and logs generated by theleappupgrade tool.
Step 4: Updating Kernel Boot Parameters
Modify kernel boot options to reflect necessary configurations:
BOOT_OPTIONS="$(tr -s "$IFS" '\n' </proc/cmdline | grep -ve '^BOOT_IMAGE=' -e '^initrd=' | tr '\n' ' ')"
echo $BOOT_OPTIONS > /etc/kernel/cmdline
Explanation:
tr -s "$IFS" '\n' </proc/cmdlineconverts the/proc/cmdlineparameters into a newline-separated format.grep -ve '^BOOT_IMAGE=' -e '^initrd='removes specific boot and initrd parameters.tr '\n' ' 'joins parameters back into a space-separated format.echo $BOOT_OPTIONS > /etc/kernel/cmdlinesaves the updated boot options.
Step 5: Removing Old Rescue Kernel Entries
To ensure a clean boot setup:
rm /boot/vmlinuz-*rescue* /boot/initramfs-*rescue*
Explanation:
rm /boot/vmlinuz-*rescue* /boot/initramfs-*rescue*removes old rescue kernel images.
Rebuild the rescue kernel:
/usr/lib/kernel/install.d/51-dracut-rescue.install add "$(uname -r)" /boot "/boot/vmlinuz-$(uname -r)"
This regenerates a rescue kernel for the current kernel version.
Verify rescue kernel presence:
ls /boot/vmlinuz-*rescue* /boot/initramfs-*rescue*
If verification is needed:
lsinitrd /boot/initramfs-*rescue*.img | grep -qm1 "$(uname -r)/kernel/" && echo "OK" || echo "FAIL"
This checks if the current kernel is properly included in the rescue image.
Step 6: Confirming GRUB Boot Configuration
To review the GRUB bootloader settings:
grubby --info $(ls /boot/vmlinuz-*rescue*)
This will display boot parameters associated with the rescue kernel.
Step 7: Final System Reboot
Once all steps are complete, reboot the system:
reboot
This will apply the changes and boot into the upgraded RHEL 9 environment.
Conclusion
This document provides a structured approach to upgrading from RHEL 8 to RHEL 9, covering package removal, kernel boot parameter adjustments, and GRUB bootloader updates to ensure a smooth transition.









