e Learning

Unable to find the sources of your current Linux kernel – CentOS 7 VirtualBox

Make sure to install  kernel-headers and gcc Compiler Before you install VirtualBox on CentOS 7 or Fedora 23 workstation.

sudo yum install kernel-devel kernel-headers gcc

Otherwise, you will get multiple “Recompiling VirtualBox kernel modules failed”  error messages.

Problem : unable to find the sources of your current Linux kernel

Unable to find the sources of your current Linux kernel

Without above three packages you will get the following error message during the installation process.

No precompiled module for this kernel found — trying to build one. Messages emitted during module compilation will be logged to /var/log/vbox-install.log. Recompiling VirtualBox kernel modules [FAILED] (Look at /var/log/vbox-install.log to find out what went wrong)

Then, if you looked at /var/log/vbox-install.log file, you should see the following error message.

Makefile:185: *** Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=<directory> and run Make again. Stop.

And Despite error, VirtualBox will still be installed on your machine. But again, if you try to start a virtual machine you will get the following error message.

The VirtualBox Linux kernel driver (vboxdrv) is either not loaded or there is a permission problem with /dev/vboxdrv. Please reinstall the kernel module by executing ‘/sbin/rcvboxdrv setup’

Solution : Reinstall the kernel module

As I mentioned before problem happens if you did not installed kernel-headers before install VirtualBox. But anyway, it is very easy to fix the issue. what we have to do now is Recompiling VirtualBox kernel modules. So do the following steps to fix the “unable to find the sources of your current Linux kernel” problem.

Step One

Update CentOS Linux Kernel

yum -y update kernel

Step Two

Add kernel headers and gcc Compiler

sudo yum -y install kernel-devel kernel-headers gcc

Step Three

Recompile VirtualBox kernel modules

/sbin/rcvboxdrv setup

Recompiling VirtualBox kernel modules

This solution should work for both CentOS 7 and Fedora 23. And now we should be able to start virtual machines without  Recompiling failed messages. You can also read the our complete CentOS 7 VirtualBox installation guide here.