How to install Mainline Kernel on Rocky Linux 9

Share on Social Media

Discover how to install Mainline Kernel on Rocky Linux 9 with our step-by-step guide. Upgrade your system with the latest kernel version for improved performance, security, and hardware compatibility. #centlinux #linux #linuxkernel

What is Linux Kernel?

Kernel is the most important component of any Linux operating system. A Linux kernel is works as the interpreter or mediator between computer hardware and software processes.

The Linux Kernel performs following tasks.

  • Process Management
  • Memory Management
  • Device Drivers
  • System Calls and Security

Each Linux distribution is shipped with a stable version of Linux Kernel and the supported software and drivers. But the shipped Kernel may not be the the latest one.

The Linux kernel project integrates new code on a rolling basis. Software checked into the project must work and compile without error. Each kernel subsystem is assigned a maintainer who is responsible for reviewing patches against the kernel code standards and keeps a queue of patches that can be submitted to Linus Torvalds within a merge window of several weeks.

Patches are merged by Torvalds into the source code of the prior stable Linux kernel release, creating the -rc release candidate for the next stable kernel. Once the merge window is closed only fixes to the new code in the development release are accepted. The -rc development release of the kernel goes through regression tests and once it is judged to be stable by Torvalds and the kernel subsystem maintainers a new Linux kernel is released and the development process starts all over again.

What is Mainline Linux?

The Git tree of Linus Torvalds that contains the Linux kernel is referred to as mainline Linux. Every stable kernel release originates from the mainline tree, and is frequently published on kernel.org. Mainline Linux has only solid support for a small subset of the many devices that run Linux. Non-mainline support is provided by independent projects, such as Yocto or Linaro, but in many cases the kernel from the device vendor is needed. Using a vendor kernel likely requires a board support package.

Maintaining a kernel tree outside of mainline Linux has proven to be difficult.

Mainlining refers to the effort of adding support for a device to the mainline kernel, while there was formerly only support in a fork or no support at all. This usually includes adding drivers or device tree files. When this is finished, the feature or security fix is considered mainlined.

Recommended Online Training: Learn Bash Shell in Linux for Beginners

745772 0021show?id=oLRJ54lcVEg&offerid=1074652.745772&bids=1074652

Environment Specification

We are using a minimal Rocky Linux 9 virtual machine with following specifications.

  • CPU – 3.4 Ghz (2 cores)
  • Memory – 2 GB
  • Storage – 20 GB
  • Operating System – Rocky Linux release 9.0 (Blue Onyx)
  • Hostname – rocky-09.centlinux.com
  • IP Address – 192.168.116.130/24

Check your Current Linux Kernel Version

By using a ssh client, login to your Linux server as root user.

Check your Linux operating system version by executing following command.

# cat /etc/rocky-release
Rocky Linux release 9.0 (Blue Onyx)

Check your active Linux Kernel version by using uname command.

# uname -r
5.14.0-70.26.1.el9_0.x86_64

Install ELRepo on Rocky Linux 9

The latest Linux kernels are distributed through ELRepo yum repository. Therefore, you need to install it before installing Mainline Linux Kernel.

Import the GPG Key of ELRepo repository into the system.

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

Install ELRepo on your Linux server by using dnf command.

# dnf install -y https://www.elrepo.org/elrepo-release-9.el9.elrepo.noarch.rpm
Last metadata expiration check: 0:38:55 ago on Mon 17 Oct 2022 11:05:16 AM CDT.
elrepo-release-9.el9.elrepo.noarch.rpm          8.1 kB/s |  12 kB     00:01
Dependencies resolved.
================================================================================
 Package             Arch        Version                Repository         Size
================================================================================
Installing:
 elrepo-release      noarch      9.1-1.el9.elrepo       @commandline       12 k

Transaction Summary
================================================================================
Install  1 Package

Total size: 12 k
Installed size: 5.0 k
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                        1/1
  Installing       : elrepo-release-9.1-1.el9.elrepo.noarch                 1/1
  Verifying        : elrepo-release-9.1-1.el9.elrepo.noarch                 1/1

Installed:
  elrepo-release-9.1-1.el9.elrepo.noarch

Complete!

Build cache for newly installed yum repositories.

# dnf makecache
ELRepo.org Community Enterprise Linux Repositor  29 kB/s |  71 kB     00:02
Rocky Linux 9 - BaseOS                          952  B/s | 3.6 kB     00:03
Rocky Linux 9 - AppStream                       2.0 kB/s | 3.6 kB     00:01
Rocky Linux 9 - Extras                          1.2 kB/s | 2.9 kB     00:02
Metadata cache created.

Install Mainline Kernel on Rocky Linux 9

ELRepo repository contains elrepo-kernel channel that provides the Long Term Supported kernels (kernel-lt) and Main-Line Stable Kernels (kernel-ml) for Red Hat Enterprise Linux based distributions. Both of these Kernel packages are built from the sources available from The Linux Kernel Archives.

Search the elrepo-kernel channel to list down the kernel-ml related packages.

# dnf --disablerepo="*" --enablerepo="elrepo-kernel" list available | grep kernel-ml
kernel-ml.x86_64                         6.0.2-1.el9.elrepo        elrepo-kernel
kernel-ml-core.x86_64                    6.0.2-1.el9.elrepo        elrepo-kernel
kernel-ml-devel.x86_64                   6.0.2-1.el9.elrepo        elrepo-kernel
kernel-ml-devel-matched.x86_64           6.0.2-1.el9.elrepo        elrepo-kernel
kernel-ml-doc.noarch                     6.0.2-1.el9.elrepo        elrepo-kernel
kernel-ml-headers.x86_64                 6.0.2-1.el9.elrepo        elrepo-kernel
kernel-ml-modules.x86_64                 6.0.2-1.el9.elrepo        elrepo-kernel
kernel-ml-modules-extra.x86_64           6.0.2-1.el9.elrepo        elrepo-kernel
kernel-ml-tools.x86_64                   6.0.2-1.el9.elrepo        elrepo-kernel
kernel-ml-tools-libs.x86_64              6.0.2-1.el9.elrepo        elrepo-kernel
kernel-ml-tools-libs-devel.x86_64        6.0.2-1.el9.elrepo        elrepo-kernel

Install the Mainline Linux Kernel package by using the following command.

# dnf --enablerepo="elrepo-kernel" install -y kernel-ml
Last metadata expiration check: 0:00:36 ago on Mon 17 Oct 2022 11:45:44 AM CDT.
Dependencies resolved.
================================================================================
 Package              Arch      Version                  Repository        Size
================================================================================
Installing:
 kernel-ml            x86_64    6.0.2-1.el9.elrepo       elrepo-kernel     11 k
Installing dependencies:
 kernel-ml-core       x86_64    6.0.2-1.el9.elrepo       elrepo-kernel     56 M
 kernel-ml-modules    x86_64    6.0.2-1.el9.elrepo       elrepo-kernel     51 M

Transaction Summary
================================================================================
Install  3 Packages

Total download size: 107 M
Installed size: 148 M
Downloading Packages:
(1/3): kernel-ml-6.0.2-1.el9.elrepo.x86_64.rpm   32 kB/s |  11 kB     00:00
(2/3): kernel-ml-modules-6.0.2-1.el9.elrepo.x86 351 kB/s |  51 MB     02:28
(3/3): kernel-ml-core-6.0.2-1.el9.elrepo.x86_64 327 kB/s |  56 MB     02:55
--------------------------------------------------------------------------------
Total                                           623 kB/s | 107 MB     02:56
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                        1/1
  Installing       : kernel-ml-core-6.0.2-1.el9.elrepo.x86_64               1/3
  Running scriptlet: kernel-ml-core-6.0.2-1.el9.elrepo.x86_64               1/3
  Installing       : kernel-ml-modules-6.0.2-1.el9.elrepo.x86_64            2/3
  Running scriptlet: kernel-ml-modules-6.0.2-1.el9.elrepo.x86_64            2/3
  Installing       : kernel-ml-6.0.2-1.el9.elrepo.x86_64                    3/3
  Running scriptlet: kernel-ml-core-6.0.2-1.el9.elrepo.x86_64               3/3
  Running scriptlet: kernel-ml-6.0.2-1.el9.elrepo.x86_64                    3/3
  Verifying        : kernel-ml-6.0.2-1.el9.elrepo.x86_64                    1/3
  Verifying        : kernel-ml-core-6.0.2-1.el9.elrepo.x86_64               2/3
  Verifying        : kernel-ml-modules-6.0.2-1.el9.elrepo.x86_64            3/3

Installed:
  kernel-ml-6.0.2-1.el9.elrepo.x86_64
  kernel-ml-core-6.0.2-1.el9.elrepo.x86_64
  kernel-ml-modules-6.0.2-1.el9.elrepo.x86_64

Complete!

Mainline Linux Kernel 6.0 has been installed on your Rocky Linux server.

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

# reboot

After reboot, you will see that, the newly installed Linux Kernel 6.0 has been added to the GRUB boot menu.

Install Mainline Kernel on Rocky Linux 9
Install Mainline Kernel on Rocky Linux 9

Start your Linux operating system with newly installed Kernel 6.0.

After startup, execute the following command at Linux CLI to check your active Kernel version.

# uname -r
6.0.2-1.el9.elrepo.x86_64

Uninstall Mainline Linux Kernel 6.0

Uninstall process of Linux Kernel 6.0 is very straight forward, But we have included it in this configuration guide for the sake of completeness.

Restart your Linux operating system.

# reboot

Start the Linux operating system with an older version of Linux Kernel.

GRUB Old Linux Kernels
GRUB Old Linux Kernels

After successful startup, check the active kernel version by executing the following command at Linux CLI.

# uname -r
5.14.0-70.26.1.el9_0.x86_64

Your Linux operating system is now using an older version of Linux Kernel.

Linux Kernel 6.0 is not your active kernel, therefore you can safely uninstall it by using dnf command.

# dnf remove -y kernel-ml
Dependencies resolved.
================================================================================
 Package              Arch      Version                 Repository         Size
================================================================================
Removing:
 kernel-ml            x86_64    6.0.2-1.el9.elrepo      @elrepo-kernel      0
Removing unused dependencies:
 kernel-ml-core       x86_64    6.0.2-1.el9.elrepo      @elrepo-kernel     98 M
 kernel-ml-modules    x86_64    6.0.2-1.el9.elrepo      @elrepo-kernel     50 M

Transaction Summary
================================================================================
Remove  3 Packages

Freed space: 148 M
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                        1/1
  Erasing          : kernel-ml-6.0.2-1.el9.elrepo.x86_64                    1/3
  Erasing          : kernel-ml-modules-6.0.2-1.el9.elrepo.x86_64            2/3
  Running scriptlet: kernel-ml-modules-6.0.2-1.el9.elrepo.x86_64            2/3
  Running scriptlet: kernel-ml-core-6.0.2-1.el9.elrepo.x86_64               3/3
  Erasing          : kernel-ml-core-6.0.2-1.el9.elrepo.x86_64               3/3
  Running scriptlet: kernel-ml-core-6.0.2-1.el9.elrepo.x86_64               3/3
  Verifying        : kernel-ml-6.0.2-1.el9.elrepo.x86_64                    1/3
  Verifying        : kernel-ml-core-6.0.2-1.el9.elrepo.x86_64               2/3
  Verifying        : kernel-ml-modules-6.0.2-1.el9.elrepo.x86_64            3/3

Removed:
  kernel-ml-6.0.2-1.el9.elrepo.x86_64
  kernel-ml-core-6.0.2-1.el9.elrepo.x86_64
  kernel-ml-modules-6.0.2-1.el9.elrepo.x86_64

Complete!

Restart your Linux server again.

# reboot
Uninstall Linux Kernel
Uninstall Linux Kernel

You can see that Mainline Linux Kernel 6.0 has been removed from your operating system.

Video Tutorial: How to install Mainline Linux Kernel

YouTube player

Final Thoughts

Congratulations on successfully learning how to install Mainline Kernel on Rocky Linux 9! By upgrading to the latest kernel version, you’ve taken a significant step towards enhancing the performance, security, and compatibility of your system. Enjoy the benefits of the latest kernel updates and explore the new features and improvements they bring. Happy computing! We recommend that for learning more about Linux Kernel, you should read How Linux Works, 2nd Edition: What Every Superuser Should Know Second Edition (PAID LINK) by Brian Ward.

Leave a Comment