Upgrading CentOS kernel to the latest version | INTROSERV
EUR
european

EUR

usa

USD

English En
Ex. VAT Ex. VAT 0%

Upgrading the CentOS kernel to the latest version

This guide explains how to install a newer kernel on CentOS 7 using the ELRepo repository.

Warning

ELRepo discontinued support for el7 in July 2024. The procedure described in this guide no longer works. This guide is preserved as archival material.

If you are still running CentOS 7, consider migrating to AlmaLinux 8 using the Elevate tool.

Choose a kernel variant

ELRepo provides two kernel variants:

kernel-ml installs the mainline kernel, which follows the latest upstream Linux releases. It receives new features and improvements quickly but may introduce compatibility issues with drivers or production workloads.

kernel-lt installs a long-term support kernel, which prioritizes stability over new features. This is the recommended option for production servers.

Update the system and install ELRepo

Update the installed packages:

yum -y update

Import the ELRepo GPG key and install the repository:

rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org rpm -Uvh https://www.elrepo.org/elrepo-release-7.el7.elrepo.noarch.rpm

Verify that the repository was added successfully:

yum repolist | grep elrepo

Clear the yum cache:

yum clean all

Install the new kernel

To install the long-term support kernel (recommended for production):

yum --enablerepo=elrepo-kernel install kernel-lt kernel-lt-headers kernel-lt-tools kernel-lt-tools-libs

To install the mainline kernel instead:

yum --enablerepo=elrepo-kernel install kernel-ml kernel-ml-headers kernel-ml-tools kernel-ml-tools-libs

Verify that the kernel packages were installed:

rpm -qa | grep '^kernel-'

Set the new kernel as default

List all installed kernels with their boot order:

grubby --info=ALL | grep -E 'title|kernel'

The newest kernel is usually assigned index 0, but verify the order before setting it as default. Set the default by index:

grubby --set-default=0

Or by the full kernel path for reliability:

grubby --set-default /boot/vmlinuz-<version>

Replace <version> with the actual version string from the grubby --info=ALL output.

Verify the default kernel:

grubby --default-kernel grub2-editenv list

Info

If Secure Boot is enabled in BIOS/UEFI, third-party kernels from ELRepo may fail to boot. Disable Secure Boot before rebooting.

Reboot and verify

Reboot the server:

reboot

After the system comes back up, verify the running kernel version:

uname -r

Remove old kernels

Once the new kernel is confirmed working, remove older versions to free disk space. The --count=2 option keeps the two most recent kernels as a fallback:

yum install -y yum-utils package-cleanup --oldkernels --count=2

Emergency rollback

If the new kernel does not boot, select the previous kernel from the GRUB menu during startup. After booting into the old kernel, restore it as default:

grubby --set-default=1 reboot

Replace 1 with the index of the working kernel from grubby --info=ALL.

VAT

  • Other

    Ex. VAT

    0%
  • austria

    Austria

    20%
  • Belgium

    Belgium

    21%
  • Bulgaria

    Bulgaria

    20%
  • Croatia

    Croatia

    25%
  • Cyprus

    Cyprus

    19%
  • Czech Republic

    Czech Republic

    21%
  • Denmark

    Denmark

    25%
  • Estonia

    Estonia

    22%
  • France

    France

    20%
  • Finland

    Finland

    24%
  • Germany

    Germany

    19%
  • Greece

    Greece

    24%
  • Hungary

    Hungary

    27%
  • Ireland

    Ireland

    23%
  • Italy

    Italy

    22%
  • Latvia

    Latvia

    21%
  • Lithuania

    Lithuania

    21%
  • Luxembourg

    Luxembourg

    17%
  • Malta

    Malta

    18%
  • Netherlands

    Netherlands

    21%
  • Poland

    Poland

    23%
  • Portugal

    Portugal

    23%
  • Romania

    Romania

    19%
  • Slovakia

    Slovakia

    20%
  • Slovenia

    Slovenia

    22%
  • Spain

    Spain

    21%
  • Sweden

    Sweden

    25%
  • USA

    USA

    0%
european
states
  • germany
  • Español
  • Italiano
  • Poland
  • Русский
  • Slovenski
  • Türkçe
  • ukraine
  • kingdom
  • French
  • Hrvatska
  • Other
  • Austria
  • Belgium
  • Bulgaria
  • Croatia
  • Cyprus
  • Czech Republic
  • Denmark
  • Estonia
  • Finland
  • France
  • Germany
  • Greece
  • Hungary
  • Ireland
  • Italy
  • Latvia
  • Lithuania
  • Luxembourg
  • Malta
  • Netherlands
  • Poland
  • Portugal
  • Romania
  • Slovakia
  • Slovenia
  • Spain
  • Sweden
  • USA