Upgrade to Latest Linux Kernel on AlmaLinux 8 or Rocky Linux 8

The Linux kernel is the core component of a Linux operating system. It is the interface between the computer’s hardware and the processes of a computer.

Linux Kernel needs to be updated periodically to improve security, bugs fix to problems, better hardware compatibility, improve speed, and new functionality.

Each Linux distribution comes with a stable version of Linux Kernel. This version may not be the latest one. The Linux Kernel Organization distributes the Linux kernel via The Linux Kernel Archives for free of charge.

In this tutorial, we learn how to upgrade to the latest Linux Kernel on AlmaLinux 8 or Rocky Linux 8 using ELRepo.

Step 1: Check Your Current Kernel Version

First, check your current kernel version using the uname command.

uname -r
check kernel version

The output shows Kernel 4.18 is currently running and on which architecture is based.

Step 2: Update AlmaLinux or Rocky Linux Repositories

Before upgrading the kernel, update all the packages to the latest version:

sudo dnf upgrade

This makes sure your software repository and packages are updated.

Step 3: Enable ELRepo Repository on AlmaLinux or Rocky Linux

ELRepo repositories provide the latest kernel version from The Linux Kernel Archives. It provides two kernel packages: kernel-ml and kernel-lt through elrepo-kernel channel. The kernel-ml packages are built from the sources available from the "mainline stable" branch and kernel-lt based on a "long term support" branch for Red Hat Enterprise Linux based distributions.

First import ELRepo’s GPG key, type:

sudo rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org

Next, install ELRepo repository for AlmaLinux 8 or Rocky Linux8 by executing the following command:

sudo dnf install https://www.elrepo.org/elrepo-release-8.el8.elrepo.noarch.rpm

Step 4: List Available Kernels

To list available kernels, type:

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

This will list the available kernel-ml and kernel-lt packages available in elrepo-kernel channel. kernel-lt is a stable long-term support release whereas kernel-ml with a shorter support term but with more frequent updates.

In the output, the second column indicates the available kernel version. You can see the mainline release has the latest Linux kernel.

Step 5: Install Latest Linux Kernel on AlmaLinux 8 or Rocky Linux 8

ELrepo-kernel channel currently has kernel 5.14 in kernel-ml and 5.4 in kernel-lt.

To install the latest mainline kernel:

sudo dnf --enablerepo=elrepo-kernel install kernel-ml
install kernel-ml

To install the latest long-term support kernel:

sudo dnf --enablerepo=elrepo-kernel install kernel-lt
install kernel-lt

This will download the latest kernel package and install it on your system.

Step 6: Reboot and Select the New Kernel

To load the new Linux kernel, you need to restart your machine.

$ sudo systemctl reboot

By default the Grub select the newly installed kernel, press Enter key to continue boot.

The GRUB_DEFAULT=N in the /etc/default/grub file, instructs the boot loader to default which kernel. The GRUB_DEFAULT=0 default to the first kernel on the list. If you making any changes, run sudo grub2-mkconfig -o /boot/grub2/grub.cfg to recreate the kernel configuration.

Once booted confirm the new version by uname -r command.

verify Kernel version installed

We have successfully installed the latest Kernel version 5.14 on AlmaLinux 8.

Remove the newly installed Linux Kernel

Reboot your Linux system and boot the system by selecting the old kernel from the Grub menu.

From the terminal run the following command to remove kernel-ml package and related packages:

sudo dnf remove kernel-ml kernel-ml-{devel,headers}

if you have install kernel-lt, run the following to remove it:

sudo dnf remove kernel-lt kernel-lt -{devel,headers}


In this tutorial, we learned how to upgrade/update to the latest Linux Kernel on AlmaLinux 8 or Rocky Linux 8.

Leave a Comment