HomeLinuxHow to Upgrade from CentOS 8 Stream to CentOS 9 Stream

How to Upgrade from CentOS 8 Stream to CentOS 9 Stream

This tutorial focuses on a seamless upgrade from CentOS 8 Stream to CentOS 9 Stream. By moving to CentOS 9 Stream, you may increase support, guarantee security enhancements and the most recent software, and boost enterprise support by better aligning with RHEL 9.

Overview of the Process

This guide will take you through the entire process, from backing up your system to verifying the upgrade and setting the latest kernel as default. We’ll start by backing up your system and updating CentOS 8 Stream. Then, we’ll disable CentOS 8-specific modules and install CentOS 9 repositories. After that, we’ll switch packages and rebuild the RPM database. We’ll also disable the subscription manager, reboot the system, and verify the upgrade. Finally, we’ll set the latest kernel as default and remove old kernels to ensure your system runs smoothly on CentOS 9 Stream. Follow these steps carefully to ensure a smooth upgrade.

How to Update CentOS 8 Stream?

Make sure your current CentOS 8 Stream system is up to date before upgrading to CentOS Stream 9. By doing this step, the likelihood of package conflicts during the conversion process is reduced. Use the following command to update it and then reboot the system:

sudo dnf update -y
reboot

Disable python36 and virt Modules

Some modules block kernel updates. It would help if you disabled them. Disabling python36 and virt module will allow this to proceed with upgradation.

dnf module disable python36 virt

How to Install CentOS 9 Repositories?

The below commands will install the required CentOS 9 Stream repositories and switch and rebuild your system to use it:

dnf install https://mirror.stream.centos.org/9-stream/BaseOS/x86_64/os/Packages/centos-stream-release-9.0-22.el9.noarch.rpm https://mirror.stream.centos.org/9-stream/BaseOS/x86_64/os/Packages/centos-gpg-keys-9.0-22.el9.noarch.rpm https://mirror.stream.centos.org/9-stream/BaseOS/x86_64/os/Packages/centos-stream-repos-9.0-22.el9.noarch.rpm
dnf --releasever=9 --allowerasing --setopt=deltarpm=false distro-sync -y
rpm --rebuilddb

How to Verify the CentOS 9 Stream Upgrade?

Reboot the system by executing sudo reboot command and then access the system when it comes online again. To check the status of upgrade, just view the contents of the file: centos-release by the command:

cat /etc/centos-release

You should see “CentOS Stream release 9” if the upgrade was successful.

Verify that the latest kernel is used (5.14+) by executing the command uname -a :

If the CentOS 9 Stream kernel is not listed in the uname -a output, install the latest kernel by executing the command:

sudo dnf install kernel

We have successfully installed the 5.14+ kernel. Now reboot the system!

sudo reboot

How to Set the Latest Kernel as Default?

If the latest kernel is not set as default, use grubby to set it. Here make sure the kernel for CentOS 9 Stream is correctly configured in the grub file.

Firstly, list all boot options:

sudo grubby --info=ALL

Your output should look like this if you have successfully installed the latest kernel:

In the above sample screenshot 5.14.0-452.el9.x86_64 (5.14+ kernel) was having index=0 value. Therefore set index=0 value in /etc/default/grub file and also set the default kernel by executing the below command:

sudo grubby --set-default /boot/vmlinuz-.

Example: The kernel version that I am using is 5.14.0-452.el9.x86_64. I am using the command after modifying it to fit my situation, as illustrated in the image below, and then running it:

Then set the index file correctly in the /etc/default/grub file by either setting the value of GRUB_DEFAULT to saved or the new kernel version/index.

sudo nano /etc/default/grub

All done, now you can regenerate the grub configuration and reboot the system for finalising the upgradation:

sudo grub2-mkconfig -o /boot/grub2/grub.cfg
sudo reboot

How to Remove Old Kernels? [Optional Step]

To remove the old kernel execute the following command where you can replace <old-kernel-version> with the specific versions you want to remove, such as 4.18.0-553.5.1.el8.x86_64 in my above example:

sudo dnf remove kernel-<old-kernel-version>

You’ve successfully upgraded from CentOS 8 Stream to CentOS 9 Stream, opening the door to a more modern operating environment. If you follow these steps, your upgrade will go smoothly and quickly. 😎🎉

Also Read:

CentOS 7 to CentOS 8 Stream Migration: Upgrade Guide
Scroll to Top