Please install the Linux kernel "header" files matching the current kernel

General support questions
Post Reply
alexei28
Posts: 10
Joined: 2021/07/29 06:36:24

Please install the Linux kernel "header" files matching the current kernel

Post by alexei28 » 2021/08/02 10:20:14

CentOS 7, kerner 5.4.137-1.el7.elrepo.x86_64
, Virtual Box 6.1

I can't run virtual machine.

I try this command:

Code: Select all

/sbin/vboxconfig 
but get error:

Code: Select all

vboxdrv.sh: Stopping VirtualBox services.
vboxdrv.sh: Starting VirtualBox services.
vboxdrv.sh: Building VirtualBox kernel modules.
This system is currently not set up to build kernel modules.
Please install the Linux kernel "header" files matching the current kernel
for adding new hardware support to the system.
The distribution packages containing the headers are probably:
    kernel-devel kernel-devel-5.4.137-1.el7.elrepo.x86_64
This system is currently not set up to build kernel modules.
Please install the Linux kernel "header" files matching the current kernel
for adding new hardware support to the system.
The distribution packages containing the headers are probably:
    kernel-devel kernel-devel-5.4.137-1.el7.elrepo.x86_64

There were problems setting up VirtualBox.  To re-start the set-up process, run
  /sbin/vboxconfig
as root.  If your system is using EFI Secure Boot you may need to sign the
kernel modules (vboxdrv, vboxnetflt, vboxnetadp, vboxpci) before you can load
them. Please see your Linux system's documentation for more information.

scottro
Forum Moderator
Posts: 2556
Joined: 2007/09/03 21:18:09
Location: NYC
Contact:

Re: Please install the Linux kernel "header" files matching the current kernel

Post by scottro » 2021/08/02 12:44:21

You need to have kernel-devel and kernel-headers installed. Also, they must match your current running kernel.

What sometimes happens is that people update, which updates the kernel, and pulls in the latest kernel-devel. However, this will be a newer version than the actual running kernel. When this happens, it can be fixed with a reboot.

So make sure you have have kernel-devel and kernel-headers installed and that their version matches the kernel version. You can check that with

Code: Select all

uname -r 
If you go to install the headers and devel package, and they're a different version than the running kernel, you'll have to do a dnf upgrade to get the latest kernel as well.

Sometimes, even if you have these packages, it fails to install because you need other packages. If it fails, you should be able to find answers in /var/log/vbox-install.log. (I think, I don't have a machine with VirtualBox installed in front of me). But I vaguely remember having installed fail because I didn't have libelf-devel or something similar, but the vbox-install log is quite useful in giving solutions when a build fails.
New users should check the FAQ and Read Me First pages

alexei28
Posts: 10
Joined: 2021/07/29 06:36:24

Re: Please install the Linux kernel "header" files matching the current kernel

Post by alexei28 » 2021/08/02 13:00:42

Code: Select all

uname -r

5.4.137-1.el7.elrepo.x86_64
Now I want to install kernel-devel with this version.
I try

Code: Select all

sudo yum install "kernel-devel-uname-r == $(uname -r)"
but get error:
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: repo.fedora.md
* centos-sclo-rh: mirror.as43289.net
* elrepo: ftp.ines.lug.ro
* epel: repo.fedora.md
* extras: repo.fedora.md
* updates: mirror.as43289.net
No package kernel-devel-uname-r == 5.4.137-1.el7.elrepo.x86_64 available.
Error: Nothing to do

Mike_Rochefort
Posts: 215
Joined: 2016/03/16 02:34:19

Re: Please install the Linux kernel "header" files matching the current kernel

Post by Mike_Rochefort » 2021/08/02 14:11:05

The simple command to run would be (assuming you're running the latest kernel available (which .137 is):

Code: Select all

$ yum install kernel-lt-devel
As a side note, you need to remove a single = from your command, it has to match the output of the packages' metadata.

Code: Select all

$ yum install "kernel-devel-uname-r = $(uname -r)"

Code: Select all

$ rpm -q --provides kernel-lt-devel
kernel-devel = 5.4.137-1.el7.elrepo
kernel-devel-x86_64 = 5.4.137-1.el7.elrepo
kernel-devel-uname-r = 5.4.137-1.el7.elrepo.x86_64
kernel-lt-devel = 5.4.137-1.el7.elrepo
kernel-lt-devel-x86_64 = 5.4.137-1.el7.elrepo
kernel-lt-devel-uname-r = 5.4.137-1.el7.elrepo.x86_64
kernel-lt-devel(x86-64) = 5.4.137-1.el7.elrepo
Cheers,
Mike

Edit: removed traces of kernel-headers since kernel-lt-headers aren't needed as noted by the ELRepo docs:
There is no need to install the kernel-lt-headers package. It is only necessary if you intend to rebuild glibc and, thus, the entire operating system. If there is a need to have the kernel headers installed, you should use the current distributed kernel-headers package as that is related to the current version of glibc.

When you see a message like "your kernel headers for kernel xxx cannot be found ...", you most likely need the kernel-lt-devel package, not the kernel-lt-headers package.
Last edited by Mike_Rochefort on 2021/08/02 16:40:14, edited 5 times in total.
Solution Architect @RedHat | RHCE
Former SysAdmin @BlueSkyStudios and @Pixar
Feature animation and VFX enthusiast
--
Report CentOS Stream 8 bugs: https://da.gd/c8s-bugs
Report CentOS Stream 9 bugs: https://da.gd/c9s-bugs

User avatar
TrevorH
Site Admin
Posts: 33191
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Please install the Linux kernel "header" files matching the current kernel

Post by TrevorH » 2021/08/02 15:52:45

Or just yum --enablerepo=elrepo-kernel install kernel-\*devel-$(uname -r)
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

Mike_Rochefort
Posts: 215
Joined: 2016/03/16 02:34:19

Re: Please install the Linux kernel "header" files matching the current kernel

Post by Mike_Rochefort » 2021/08/02 16:58:56

@TrevorH: That actually won't work with the kernel-lt packages without extra flags, specifically because of the wildcard expansion. It'll try to install the kernel-lt-tools-libs-devel package, which directly conflicts with the existing kernel-tools* package and will fail the transaction. Adding --skip-broken is the way out, though.

The following runs do work without dependency issues:

Code: Select all

yum install kernel-lt-devel-$(uname -r)
yum install "kernel-devel-uname-r = $(uname -r)"
yum install "kernel-lt-devel-uname-r = $(uname -r)"
If you remove the arch from $(uname -r) you can also use other metadata comparisons, but the above should suffice for pretty much all situations.

Cheers,
Mike
Solution Architect @RedHat | RHCE
Former SysAdmin @BlueSkyStudios and @Pixar
Feature animation and VFX enthusiast
--
Report CentOS Stream 8 bugs: https://da.gd/c8s-bugs
Report CentOS Stream 9 bugs: https://da.gd/c9s-bugs

Post Reply