0

I cannot figure out how to install kernel-headers/devel-4.x on CentOS7. I want to compile a program using headers from a later kernel version without having to upgrade CentOS.

I'm running CentOS 7.9 (kernel: 3.10.0-1160.24.1.el7.x86_64), but this question applies to any level of CentOS7.

I have tried:

yum install kernel-devel-4.18.0-240.15.1.el8_3.x86_64

And

yum install https://vault.centos.org/8.3.2011/BaseOS/Source/SPackages/kernel-4.18.0-240.15.1.el8_3.src.rpm

Here's my repolist:

# yum repolist
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
epel/x86_64/metalink                                                                                                                                                                   | 4.6 kB  00:00:00
 * base: la.mirrors.clouvider.net
 * epel: mirror.twinlakes.net
 * extras: mirror.keystealth.org
 * updates: centos.mirror.ndchost.com
epel                                                                                                                                                                                   | 4.7 kB  00:00:00
(1/3): epel/x86_64/group_gz                                                                                                                                                            |  96 kB  00:00:00
(2/3): epel/x86_64/updateinfo                                                                                                                                                          | 1.0 MB  00:00:00
(3/3): epel/x86_64/primary_db                                                                                                                                                          | 6.9 MB  00:00:00
repo id                                                                              repo name                                                                                                          status
base/7/x86_64                                                                        CentOS-7 - Base                                                                                                    10072
epel/x86_64                                                                          Extra Packages for Enterprise Linux 7 - x86_64                                                                     13576
extras/7/x86_64                                                                      CentOS-7 - Extras                                                                                                    468
updates/7/x86_64                                                                     CentOS-7 - Updates                                                                                                  1924
repolist: 26040

Do I need to add a repo here? I have not been able to figure this out.

0

The kernel version you are looking at is the CentOS 8 kernel, which is not available on CentOS 7.

If you want a newer kernel on Centos7, you can get a 5.4 kernel currently with the ELRepo kernel-lt package (the current “long term” kernel as of April, 2021) or a 5.11 kernel with the kernel-ml (mainline) package. Each have their own -devel and related packages.

I would suggest the ELrepo packages over trying to get a Centos 8 kernel running on Centos 7.

2
  • Thx. I wasn't trying to get the 4.x kernel running inside RHEL7, rather I just needed to install the kernel-headers and kernel-devel installed in order to build some code which will run on CentOS8/RHEL on a different system. Not sure how this is usually handled if you have a build server which builds for various distros/levels. Apr 14 at 1:16
  • Typicall, you don’t install a kernel from another release of CentOS on a system, although you can extract the contents. I normally use mock to do this kind of thing, although I am building kmod packages: github.com/rpm-software-management/mock/wiki
    – jsbillings
    Apr 14 at 2:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.