17

I've been having a difficult time getting Guest Additions to install on my Oracle Linux 7. I have VirtualBox version 6.1.4. I have guest additions version 6.0.4

The machine had 4.14.35-1902.7.3.1 kernel version. I succesed installed it a kernel version 4.1.12-124.24.3 on it. To do so, I followed the instructions from this page: https://www.thegeekdiary.com/centos-rhel-7-change-default-kernel-boot-with-old-kernel/

Newest article: (https://www.thegeekdiary.com/how-to-change-the-default-kernel-boot-from-old-kernel-in-centos-rhel-8/)

Installation steps:

yum -y install kernel-uek-firmware-4.1.12-124.24.3.el6uek.noarch.rpm
yum -y install kernel-uek-4.1.12-124.24.3.el6uek.x86_64.rpm
yum -y install kernel-uek-devel-4.1.12-124.24.3.el6uek.x86_64.rpm

awk -F\' '$1=="menuentry " {print $2}' /etc/grub2.cfg
grub2-set-default 0 #depends on the above result
grub2-mkconfig -o /boot/grub2/grub.cfg
And reboot.

When I run uname -r I got this: 4.1.12-124.24.3.el6uek.x86_64

At this point, everything it's fine until I have to install Guest Additions.

When I run ./VBoxLinuxAdditions.run this error is returned:

Verifying archive integrity... All good.
Uncompressing VirtualBox 6.0.4 Guest Additions for Linux........
VirtualBox Guest Additions installer
Removing installed version 6.1.4 of VirtualBox Guest Additions...
Copying additional installer modules ...
Installing additional modules ...
VirtualBox Guest Additions: Starting.
VirtualBox Guest Additions: Building the VirtualBox Guest Additions kernel
modules.  This may take a while.
VirtualBox Guest Additions: To build modules for other installed kernels, run
VirtualBox Guest Additions:   /sbin/rcvboxadd quicksetup <version>
VirtualBox Guest Additions: or
VirtualBox Guest Additions:   /sbin/rcvboxadd quicksetup all
VirtualBox Guest Additions: Kernel headers not found for target kernel
4.1.12-124.24.3.el6uek.x86_64. Please install them and execute
  /sbin/rcvboxadd setup
modprobe vboxguest failed
The log file /var/log/vboxadd-setup.log may contain further information.

I reran /sbin/rcvboxadd setup but it was the same log message. The log file just showed up "modprobe vboxguest failed". I also exported KERN_DIR environment variable as /usr/src/kernels/4.1.12-124.24.3.el6uek.x86_64

What I am doing wrong? Does anyone knows how to install it properly? If anyone has any ideas I would really appreciate feedback.

7 Answers 7

17

On my CentOS 6 VM, the kernel development package was not installed, so I had to do:

yum install kernel-devel

This, however, created a mismatch between the kernel development version (2.6.32-754.31.1.el6) and the actual kernel version (2.6.32-754.el6). You can check all these versions using yum list kernel*. So, I then updated my kernel version and rebooted:

yum update kernel kernel-headers
reboot now

On my system, the Guest Additions autorun.sh file still did not complete after this, because the gcc package was missing:

yum install gcc

After installing gcc, the Guest Additions installation succeeded, and they took effect after another reboot.

2
  • This answer basically worked for me. For me there was no mismatched version, but I did have a lot other missing packages. The error log guided me through which packages to yum install. At the end of it all I rebooted and now things seem to be working nicely.
    – DavidS
    Commented Mar 29, 2021 at 4:19
  • Only this actually worked for me. Before that I had used linuxconfig.org/… as prerequisite installation before I had installed the guest-edition, that led to the above error that this article handled correctly. Virtual Box 6.1 and Centos7. It saved my time and from frustations:-) Commented May 14, 2022 at 15:04
4

I was getting Issues even after getting the proper packages. I first made sure to check and update my kernel headers...

    yum update kernel kernel-headers

...made sure I had appropriate pre-reqs installed..

    yum -y install gcc make

...Then I forced the correct version by running:

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

This is all assuming that uname -r is displaying the correct value.

1
  • Another thing that may help is to set the KERN_DIR environment variable. to the kernel source code directory. $ export KERN_DIR=/usr/src/kernels/$(uname -r) THEN you can try again with guest additions.
    – Langosta
    Commented Aug 5, 2022 at 18:17
3

I am not sure, but i think even if you are loading the correct kernel, the devel package that include headers since the newest kernel versions is incompatible with the current kernel, to check this :

rpm -qa | grep kernel

Then install the correct devel version and make sure gcc and make are installed :

yum -y install gcc make
yum -y install kernel-uek-devel-`uname -r`

if the repo is not available, execute this before

yum-config-manager --add-repo=yum.oracle.com/repo/OracleLinux/OL6/UEKR4/archive/x86_64
sudo yum install -y kernel-uek-4.1.12-124.24.3.el6uek.x86_64
sudo yum install -y kernel-uek-devel-4.1.12-124.24.3.el6uek.x86_64
2
  • I tried it and it didn't work. [root@devbox ~]# yum -y install kernel-uek-devel-`uname -r` Loaded plugins: langpacks, ulninfo No package kernel-uek-devel-4.1.12-124.24.3.el6uek.x86_64 available. Error: Nothing to do
    – Dyno
    Commented Mar 17, 2020 at 19:05
  • Try to add this repo : yum.oracle.com/repo/OracleLinux/OL6/UEKR4/archive/x86_64
    – Reda Salih
    Commented Mar 17, 2020 at 19:26
2

here's the code from the Virtual Box script:

        if test -d /lib/modules/"$TARGET_VER"/build; then
            setup_modules "$TARGET_VER"
            depmod
        else
            info "Kernel headers not found for target kernel $TARGET_VER. [...]

The variable $TARGET_VER is defined as:

test -z "${TARGET_VER}" && TARGET_VER=`uname -r`

So I'd check if /lib/modules/$(uname -r)/build points to a valid directory with kernel source...

2

The message says:

VirtualBox Guest Additions: Kernel headers not found for target kernel
5.3 (in may case).

the target kernel is the kernel version the OS is using. you can see it with:

uname -r

5.3

The kernel headers are made by the kernel-devel package: you can see the versión of kernel-devel with:

dnf list kernel-devel*

kernel-devel.x86_64                             5.10

I have Kernel headers for kernel version 5.10, but virtual box is trying to use headers for kernel versión 5.3.

You have to boot the OS using kernel version 5.10 instead of 5.3

to see if you have kernel versión 5.10:

dnf list kernel-core*

kernel-core.x86_64                             5.3                           @updates 
kernel-core.x86_64                             5.9                          @updates 
kernel-core.x86_64                             5.10

There it is.

Now you just need to update grub2 so it can see the new kernel versión:

grub2-mkconfig –o /boot/grub2/grub.cfg

reboot

Now check again which kernel version the OS is using:

 uname –r

 5.10

this solved the problem for me.

1

Simple one-liner from Dev2QA.com:

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

On your Linux, you must install the Kernel-devel version to match the target kernel using this link https://yum.oracle.com/repo/OracleLinux/OL8/UEKR6/x86_64/

  • Then reboot, and Install the Guest Addition again.

The guest additions should work fine.

You must log in to answer this question.

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