Sunday, October 30, 2011

Unable to find the sources of your current Linux kernel

When you are installing Oracle Linux (or other distributions) within a Oracle VirtualBox virtualization environment you do want to install the Guest Additions most likely. Depending on what you have included in your installation you might be missing some packages which result in failure of the installation of the Guest Additions.

Last “version” of this issue I encountered was represented by this error message:

The headers for the current running kernel were not found. 
If the following module compilation fails then this could be the reason.


Building the main Guest Additions module ...fail!
(Look at /var/log/vboxadd-install.log to find out what went wrong)

When you take a look in the mentioned log located in /var/log/vboxadd-install.log I encountered the following line:

Failed to install using DKMS, attempting to install without
/tmp/vbox.0/Makefile.include.header:94: *** Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR= and run Make again.  Stop.

This indicates that you do not have all the packages you need to rebuild some of the kernel parts. To resolve this you have to install the following GCC, kernel-dev and kernel-headers. You can do so by executing the following yum command:

yum install gcc kernel-devel kernel-headers

That is under the impression that you have already configured your yum repository to your enterprise yum repository or to the public yum server available online at Oracle. If you have not configured yum you can read in this blogpost how you should configure your yum settings.

Secondly you have to make sure you have a variable names KERN_DIR pointing to your sources kernel. In my case this is /usr/src/kernerls/2.6.32-131.0.15.el6.i686

9 comments:

Ben Hählen said...

Don't forget: Starting with OEL6, you automatically get the Unbreakable Enterprise Kernel (uek).
So, be sure to install the kernel-headers-uek and kernel-devel-uek packages instead of the "normal" kernel-header and kernel-devel.

I've been down that road, and it wasn't pretty ;).

Johan Louwers said...

True indeed. A good comment from Ben. :-)

Johan Louwers said...

That will be kernel-uek-headers and kernel-uek-devel

Ramanpal Singh Anand said...

Johan - I dont have words to thank you. I have been facing this issue from past 5 days and was not able to get correct answer. Finally your solution helped - Thanks again

Anonymous said...

Thank you Johan!!!!
Helmut

Jig said...

Hi Johan,

I have source the env variable to "KERN_DIR=/usr/src/kernels/2.6.18-194.el5-x86_64" but still getting error.

[root@XXXXX kernels]# KERN_DIR=/usr/src/kernels/2.6.18-308.11.1.0.1.el5-x86_64 /etc/init.d/vboxdrv setup
Stopping VirtualBox kernel modules [ OK ]
Uninstalling old VirtualBox DKMS kernel modules [ OK ]
Removing old VirtualBox pci kernel module [ OK ]
Removing old VirtualBox netadp kernel module [ OK ]
Removing old VirtualBox netflt kernel module [ OK ]
Removing old VirtualBox kernel module [ OK ]
Trying to register the VirtualBox kernel modules using DKMS[FAILED]
(Failed, trying without DKMS)
Recompiling VirtualBox kernel modules [ OK ]
Starting VirtualBox kernel modules [FAILED]
(modprobe vboxdrv failed. Please use 'dmesg' to find out why)


dmesg:
vboxdrv: no symbol version for module_layout


plz help

Johan Louwers said...

"vboxdrv: no symbol version for module_layout" check with uname -a if you have the same kernel version as you have the sources for. That might be a good starting point to look at.

Unknown said...

Thank you, that was very helpful!

guillermoagz said...

Hello there!
I have been trying to do all that is described here, unfortunately nothing seems to work.
I installed the yum gcc...

HOWEVER, repeating the steps you describe here the error still continous. Then I dont know exaclty how I should apply the comment from Ben Hählen, in which Johan has commented after him this: That will be kernel-uek-headers and kernel-uek-devel

do you know the commands I must use for this?

thanks