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
Without above three packages you will get the following error message during the installation process.
Then, if you looked at /var/log/vbox-install.log file, you should see the following error message.
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.
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.
Update CentOS Linux Kernel
yum -y update kernel
Add kernel headers and gcc Compiler
sudo yum -y install kernel-devel kernel-headers gcc
Recompile VirtualBox kernel modules
/sbin/rcvboxdrv setup
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.