How7o
  • Home
  • Tools
  • Prank Screens
  • Contact
  • Blog
Reading: How to Upgrade the Linux Kernel in CentOS 7
Share
Subscribe Now
How7oHow7o
Font ResizerAa
  • Marketing
  • OS
  • Features
  • Guide
  • Complaint
  • Advertise
Search
  • Home
  • Tools
  • Prank Screens
  • Contact
  • Blog
Follow US
Copyright © 2014-2023 Ruby Theme Ltd. All Rights Reserved.
How7o > Blog > Server Management > How to Upgrade the Linux Kernel in CentOS 7
Server Management

How to Upgrade the Linux Kernel in CentOS 7

how7o
By how7o
Last updated: April 16, 2026
9 Min Read
Step-by-step guide to upgrading the Linux kernel in CentOS 7 using ELRepo
SHARE

I needed to upgrade the Linux kernel on a CentOS 7 server to patch a security vulnerability and pick up newer hardware support. If you’re running CentOS 7 and need a newer kernel than what the default repos provide, this guide walks you through the full process — from checking your current version to setting the new kernel as the default boot option in GRUB.

Contents
  • TL;DR
  • Step 1: Check Your Current Kernel Version
  • Step 2: Update CentOS Repositories
  • Step 3: Enable the ELRepo Repository
    • Import the GPG Key
    • Install the ELRepo Repository Package
  • Step 4: List Available Kernels
  • Step 5: Install the New Kernel
    • Option A: Install the Mainline Kernel
    • Option B: Install the Long-Term Support Kernel
  • Step 6: Reboot and Select the New Kernel
  • Step 7: Set the New Kernel as the Default Boot Option
  • Troubleshooting
    • New Kernel Does Not Appear in GRUB Menu
    • System Boots Into the Old Kernel
    • ELRepo RPM Installation Fails
  • Frequently Asked Questions
  • Related Guides

Originally published March 16, 2023, rewritten and updated April 16, 2026.

⚠️ CentOS 7 reached end of life on June 30, 2024. This means no further security patches or updates from the CentOS project. If you are still running CentOS 7 in production, consider migrating to AlmaLinux, Rocky Linux, or another RHEL-compatible distribution. The steps below remain accurate for existing CentOS 7 systems, but the ELRepo repository may eventually stop providing new kernel builds for CentOS 7.

TL;DR

Import the ELRepo GPG key, install the ELRepo repository, then use yum to install either kernel-ml (mainline) or kernel-lt (long-term support). After installation, reboot, select the new kernel from the GRUB menu, and set GRUB_DEFAULT=0 in /etc/default/grub so it boots by default. Regenerate the GRUB config with grub2-mkconfig and reboot once more to confirm.

Step 1: Check Your Current Kernel Version

Before upgrading the Linux kernel, check which version is currently running. This gives you a baseline to verify the upgrade succeeded later.

uname -msr

You will see output like Linux 3.10.0-1160.el7.x86_64 x86_64 — the default CentOS 7 kernel is in the 3.10.x series. Note this version so you can compare after the upgrade.

Step 2: Update CentOS Repositories

Update your existing packages and repository metadata before adding new repos. This ensures there are no dependency conflicts during the kernel installation.

sudo yum -y update

The -y flag automatically confirms all prompts. Depending on how many packages need updating, this may take a few minutes.

Step 3: Enable the ELRepo Repository

The default CentOS repositories do not carry newer kernel versions. ELRepo is a community repository that provides kernel packages built specifically for RHEL/CentOS.

Import the GPG Key

CentOS requires packages to be signed. Import the ELRepo GPG key first:

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

Install the ELRepo Repository Package

Install the repository configuration RPM:

sudo rpm -Uvh https://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm

This adds the ELRepo repository to your yum configuration. You can verify it was added by checking /etc/yum.repos.d/elrepo.repo.

Step 4: List Available Kernels

With ELRepo enabled, list the kernel packages it offers:

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

Look for two key entries in the output:

  • kernel-lt — Long-term support kernel. More conservative, fewer updates, longer maintenance window. Best for production servers where stability matters most.
  • kernel-ml — Mainline kernel. Latest features and drivers, shorter support cycle, more frequent updates. Good for development or when you need specific hardware support.
Available kernel packages from the ELRepo repository listed in a CentOS 7 terminal

Step 5: Install the New Kernel

Choose one of the two kernel branches and install it. You do not need to remove your current kernel — CentOS keeps multiple kernels installed side by side and lets you select at boot.

Option A: Install the Mainline Kernel

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

Option B: Install the Long-Term Support Kernel

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

When prompted to confirm the installation, type y and press Enter. The download and installation will take a minute or two depending on your connection speed.

Step 6: Reboot and Select the New Kernel

Reboot the system so GRUB picks up the newly installed kernel:

reboot

When the GRUB boot menu appears, use the arrow keys to highlight the new kernel entry and press Enter. If you are on a remote server without console access, the newest kernel is typically the first entry in GRUB by default, so a simple reboot may boot into it automatically — but verify with uname -msr after reconnecting.

Step 7: Set the New Kernel as the Default Boot Option

After confirming the new kernel works, make it the permanent default. Open the GRUB configuration:

sudo vim /etc/default/grub

Find the GRUB_DEFAULT line and set it to 0:

GRUB_DEFAULT=0

This tells GRUB to boot the first entry in the menu — which is the newest kernel. Save and close the file, then regenerate the GRUB configuration:

sudo grub2-mkconfig -o /boot/grub2/grub.cfg

Reboot one final time and verify the new kernel is active:

reboot

After the system comes back up, run uname -msr again. The version number should now reflect the kernel you installed in Step 5.

Troubleshooting

New Kernel Does Not Appear in GRUB Menu

If the newly installed kernel does not show up after reboot, the GRUB config may not have been regenerated. Run sudo grub2-mkconfig -o /boot/grub2/grub.cfg and reboot again.

System Boots Into the Old Kernel

Verify that GRUB_DEFAULT=0 is set in /etc/default/grub and that you regenerated the config afterward. You can also check the installed kernels and their order with awk -F\' '/menuentry / {print $2}' /boot/grub2/grub.cfg to confirm the new kernel is listed first.

ELRepo RPM Installation Fails

If the rpm -Uvh command fails with a network error, ensure your server can reach elrepo.org. On firewalled servers, you may need to allow outbound HTTPS. You can also download the RPM manually and install it from the local file.

Frequently Asked Questions

Should I install kernel-lt or kernel-ml on CentOS 7?

Install <strong>kernel-lt</strong> (long-term support) for production servers where stability is the priority. Install <strong>kernel-ml</strong> (mainline) if you need the latest features, drivers, or security patches that haven’t been backported to the LTS branch yet.

Can I remove the old kernel after upgrading?

Yes, but it is safer to keep at least one previous kernel as a fallback. If the new kernel causes issues, you can select the old one from the GRUB boot menu. CentOS keeps multiple kernels installed by default and <code>yum</code> is configured (via <code>installonly_limit</code> in <code>/etc/yum.conf</code>) to automatically remove the oldest kernel when you exceed the limit.

Is CentOS 7 still supported for kernel upgrades?

CentOS 7 reached end of life on June 30, 2024. The base CentOS repositories no longer receive updates. ELRepo may continue to provide kernel packages for CentOS 7 for some time, but long-term you should plan to migrate to AlmaLinux, Rocky Linux, or another RHEL-compatible distribution.

How do I revert to the old kernel if the new one causes problems?

Reboot the system and select the old kernel from the GRUB boot menu using the arrow keys. To make it the default again, change <code>GRUB_DEFAULT</code> in <code>/etc/default/grub</code> to the menu index of the old kernel (usually <code>1</code>) and run <code>sudo grub2-mkconfig -o /boot/grub2/grub.cfg</code>.

How do I check which kernel version is currently running?

Run <code>uname -msr</code> in the terminal. This prints the kernel name, version, and machine hardware architecture. For more detail, use <code>uname -a</code> to see the full kernel version string including the build date.

Related Guides

  • How to Install MySQL on Ubuntu
  • How to Install PHP on Ubuntu
  • How to Install Node.js on Ubuntu

For the official ELRepo documentation and available packages, see elrepo.org.

TAGGED:BashcentosconfigurationinstallationSecurity

Sign Up For Daily Newsletter

Be keep up! Get the latest breaking news delivered straight to your inbox.
By signing up, you agree to our Terms of Use and acknowledge the data practices in our Privacy Policy. You may unsubscribe at any time.
Share This Article
Facebook Copy Link Print
Previous Article Install Node.js on Ubuntu — terminal with NodeSource setup_22.x curl command and Node.js hexagon icon How to Install Node.js on Ubuntu (22.04 & 24.04): Step-by-Step
Leave a Comment

Leave a Reply Cancel reply

You must be logged in to post a comment.

FacebookLike
XFollow
PinterestPin
InstagramFollow

Subscribe Now

Subscribe to our newsletter to get our newest articles instantly!
Most Popular
Step-by-step guide to upgrading the Linux kernel in CentOS 7 using ELRepo
How to Upgrade the Linux Kernel in CentOS 7
April 16, 2026
Install Node.js on Ubuntu — terminal with NodeSource setup_22.x curl command and Node.js hexagon icon
How to Install Node.js on Ubuntu (22.04 & 24.04): Step-by-Step
April 16, 2026
Configure WordPress multisite with subdirectories on Nginx — nginx gear + wordpress tree with subsite branches
How to Configure WordPress Multisite with Subdirectories on Nginx
April 16, 2026
Install Laravel on Ubuntu — terminal with composer create-project command and Laravel red-pillar icon
How to Install Laravel on Ubuntu: Step-by-Step Guide
April 16, 2026
Install PHP on Ubuntu — terminal with apt install php command and stylized elephant icon
How to Install PHP on Ubuntu (22.04 & 24.04): Step-by-Step Guide
April 16, 2026

You Might Also Like

Migrating files from cPanel to aaPanel using rsync
Server Management

cPanel to aaPanel Migration with rsync: Fix Permissions, SSH Port, and CSF Firewall

6 Min Read
Install MySQL on Ubuntu 22.04 — terminal with apt command and database cylinder icon
Server Management

How to Install MySQL on Ubuntu 22.04: Step-by-Step Guide

9 Min Read
Automatic logout timeout for command line in Ubuntu (TMOUT 300s)
Server Management

Automatic Logout Timeout for Command Line in Ubuntu (TMOUT 300s)

5 Min Read
Create a Directory in Ubuntu
Server Management

Create a Directory in Ubuntu (mkdir Command + Examples)

4 Min Read
How7o

We provide tips, tricks, and advice for improving websites and doing better search.

Latest News

  • SEO Audit Tool
  • Client ReferralsNew
  • Execution of SEO
  • Reporting Tool

Resouce

  • Google Search Console
  • Google Keyword Planner
  • Google OptimiseHot
  • SEO Spider

Get the Top 10 in Search!

Looking for a trustworthy service to optimize the company website?
Request a Quote
Welcome Back!

Sign in to your account

Username or Email Address
Password

Lost your password?