CentOS 7 systems can use distribution packages, third-party kernel packages, or a kernel built from source. Each approach has compatibility and maintenance implications, especially for applications and drivers that depend on a particular kernel.
CentOS 7 is end-of-life. Upgrading its kernel alone does not make the operating system supported. Plan a migration to a maintained distribution. This article preserves the original workflow as historical guidance for legacy systems.
Before upgrading
Back up the system, verify that the application, drivers, boot mode, and any out-of-tree modules support the target kernel, and arrange console access in case the machine cannot boot. Keep a known-working kernel and a tested recovery path. Kernel changes require a reboot and a maintenance window.
The original article discussed ELRepo packages in two tracks:
kernel-ml for the mainline stable series and kernel-lt for a long-term series. Available versions and package policies change. Inspect the repository's current package metadata and compatibility rather than assuming old versions or coexistence rules still apply.Install a packaged kernel
After configuring a trusted, verified repository appropriate for the host, inspect available packages:
bash_snippet
Bash · 1 line|
| yum --enablerepo=elrepo-kernel list --showduplicates kernel-ml kernel-lt |
Choose one track and review the transaction before installing. For example, the original workflow used:
bash_snippet
Bash · 1 line|
| sudo yum --enablerepo=elrepo-kernel install kernel-lt kernel-lt-devel |
The
-devel package is useful when building modules against that kernel; it is not required for every system. For the mainline track, select the matching kernel-ml and, when needed, kernel-ml-devel packages instead. Confirm package signatures and repository trust; do not download unsigned RPMs over HTTP.Select and verify the boot entry
List boot entries and review the active GRUB configuration:
bash_snippet
Bash · 2 lines|
| awk -F\' '$1=="menuentry " {print $2}' /etc/grub2.cfg |
| sudo grub2-editenv list |
The original example used
grub2-set-default 0, but entry ordering can change, and saved-default behavior and UEFI paths vary. Identify the intended entry and use the GRUB procedure appropriate to the host before rebooting. Do not assume index zero is the desired kernel.After a controlled reboot:
bash_snippet
Bash · 2 lines|
| uname -r |
| rpm -qa | grep '^kernel' |
Verify critical services and drivers as well as the version.
Install a specific older version
Archived repositories may contain earlier kernel RPMs. Verify their source, signatures, dependencies, and support status. Match the kernel and any required
-devel package versions; install headers only when actually required and compatible with the host's packages. Review conflicts and the package manager's proposed changes before proceeding. An old kernel may contain known vulnerabilities.Build from source
A source build requires a suitable compiler and build dependencies. The original CentOS 7 example installed tools such as
gcc, make, bison, flex, ncurses-devel, openssl-devel, elfutils-libelf-devel, and bc. Exact requirements vary by kernel release.- Obtain and verify the desired source archive and extract it into a dedicated build directory.
- In that source tree, copy the running kernel configuration, for example
cp /boot/config-$(uname -r) .config.
- Adapt it for the target release using
make oldconfig,make menuconfig, ormake nconfig; review changes and driver requirements.
- Build using
make -j <jobs>, selecting a job count appropriate to available CPU and memory.
- Follow the release and distribution-specific installation procedure, including modules, initramfs, Secure Boot signing where applicable, and GRUB integration. The original workflow used
make modules_install installwith administrative privileges, but this alone is not a universal deployment procedure.
- Select the intended boot entry, reboot in a maintenance window, and verify as above.
Commands such as
make mrproper remove configuration and generated files: use them only inside the intended kernel source tree and before copying a configuration you need to keep.Removing or rolling back a kernel
Inspect the running version with
uname -r and installed packages with rpm -qa | grep '^kernel'. Boot and verify a retained fallback kernel before considering removal of another version. Review the exact package-manager transaction and its dependencies; never remove the running or last known-working kernel. If a desired older package conflicts with a newer one, follow the repository's supported downgrade procedure rather than forcing package removal.✦ 卷终 · 柯航存卷 ✦