How7o
  • Home
  • Tools
  • Prank Screens
  • Learn
  • Blog
  • Contact
Reading: How to Upgrade the Linux Kernel in CentOS 7
Share
How7oHow7o
Font ResizerAa
  • OS
Search
  • Home
  • Tools
  • Prank Screens
  • Learn
  • Blog
  • Contact
Follow US
© 2024–2026 How7o. All rights reserved.
How7o > Learn > 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.
[mc4wp_form]
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
Next Article Laravel updateOrCreate method shown in an Eloquent code snippet with insert and update branches Laravel updateOrCreate: Insert or Update Records in Eloquent
Leave a Comment

Leave a Reply Cancel reply

You must be logged in to post a comment.

FacebookLike
XFollow
PinterestPin
InstagramFollow
Most Popular
Display PHP errors — ini_set + php.ini configuration
How to Display PHP Errors
May 10, 2026
PHP convert string to uppercase — strtoupper and mb_strtoupper
How to Convert a String to Uppercase in PHP
May 10, 2026
PHP string to float conversion with cast, regex cleanup, NumberFormatter
How to Convert a String to Float in PHP
May 10, 2026
PHP merge arrays without duplicates — union operator and array_unique
How to Combine Two Arrays Without Duplicates in PHP
May 10, 2026
PHP delete array element — unset, array_splice, array_filter, array_search
How to Delete an Element from a PHP Array
May 10, 2026

You Might Also Like

Login to Laravel programmatically without a password (Auth::login and loginUsingId)
Web Development

Login to Laravel Programmatically Without a Password (Auth::login & loginUsingId)

4 Min Read
MySQL connect remote from Ubuntu — mysql-client + mysql -h host
Server Management

How to Connect to a Remote MySQL Database from Ubuntu

7 Min Read
Configure Nginx for WordPress in aaPanel (fix 404 permalinks)
Server Management

Configure Nginx for WordPress in aaPanel (Fix Permalink 404 Errors)

5 Min Read
Laravel .htaccess exclude .well-known for Let's Encrypt ACME challenge
Server Management

How to Exclude .well-known from Redirection for Let’s Encrypt in Laravel

8 Min Read
How7o

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

Tools

  • Age Calculator
  • Word Counter
  • Image Upscaler
  • Password Generator
  • QR Code Generator
  • See all tools→

Pranks

  • Fake Blue Screen Prank
  • Hacker Typer
  • Fake iMessage Generator
  • Windows XP Crash Prank
  • Windows 11 Update Prank
  • See all prank screens →

Company

  • About Us
  • Blog
  • Contact
  • Privacy Policy
  • Terms of Service
  • Sitemap
© 2024–2026 How7o. All rights reserved.
Welcome Back!

Sign in to your account

Username or Email Address
Password

Lost your password?