How do I fix a vboxdrv setup failure in VirtualBox?

So, I tried creating an OS with VirtualBox, and I got this error:

Kernel driver not installed (rc=-1908)

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

'/etc/init.d/vboxdrv setup'

as root. If it is available in your distribution, you should install the DKMS package first. This package keeps track of Linux kernel changes and recompiles the vboxdrv kernel module if necessary.

So I did the obvious, running the Vboxdrv setup. I ran this command:

sudo service vboxdrv setup

I got an error while doing so.:

stopping kernel drivers...done.

Uninstalling old virtualbox dkms kernel modules/etc/init.d/voboxdrv: 302: /etc/init.d/vboxdrv: /usr/share/virtualbox/src/vboxhost/do_dkms: not found
...done.
(Failed, trying without DKMS)
recompiling VirtualBox kernel modules...failed!
(look at /var/log/vbox-install.log to find out what went wrong.)

So, I took a look at /var/log/vbox-install.log to see if I can find anything. I got this error:

/etc/init.d/vboxdrv: 334: /etc/init.d/vboxdrv: /usr/share/virtualbox/src/vboxhost/build_in_tmp: not found

Any help? Thanks.


Solution 1:

Finally got this working. Looks like DKMS is not working as it should(?). After reinstalling virtualbox-dkms, my VMs are back up.

sudo apt-get --reinstall install virtualbox-dkms

Solution 2:

I would suggest the following:

First, ensure that you have the headers and other required elements to build programs. Open a terminal window ctrl+alt+t

sudo apt-get install build-essential libssl-dev linux-headers-`uname -r`

Secondly, install the dkms module so that you do not face this problem after kernel updates

sudo apt-get install dkms

Finally, try the command as suggested by the first error message

sudo -i
/etc/init.d/vboxdrv setup
exit

Solution 3:

Use "All distributions - run Installer" (bottommost entry of this list) instead of a deb or rpm package! This fixed the error for me (Ubuntu 14.10 + VirtualBox 4.3.26).

Solution 4:

After trying @Crusty_Barnacle and @Charles_Green solutions without success, I made sure my distro (Ubuntu 14.04) was fully up-to-date then did:

aptitude purge virtualbox virtualbox-dkms virtualbox-qt
aptitude install virtualbox

And everything worked fine again.

Hope this may help others.