Menu
User

DropVPS Team

Writer: Cooper Reagan

How to install Mainline Kernel on Centos 8

How to install Mainline Kernel on Centos 8

Publication Date

10/07/2025

Category

Articles

Reading Time

4 Min

Table of Contents

Running modern software or hardware on CentOS 8 often needs a newer Linux kernel. Installing the ELRepo mainline (kernel-ml) brings upstream features, drivers, and security fixes. The process is safe if you keep at least one old kernel and control GRUB defaults. Follow the steps below using a privileged shell.

Step 1: Check OS and current kernel

Confirm the system is CentOS 8 and note the running kernel. This helps with rollback and verification later.

cat /etc/centos-release
uname -r

Example output:

CentOS Linux release 8.5.2111
4.18.0-425.19.2.el8_7.x86_64

đź’» Looking for reliable Linux VPS hosting? Buy Linux VPS with full root access and instant setup.

Apply updates so toolchains and GRUB utilities are current. Reboot to ensure a clean baseline.

sudo dnf -y update
sudo reboot

Step 3: Install ELRepo and enable the kernel repository

ELRepo provides signed mainline kernels for Enterprise Linux. Install the release package and enable the elrepo-kernel channel.

sudo dnf -y install https://www.elrepo.org/elrepo-release-8.el8.elrepo.noarch.rpm
sudo dnf -y install dnf-plugins-core
sudo dnf config-manager --set-enabled elrepo-kernel
dnf repolist | egrep -i 'elrepo'

Step 4: Check Secure Boot and enroll ELRepo key (if needed)

Secure Boot may block third-party kernel booting. If enabled, enroll the ELRepo GPG key into MOK so the firmware trusts it.

sudo mokutil --sb-state

Example output:

SecureBoot enabled

If enabled, import and enroll:

sudo rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
sudo mokutil --import /etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org

Set a one-time password when prompted, reboot, then in the blue MOK Manager screen choose “Enroll MOK” → “Continue” → enter the password → reboot again.

Step 5: Install the mainline kernel (kernel-ml)

Install the latest upstream kernel and matching headers for building drivers and modules.

sudo dnf --enablerepo=elrepo-kernel -y install kernel-ml kernel-ml-headers kernel-ml-devel
rpm -qa | grep -E '^kernel-ml'

Step 6: Set the mainline kernel as the GRUB default

Use grubby to point GRUB to the new kernel so the next boot uses it automatically.

sudo grubby --info=ALL | egrep -i 'index|^title|^kernel'
sudo grubby --set-default /boot/vmlinuz-$(rpm -q --qf '%{VERSION}-%{RELEASE}.%{ARCH}\n' kernel-ml)
sudo grubby --default-kernel
sudo grubby --default-index

Example output:

/boot/vmlinuz-6.10.5-1.el8.elrepo.x86_64
0

Step 7: Reboot into the new kernel

Reboot the server and confirm the kernel version after login. Keep console/KVM access ready in case of driver issues.

sudo reboot
uname -r

Example output:

6.10.5-1.el8.elrepo.x86_64

Step 8: Install build tools and DKMS (optional but useful)

If you use out-of-tree drivers (ZFS, NVIDIA, WireGuard via DKMS), install EPEL and DKMS so modules rebuild on future kernel updates.

sudo dnf -y install epel-release
sudo dnf -y install dkms gcc make elfutils-libelf-devel

Step 9: Keep at least one old kernel for rollback

Do not remove your last known-good kernel. If testing is complete, you may prune older versions, but always keep one stock kernel.

rpm -qa | egrep '^kernel(-ml)?' | sort -V
# Example removal (replace with your exact version):
# sudo dnf remove -y kernel-ml-6.9.9-1.el8.elrepo.x86_64 kernel-ml-headers-6.9.9-1.el8.elrepo.x86_64

Step 10: Roll back to the previous kernel (if something breaks)

If the system misbehaves, set the older kernel as default and reboot. You can also select it once from the GRUB menu during boot.

sudo grubby --info=ALL | egrep -i 'index|^title|^kernel'
# Copy the path of your previous kernel from the list, then:
sudo grubby --set-default /boot/vmlinuz-4.18.0-425.19.2.el8_7.x86_64
sudo grubby --default-kernel
sudo reboot

Installing the ELRepo mainline kernel on CentOS 8 delivers newer features and hardware support with controlled risk by keeping a fallback kernel. For further reading, guidance, buying servers, and professional support, you can use dropvps.

Linux VPS
U
Loading...

Related Posts