How to Install Linux Kernel 6.0 on Rocky Linux 9 | Rocky Linux 8

As anyone who has used Rocky Linux Stream for any time knows, one of its primary focuses is stability. This can often mean that the distribution is relatively stable but usually has very outdated packages in terms of new features. For example, at the time of this writing, Rocky Linux features kernel 5.14, but some users may require a more recent kernel for better hardware compatibility, among many other things. While this focus on stability is admirable, it can be frustrating for users who need the latest and most significant features that newer kernels often provide. Fortunately, there are a few ways to work around this issue.

For most users, the best option is to use the ELRepo repository, which has an excellent reputation amongst EL9 and EL8 distributions such as AlmaLinux, CentOS, Oracle, etc. The following tutorial will show you how to import the ELRepo for Rocky Linux 9 or Rocky Linux 8 desktop or server using cli commands for the users that require to update their kernel for better hardware support.

Recommended Steps Before Installation

Before you begin, update your system to ensure all existing packages are up to date, as this is essential when installing/upgrading Linux kernels to avoid conflicts.

sudo dnf upgrade --refresh

Import ELRepo on Rocky Linux

The first step is to import the repository from the ELRepo project. This has the latest available mainline kernel with regular updates, so you do not need to compile kernels and install and upgrade using the dnf package manager.

First, import the GPG key to verify the installation package.

sudo rpm --import

Next, install the repository with the following command; ensure you import the correct version for your distribution version; if not, your kernel installation will fail.

Import ELRepo EL9 for Rocky Linux 9:

sudo dnf install -y

Import ELRepo EL9 for Rocky Linux 8:

sudo dnf install -y

To verify the imported repository, you can search ELRepo to see the supported kernels available for installation.

dnf list available --disablerepo='*' --enablerepo=elrepo-kernel

Example output:

example list contents of elrepo kernel on Rocky Linux 9/Rocky Linux 8

Install Linux Kernel 6.0 on Rocky Linux

The first option is to install the latest Linux Kernel from the stable branch. Given that Rocky Linux focuses on being extremely durable, this kernel version may bring inconsistencies, but for most systems, it should work fine and increase performance. Always have a backup solution in place when installing kernels on critical systems like you would with any significant packages.

In your terminal, use the following command to begin the installation.

sudo dnf --enablerepo=elrepo-kernel install kernel-ml kernel-ml-core kernel-ml-headers kernel-ml-modules kernel-ml-modules-extra -y

Now reboot your system; during the boot window with kernels to choose from, select kernel 6.0 if this option is not selected automatically. Remember, you can switch back to any kernel listed here for any problems that may occur.



bootscreen with new linux kernel on Rocky Linux 9/Rocky Linux 8

Once back in your system, verify the new kernel and build by checking the kernel.

uname -r

Or, for more detailed information, use something like the hostnamectl command.


Example output:

confirm elrepo kernel installed on Rocky Linux 9/Rocky Linux 8

Congratulations, you have installed the latest 6.0 kernel on your Rocky Linux 9 workstation desktop or a headless server.

Update Kernel from ELRepo on Rocky Linux

ELRepo uses the DNF manager, as you would have noticed when installing the kernel. To check and keep the kernel up to date, use the following command as you would with any other package.

sudo dnf upgrade --refresh

Remember, for any kernel updates, you will need to reboot your system.

Restore Default Kernel on Rocky Linux

For users who find the new kernel has bugs for their hardware, say, loss of sound, use the following steps to restore the default kernel; if you installed an alternative kernel, replace the default kernel section with whatever you want to install.

First, disable the ELRepo repository using the following command.

sudo dnf config-manager --set-disabled elrepo

Confirm this repository has been disabled using the following dnf repolist command.

Next, re-install the default kernel packages.

sudo dnf reinstall kernel kernel-core kernel-modules kernel-headers

Users that have removed all unused kernels use the install command instead.

sudo dnf install kernel kernel-core kernel-modules kernel-headers

Example output:

re-install kernel on Rocky Linux 9/Rocky Linux 8

Remember to reboot.


Select Linux Kernel 5.14 on system boot, and this is probably the simple way to revert to the kernel.

Once you have returned to Linux Kernel 5.14, which is the default currency for Rocky Linux, confirm it.

uname -r

Lastly, you can optionally remove all unused kernels. I would cite caution for this.

sudo dnf --setopt=protected_packages= remove $(rpm -q kernel-core | grep -v $(uname -r))

Not what you were looking for? Try searching for additional tutorials.

Leave a Comment