6

Running ./VBoxLinuxAdditions.run in CentOS8 gives following error:

Kernel headers not found for target kernel 4.18.0-193.6.3.el8_2.x86_64. Please install them and execute /sbin/rcvboxadd setup
ValueError: File context for /opt/VBoxGuestAdditions-6.0.22/other/mount.vboxsf already defined
modprobe vboxguest failed

How do I install the required kernel headers?

4 Answers 4

7
# dnf update -y
# dnf install kernel-devel make gcc -y

Followed by reboot in case a new kernel gets installed should fix it for you.

2
  • yep. tried that too. no love. same error. but i'll spin up a fresh copy and try again.
    – WhiteRau
    Jul 11, 2020 at 8:23
  • ok. fresh copy. worked as you promised. thank you. wish i knew what went sideways. but hey it works. moving on. again, thank you.
    – WhiteRau
    Jul 11, 2020 at 9:38
5

After installing all the required packages, it still did not work for me. Then I got a crucial hint as to what was wrong, some subversion of kernel-devel must have been installed for me..

Have a look at

ls -l /lib/modules/$(uname -r)/build

For me it was pointing at a non-existing directory ie. /usr/src/kernels/4.18.0-193.el8.x86_64 while the real directory looked similar but different it was /usr/src/kernels/4.18.0-193.14.2.el8_2.x86_64

So I copied the contents from the 193.14.2 directory to the /usr/src/kernels/4.18.0-193.el8.x86_64 one and restarted the install script. I probably should have linked it instead op cp -R but whatever..

2
  • This was absolutely the issue I had, and this worked perfectly. Thanks for posting that!
    – Tim S.
    Jan 6, 2021 at 2:20
  • I can't believe that my link was pointing to the wrong place. I "fixed" it but I'm not 100% sure it is now pointing correctly. May 12, 2021 at 5:50
0

I recently ran into this issue with Centos 8. I found that I had to run the following to install the right packages for everything to work.

dnf update -y
dnf install -y kernel-devel kernel-header* make gcc elfutils-libelf-devel

The last package was missing from other answers and was a package suggested by the error log for virtual box (/var/log/vboxadd-setup.log). Without the elfutils-libelf-devel the kernel modules would fail to build.

-1

I resolve this with command as root

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

And re-run Guest Additions script

I receive an error after a fill seconds, but works fine!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .