Upgrading the kernel on CentOS gives you access to newer hardware drivers, better performance, and critical security fixes. This guide walks you through the process of installing a newer kernel from the official ELRepo repository, setting it as the default boot option, and verifying the change—all without breaking your existing system.
What You’ll Need
- A CentOS system (7, 8, or 9) with root or sudo access.
- A stable internet connection to download the new kernel packages.
- At least 1 GB of free disk space in /boot.
- If you’re on a production server, schedule a maintenance window—a kernel upgrade requires a reboot.
Step-by-Step
- Check your current kernel version. Run
uname -rto see what you’re running now. Note it down—you’ll compare it after the upgrade. - Update your system packages. Run
sudo yum update -y(orsudo dnf update -yon CentOS 8/9) to ensure all existing packages are up to date. This reduces the chance of dependency conflicts. - Install ELRepo. ELRepo is a third-party repository that provides the latest kernels for CentOS. For CentOS 7, run:
sudo rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org sudo rpm -Uvh https://www.elrepo.org/elrepo-release-7.0-6.el7.elrepo.noarch.rpmFor CentOS 8, use
elrepo-release-8.0-2.el8.elrepo.noarch.rpm, and for CentOS 9, useelrepo-release-9.0-1.el9.elrepo.noarch.rpm. Adjust the URL accordingly. - List available kernel versions. Run
yum --disablerepo="*" --enablerepo=elrepo-kernel list available(ordnfon newer systems). You’ll see packages likekernel-ml(mainline stable) andkernel-lt(long-term support). For most users,kernel-mlis the latest stable kernel. - Install the new kernel. For the mainline kernel, run:
sudo yum --enablerepo=elrepo-kernel install kernel-mlOn CentOS 8/9, replace
yumwithdnf. This installs the kernel and its modules. It won’t remove your old kernel—that stays as a fallback. - Verify the new kernel is installed. Run
rpm -qa | grep kernelto list all installed kernel packages. You should see the new one alongside the old one. - Set the new kernel as the default boot entry. After installation, the new kernel should automatically be placed first in the GRUB menu. To confirm, run
sudo grub2-editenv listand check thesaved_entryvalue. If it’s not pointing to the new kernel, runsudo grub2-set-default 0(assuming the new kernel is first in the menu). - Reboot the system. Run
sudo reboot. If you’re on a remote server, make sure you have console access or a recovery plan in case the system doesn’t come back up. - Verify the new kernel is running. After reboot, run
uname -ragain. The output should show the new kernel version. If it doesn’t, you may need to select it manually from the GRUB menu during boot. - Clean up old kernels (optional). Once you’re confident the new kernel works, you can remove old kernels with
sudo package-cleanup --oldkernels --count=2(CentOS 7) orsudo dnf remove $(dnf repoquery --installonly --latest-limit=-2)(CentOS 8/9). This frees disk space.
Common Mistakes
- Not updating the system first. Skipping
yum updatecan lead to missing dependencies or conflicts with older packages. - Using the wrong ELRepo release package. Installing the CentOS 7 ELRepo on CentOS 8 will fail. Always match the release version.
- Forgetting to reboot. The new kernel won’t be active until you reboot. Some users mistakenly think the upgrade is done after installation.
- Removing old kernels too soon. If the new kernel has issues (e.g., a driver failure), you’ll need the old kernel to boot. Keep at least one old kernel until you’re sure everything works.
- Not checking GRUB order. On some systems, the new kernel may not be first in the boot menu. Always verify with
grub2-editenv list.
Tips
- Use
kernel-ltinstead ofkernel-mlif you need maximum stability for production—it’s the latest long-term support kernel. - Before rebooting, take a snapshot of your VM or backup critical data. This is a low-risk operation, but a rollback plan is always good practice.
- If you have third-party kernel modules (like NVIDIA drivers), they will need to be recompiled for the new kernel. Install the matching
kernel-develpackage and reinstall the drivers after reboot. - Check the ELRepo website for the latest recommended kernel version—sometimes a new mainline kernel has known issues that are quickly fixed.
- After reboot, run
dmesg | grep -i errorto check for kernel-level errors that might indicate problems.
Troubleshooting
System won’t boot after upgrade. This is rare but possible. Reboot, and when the GRUB menu appears, select the previous kernel (usually the second entry). Once booted, you can investigate—check dmesg for errors, ensure all required modules are present, and consider reinstalling the new kernel or reverting to the old one.
New kernel isn’t listed in GRUB. Run sudo grub2-mkconfig -o /boot/grub2/grub.cfg to regenerate the GRUB configuration. This often happens if the kernel was installed but the GRUB config wasn’t refreshed.
Dependency errors during installation. If yum reports missing dependencies, try sudo yum --enablerepo=elrepo-kernel install kernel-ml --skip-broken to see the exact issue. Often, updating all packages first resolves this.
Network or driver issues after boot. If your network interface or other hardware stops working, you may need to install the corresponding firmware or driver packages. Check dmesg for messages about missing firmware and install the linux-firmware package from ELRepo if needed.
Can’t find ELRepo package. If the ELRepo RPM fails to install, verify your CentOS version with cat /etc/centos-release and download the correct release RPM from the ELRepo website manually.
Frequently Asked Questions
Is it safe to upgrade the kernel on a production CentOS server?
Generally yes, but always test on a staging server first. The new kernel is backward-compatible, but third-party modules or custom configurations might break. Keep the old kernel as a fallback.
What’s the difference between kernel-ml and kernel-lt?
kernel-ml is the latest mainline stable kernel, updated frequently. kernel-lt is the latest long-term support kernel, which receives security fixes but not new features. For production, kernel-lt is often preferred.
Can I upgrade to the latest kernel without ELRepo?
You can compile from source, but it’s more complex and not recommended for beginners. ELRepo provides pre-built RPMs that integrate with your package manager, making upgrades and removal easier.
Will upgrading the kernel affect my installed applications?
No, applications run in user space and are not affected by the kernel version. However, kernel modules (like drivers) may need to be reinstalled.
How do I revert to the old kernel if the new one causes problems?
Reboot, select the old kernel from the GRUB menu, then remove the new kernel package with sudo yum remove kernel-ml (or dnf). This will make the old kernel the default again.
Do I need to update GRUB manually after installing the new kernel?
Usually not—the installation scripts update GRUB automatically. But if you don’t see the new kernel in the menu, run sudo grub2-mkconfig -o /boot/grub2/grub.cfg.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.
More cards in this drawer
- Creality K3 4-Nozzle 3D Printer: 4.8s Swap?
- Notepad Remove Duplicate Lines: 3 Simple Ways
- Multi-Asset Trading Platforms: Why They’re Essential
- API Security Checklist: A Backend Dev’s Guide
- Storefront Hero Images: Desktop vs. Mobile Versions
- Device Encryption vs BitLocker: Key Differences