Oracle VirtualBox Guest Addons | kernel headers not found for target kernel

So how many Oracle VirtualBox VM (Virtual Machine)s you do have?

I’ve many. I try many new software & not to break production box, I try them using Virtual Machines. I use Oracle VirtualBox (mostly) for both Windows and Linux machines (and VMWare ESXi for Production servers), as you could see with the above image. VirtualBox and VMWare supply additional software called “Guest Additions” that synchronize the Guest Virtual Machines with Host machine seamlessly. Like Mouse integration that allows your mouse to travel between both host and guest machines without any difficulties.

On Linux OS, installing the Guest Additions could be sometimes challenging. Especially with Oracle Linux that uses UEK kernels. Let us see how to “fix” the common error messages that appears when installing the Guest Additions on Oracle Linux 7 and 8.

The best approach is to update your Linux OS with latest patches before trying the below. I consider you already updated your Linux box, if yes then

yum install kernel-uek-devel

is enough to install the devel package, suffice the kernel headers missing error. Install the package, reboot the box and try to install VirtualBox Guest Additions. This time module should get installed properly. You may need make, gcc & perl already installed for a successful installation of Guest Additions. You will find instructions to install them later in the article.

Now we have another situation when guest add-ons are required, however updating the new Linux box is not possible due to many reasons. Here we will use the Linux OS ISO image. Please note, the ISO file that you are going to use must be the same ISO that you used to install OS and OS was not updated at all. That means your Linux box is as it is after the OS installation.

Attach the ISO file to your Linux box & Switch to

Packages folder for Oracle Linux 7 and “BaseOS\Packages” for Linux 8

Now locate the kernel-uek-devel-xxxxxxxxxxxxxxxxxxxx package and install it. For example, I will execute the following for Linux 8

rpm -ivh kernel-uek-devel-5.4.17-2136.300.7.el8uek.x86_64.rpm

That’s it. Restart the box and try to install the guest add-ons once again and you must be through without other issues. You might need to install gcc, make & perl also to get the guest add-ons installed.

If you are connected to internet, you can install the above packages by issuing the command

yum install gcc make perl -y

Or go through the packages available in the Packages repo, install them.

All the best!