Menu
User

DropVPS Team

Writer: Cooper Reagan

how to install mainline kernel on rocky linux 9

how to install mainline kernel on rocky linux 9

Publication Date

10/06/2025

Category

Articles

Reading Time

4 Min

Table of Contents

Installing a mainline Linux kernel on Rocky Linux 9 delivers newer hardware support, performance tweaks, and the latest features ahead of the default enterprise kernel. The safest way on RHEL-family systems is ELRepo’s kernel-ml packages. Follow the steps carefully, keep a fallback kernel, and prepare for Secure Boot if your server uses UEFI.

Check system and current kernel

Confirm you are on Rocky Linux 9 and note the running kernel before any changes.

cat /etc/os-release
uname -r
arch

Expected output example:

Rocky Linux 9.x
5.14.x-...el9.x86_64
x86_64

Bring the system current to reduce conflicts and ensure firmware/microcode are up to date.

sudo dnf -y update
sudo systemctl reboot

Check Secure Boot status

Mainline kernels from ELRepo require either enrolling ELRepo’s key via MOK or disabling Secure Boot. Decide now to prevent boot failures.

sudo mokutil --sb-state

Output examples:

SecureBoot enabled
# or
SecureBoot disabled

Enable ELRepo (trusted kernel repository)

Install ELRepo’s release package and import its GPG key. This adds the elrepo and elrepo-kernel repos for Rocky Linux 9.

sudo dnf -y install https://www.elrepo.org/elrepo-release-9.el9.elrepo.noarch.rpm
sudo rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
dnf repolist | grep -E 'elrepo'

Enroll ELRepo key if Secure Boot is enabled

Enroll ELRepo’s signing key so the system can boot their kernel with Secure Boot on. You will be prompted to confirm at next reboot (MOK Manager).

sudo mokutil --import /etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org
# Enter a one-time password when prompted

After enrolling, you must reboot later and complete the MOK enrollment menu. If you prefer, disable Secure Boot in firmware instead.

Install the mainline kernel (kernel-ml)

Install kernel-ml and, if you build drivers (NVIDIA, VirtualBox, ZFS), also install headers/devel now.

sudo dnf --enablerepo=elrepo-kernel -y install kernel-ml
# Optional for DKMS and builds:
sudo dnf --enablerepo=elrepo-kernel -y install kernel-ml-headers kernel-ml-devel

Verify installed kernels:

rpm -qa | grep -E '^kernel(-ml)?' | sort

Set mainline as the default boot entry

Rocky usually boots the newest kernel automatically. Confirm and, if needed, set the mainline kernel explicitly using grubby (BLS-aware).

sudo grubby --default-kernel
# Set default to the newest kernel-ml explicitly:
sudo grubby --set-default /boot/vmlinuz-$(rpm -q kernel-ml --qf '%{VERSION}-%{RELEASE}.%{ARCH}\n' | tail -1)
sudo grubby --default-kernel

Reboot and verify mainline kernel

Reboot and confirm the active kernel is from kernel-ml.

sudo systemctl reboot
# after login
uname -r
rpm -q kernel-ml

Expected uname example:

6.10.x-1.el9.elrepo.x86_64

Install DKMS and build tools (optional)

Ensure third‑party drivers rebuild against the new kernel.

sudo dnf -y install epel-release
sudo dnf -y install dkms gcc make elfutils-libelf-devel
# Rebuild modules for the running kernel if needed:
sudo dkms autoinstall -k $(uname -r)

Keep the Rocky kernel as a fallback

Maintain multiple kernels to recover quickly. Increase the installonly_limit to retain more versions.

grep -E '^installonly_limit' /etc/dnf/dnf.conf || echo 'installonly_limit=5' | sudo tee -a /etc/dnf/dnf.conf
sudo sed -i 's/^installonly_limit=.*/installonly_limit=5/' /etc/dnf/dnf.conf
# List boot entries:
sudo grubby --info=ALL | egrep 'index=|kernel='

Rollback or remove mainline kernel

Revert to the Rocky GA kernel if a device or driver misbehaves.

# Set default back to the latest distro kernel:
sudo grubby --set-default /boot/vmlinuz-$(rpm -q kernel --qf '%{VERSION}-%{RELEASE}.%{ARCH}\n' | tail -1)
# Optionally remove mainline kernels:
sudo dnf -y remove 'kernel-ml*'

Troubleshooting boot issues

Common problems after installing a mainline kernel on Rocky Linux 9 and quick fixes.

  • Secure Boot failed: Complete MOK enrollment at reboot or disable Secure Boot in firmware.
  • Missing network/storage driver: Boot fallback kernel, then try a newer kernel-ml or rebuild initramfs.
  • Initramfs regeneration:
sudo dracut -f --kver $(rpm -q kernel-ml --qf '%{VERSION}-%{RELEASE}.%{ARCH}\n' | tail -1)
  • GRUB not updating: BLS is default on EL9; use grubby, not manual grub.cfg edits.
  • Virtualization guests: Ensure virtio modules exist in initramfs and rebuild if needed.

Mainline kernel on Rocky Linux 9 delivers new features while keeping the distro kernel as a safe fallback. Test workloads, monitor dmesg, and keep DKMS modules in sync. For more guides and to buy servers with expert support, visit dropvps.com. For more guides, visit dropvps.com

Linux VPS
U
Loading...

Related Posts

how to install mainline kernel on rocky linux 9