How To Install Linux Kernel 5.x on Almalinux 8 or Rocky

The kernel is the core program of every Linux -based operating system. It works as a mediator between the hardware and software of the computer. And if we place a graphical user interface and other software around the kernel, we get a full-fledged Linux operating system such as Ubuntu, Manjaro, and others. The kernel works in the background and makes sure that the operating system works and that the hardware and software can be put into operation.

Just like any software, Kernel is also a code, and developers of it keep updating and fixing bugs with every new release. Hence, Kernel can be updated to new versions like software, manually.

By default out of the box, while writing this article, both AlmaLinux and Rocky Linux 8.x were coming with Linux Kernel 4.x, whereas the latest stable long-term was 5.4, and stable mainline kernels were 5.12. Let’s see how to install/upgrade the current kernel version to the latest one.

Upgrade Kernel to 5.x on Almalinux 8 or Rocky

Step 1: Check the Current Kernel Version

First, check what is the current version of your system Linux to make sure it is not already using the latest one. To know that simply run:

uname -r

MobaXterm PVBnTcOMMq

 

Step 2: Add ELRepo Repository to Almalinux

The packages to install the latest stable kernels are available in the ELPrepo, thus we need to add that first on our Rocky or AlmaLinux.

Import the ELRepo’s GPG key, which will help our system to ensure whatever packages we get on our system will be verified and have not been altered somehow.

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

After that use the DNF package manager to install the ELrepo enterprise packages repository on AlmaLinux or Rocky.

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

 

Step 3: Run system update

Once the repository is added, run the system update command to not only get the latest updates for installed packages but also to refresh the system’s repository cache.

sudo dnf update

 

Step 4: List Kernels versions available to install

Now, let’s check what new kernel updates are available to install. They will be in two categories one will be the long-term kernel – called kernel-lt whereas the other one is a stable mainline kernel – represented as kernel-ml. You can install any of them as per your choice, however here we will go for kernel-ml.

So, to see what are available versions, run-

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

To search the packages in the above command we have omitted other system repos and asked the command to only show the packages available in elrepo.

The output will be like this:

Last metadata expiration check: 0:23:11 ago on Sat 05 Jun 2021 10:46:21 AM EDT.
Available Packages
bpftool.x86_64                        5.12.9-1.el8.elrepo elrepo-kernel
kernel-lt.x86_64                      5.4.124-1.el8.elrepo elrepo-kernel
kernel-lt-core.x86_64                 5.4.124-1.el8.elrepo elrepo-kernel
kernel-lt-devel.x86_64                5.4.124-1.el8.elrepo elrepo-kernel
kernel-lt-doc.noarch                  5.4.124-1.el8.elrepo elrepo-kernel
kernel-lt-headers.x86_64              5.4.124-1.el8.elrepo elrepo-kernel
kernel-lt-modules.x86_64              5.4.124-1.el8.elrepo elrepo-kernel
kernel-lt-modules-extra.x86_64        5.4.124-1.el8.elrepo elrepo-kernel
kernel-lt-tools.x86_64                5.4.124-1.el8.elrepo elrepo-kernel
kernel-lt-tools-libs.x86_64           5.4.124-1.el8.elrepo elrepo-kernel
kernel-lt-tools-libs-devel.x86_64     5.4.124-1.el8.elrepo elrepo-kernel
kernel-ml.x86_64                      5.12.9-1.el8.elrepo elrepo-kernel
kernel-ml-core.x86_64                 5.12.9-1.el8.elrepo elrepo-kernel
kernel-ml-devel.x86_64                5.12.9-1.el8.elrepo elrepo-kernel
kernel-ml-doc.noarch                  5.12.9-1.el8.elrepo elrepo-kernel
kernel-ml-headers.x86_64              5.12.9-1.el8.elrepo elrepo-kernel
kernel-ml-modules.x86_64              5.12.9-1.el8.elrepo elrepo-kernel
kernel-ml-modules-extra.x86_64        5.12.9-1.el8.elrepo elrepo-kernel
kernel-ml-tools.x86_64                5.12.9-1.el8.elrepo elrepo-kernel
kernel-ml-tools-libs.x86_64           5.12.9-1.el8.elrepo elrepo-kernel
kernel-ml-tools-libs-devel.x86_64     5.12.9-1.el8.elrepo elrepo-kernel
perf.x86_64                           5.12.9-1.el8.elrepo elrepo-kernel
python3-perf.x86_64                   5.12.9-1.el8.elrepo elrepo-kernel
[h2s@localhost ~]$

 

Step 5: Command to Install Kernel 5.x on AlmaLinux or Rocky 8

Finally, we know what is version available to install on our Linux, in our case, it was 5.12 in Kernel-ML and 5.4 for Kernel-LT.

So to install any of the latest version runs:

#For latest stable mainline 

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

#For latest Long term 

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

Commandto upgrade AlmaLinux or Rocky Kernel

 

Step 6: Reboot Your System

To apply the changes, let’s reboot our system. Once it did, then at the GRUB menu screen you will see your newly installed kernel 5.x has been selected by default. Just hit the Enter key.

Redhat enterprise Linux latest Kernel version 5

You can even check the kernel version by typing:

uname -r

 

Uninstall Kernel 5.x on Almalinux or Rocky 8

Although there is no need to remove the latest added kernel, you can choose previous ones from the Grub Boot menu if you want to use them. However, in case you really want to remove then use the below commands:

First, reboot your Linux system and select the default 4.x kernel of your system. And after that log in and on the terminal run:

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

Whereas for Long term version use-

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

 

Other Articles:

 

2 thoughts on “How To Install Linux Kernel 5.x on Almalinux 8 or Rocky”

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.