How To Upgrade Linux Kernel on Rocky Linux 8 | Full Steps
In this guide, we want to teach you How To Upgrade Linux Kernel on Rocky Linux 8. The Linux kernel is like a bridge that enables communication between applications and hardware and manages the system’s resources. Linus Torvald developed the Linux kernel with C and Assembly, and thus, he succeeded in creating a lightweight and portable core that was released to the public as open source.
In this tutorial on the Orcacore website, you will learn how to upgrade to the latest Linux Kernel on Rocky Linux 8 using ELRepo. This article is about How To Upgrade Linux Kernel on Rocky Linux 8.
To complete this guide, you must log in to your server as a non-root user with sudo privileges. To do this, you can follow our guide on the Initial Server Setup with Rocky Linux 8.
1. Check the Current Linux Kernel Version on Rocky Linux
The first step is to check the version of your kernel. To do this, you can use the following command:
uname -msr
In your output, you will see:
**Output**
Linux 4.18.0-305.12.1.el8_4.x86_64 x86_64
Then, use the following command to update your Rocky Linux repository:
sudo dnf -y update
2. Add ELRepo Repository on Rocky Linux 8
To update the kernel on Rocky Linux, you’ll need to install a third-party repository called ElRepo. ElRepo offers the latest kernel version available from kernel.org.
First, import the ElRepo GPG key with the following command:
sudo rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
Fix error: db5 error(-30969) from dbenv
Note: While running this command, if you get an error like this:
error: db5 error(-30969) from dbenv->open: BDB0091 DB_VERSION_MISMATCH: Database environment version mismatch
You can fix it by running the commands below:
# sudo dnf upgrade --refresh rpm glibc
# sudo rm /var/lib/rpm/.rpm.lock
# sudo dnf upgrade dnf
After that, rerun the command, and it runs correctly.
Then, run the command below to add and install the ElRepo on Rocky Linux 8:
sudo dnf install https://www.elrepo.org/elrepo-release-8.el8.elrepo.noarch.rpm
When you are finished, you will get the following output:

3. List Available Kernels on Rocky Linux 8
At this point, you can check for the available kernels on your server. To do this, run the command below:
dnf list available --disablerepo='*' --enablerepo=elrepo-kernel
In your output, you will see the following:

From your output, look at the right-hand column, and notice a series of letters and numbers (which looks something like ‘5.4.217-1.e17.elrepo’). This is the kernel version.
Use these two pieces of information to decide which kernel version you want to install. As you can see, the Linux 6 kernel is the latest mainline release.
4. Install the Latest Kernel on Rocky Linux 8
To install the latest mainline kernel on Rocky Linux 8, run the command below:
sudo dnf --enablerepo=elrepo-kernel install kernel-ml
**Output**
Installed:
kernel-ml-6.0.1-1.el8.elrepo.x86_64
kernel-ml-core-6.0.1-1.el8.elrepo.x86_64
kernel-ml-modules-6.0.1-1.el8.elrepo.x86_64
Complete!
To install the latest stable kernel, run the following command:
sudo dnf --enablerepo=elrepo-kernel install kernel-lt
**Output**
Installed:
kernel-lt-5.4.217-1.el8.elrepo.x86_64
kernel-lt-core-5.4.217-1.el8.elrepo.x86_64
kernel-lt-modules-5.4.217-1.el8.elrepo.x86_64
Complete!
5. Reboot and Choose the New Linux Kernel
At this point, you need to reboot your server:
reboot
You’ll be presented with the GRUB or boot menu.
Use the arrow keys to select the Linux kernel you have just installed, then press Enter
. Your operating system should boot normally.
6. Set the Default Kernel Version on Rocky Linux 8
Once you confirm that the new kernel is compatible and working correctly, you’ll want to edit the GRUB boot utility so that, by default, it loads your new kernel.
Navigate to /etc/default/ and open the grub file with your text editor. Or, type the following in the terminal:
sudo vi /etc/default/grub
Once the file opens, look for the line that says GRUB_DEFAULT=X
, and change it to GRUB_DEFAULT=0
. This line will instruct the boot loader to default to the first kernel on the list, which is the latest.
Save the file, and then type the following command in the terminal to recreate the kernel configuration:
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
**Output**
Generating grub configuration file ...
done
Reboot once more:
reboot
Verify that the boot loader is set to load the latest kernel by default.
uname -msr
**Output**
Linux 6.0.1-1.el8.elrepo.x86_64 x86_64
Conclusion
At this point, you have learned to How To Upgrade Linux Kernel on Rocky Linux 8. Upgrading the Linux kernel on Rocky Linux 8 improves system performance, enhances hardware support, and provides security updates. It helps fix bugs, adds new features, and ensures compatibility with the latest software. This guide showed you How To Upgrade Linux Kernel on Rocky Linux 8.
Hope you enjoy it. You may also like these articles:
How To Install Erlang on Rocky Linux 8
Install PostgreSQL 14 on Rocky Linux 8
Enable Kernel Crash Dump on Debian 11
Linux kernel 6.14 Features and Release Date
Alternative Solutions for Upgrading the Linux Kernel on Rocky Linux 8
While ELRepo provides a straightforward method for upgrading the kernel, alternative approaches exist, each with its own trade-offs. Here are two such alternatives:
1. Using the CentOS Kernel-ml Repository (with caution)
This method involves enabling the CentOS kernel-ml repository temporarily, installing the desired kernel, and then disabling the repository. It’s crucial to understand that this can lead to system instability or dependency conflicts if not handled carefully, as CentOS packages aren’t always perfectly compatible with Rocky Linux. Therefore, it is not recommended for production systems.
Explanation:
The CentOS kernel-ml repository contains more recent kernel versions than the base Rocky Linux repositories. By temporarily enabling it, you can access these newer kernels. However, because CentOS and Rocky Linux, while similar, are not identical, installing packages from the CentOS repository can introduce incompatibilities. This is one way for How To Upgrade Linux Kernel on Rocky Linux 8.
Steps:
-
Enable the CentOS kernel-ml repository (temporarily):
First, you need to find the exact repository file. The CentOS repositories are typically located in
/etc/yum.repos.d/
. Look for a file that seems to contain "centos" and "kernel-ml". You may have to install thecentos-release-kernel
package first. Important: Do not enable the base CentOS repositories, only the kernel-ml or similar kernel-specific repository.Let’s assume the file is named
CentOS-kernel.repo
. Edit this file:sudo vi /etc/yum.repos.d/CentOS-kernel.repo
Within the file, find the
[kernel-ml]
section (or similar) and changeenabled=0
toenabled=1
. Also, find the[kernel-ml-debuginfo]
section and make sure it isenabled=0
. -
List available kernels:
sudo dnf list available --enablerepo=kernel-ml
-
Install the desired kernel:
sudo dnf install --enablerepo=kernel-ml kernel-ml kernel-ml-devel
Replace
kernel-ml
andkernel-ml-devel
with the specific package names shown in thednf list available
output. -
Disable the CentOS kernel-ml repository:
Revert the changes made in
/etc/yum.repos.d/CentOS-kernel.repo
, settingenabled=1
back toenabled=0
in the[kernel-ml]
section. -
Update GRUB configuration and reboot:
sudo grub2-mkconfig -o /boot/grub2/grub.cfg reboot
Caveats:
- Risk of instability: This method is risky and can potentially break your system. Thoroughly research the specific kernel version and potential compatibility issues before proceeding.
- Dependency conflicts: CentOS packages may depend on different versions of libraries than those installed on Rocky Linux.
dnf
might attempt to resolve these conflicts by downgrading essential system packages, which can lead to severe problems. - Maintenance overhead: You’re relying on a repository not specifically designed for Rocky Linux, which means updates and security patches might not be applied in a timely manner or might introduce further instability.
Why this is generally NOT recommended: The risks associated with this approach outweigh the benefits in most cases. Stick to ELRepo or the official Rocky Linux repositories whenever possible.
2. Building a Kernel from Source
A more involved, but potentially more tailored, approach is to build the kernel from source code. This provides complete control over the kernel configuration but requires significant technical expertise and time.
Explanation:
Building the kernel from source allows you to select exactly which features and drivers are included, optimizing the kernel for your specific hardware and workload. You can download the source code from kernel.org, configure it using tools like make menuconfig
, compile it, and then install the resulting kernel image. This approach will affect How To Upgrade Linux Kernel on Rocky Linux 8.
Steps (Simplified Overview):
-
Install necessary build tools:
sudo dnf install -y gcc make ncurses-devel bc elfutils-libelf-devel openssl-devel
-
Download the kernel source code:
wget https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.0.1.tar.xz tar -xvf linux-6.0.1.tar.xz cd linux-6.0.1
Replace
linux-6.0.1.tar.xz
with the URL of the desired kernel version. -
Configure the kernel:
-
Copy the existing configuration: Start with your current kernel configuration as a base.
cp /boot/config-$(uname -r) .config
-
Customize the configuration (optional):
make menuconfig
This will open a text-based configuration interface. Be very careful when changing settings. Incorrect settings can prevent your system from booting. If you aren’t sure, it’s best to leave the settings at their defaults.
-
-
Compile the kernel:
make -j$(nproc)
The
-j$(nproc)
option tellsmake
to use all available CPU cores to speed up the compilation process. -
Install the modules:
sudo make modules_install
-
Install the kernel:
sudo make install
This command will install the kernel image to
/boot
and update the GRUB configuration. -
Reboot:
reboot
Caveats:
- Complexity: Building a kernel from source is a complex process that requires a solid understanding of Linux kernel internals.
- Time-consuming: Compilation can take a significant amount of time, even on powerful hardware.
- Maintenance burden: You are responsible for maintaining the kernel, including applying security patches and bug fixes.
- Potential for errors: Incorrect configuration can lead to a non-bootable system. It is essential to back up your system before attempting this.
Why this is generally NOT recommended for beginners: Building a kernel from source is an advanced task best left to experienced Linux users. The ELRepo method offers a much simpler and safer way to upgrade the kernel. It’s useful in very specific scenarios where precise kernel customization is required and the user has the necessary expertise.
Conclusion:
This article explored How To Upgrade Linux Kernel on Rocky Linux 8. While ELRepo provides the most practical and recommended approach for upgrading the Linux kernel on Rocky Linux 8 for most users, understanding alternative methods like using the CentOS kernel-ml repository (with caution) and building from source can be beneficial for specific scenarios. However, these alternatives come with significant risks and complexities that should be carefully considered before implementation. Always prioritize stability and data safety when making changes to your system’s kernel.