Install Virtualbox on Ubuntu 12.10: the missing kernel module fix


I installed Virtualbox on a new 12.10 Ubuntu from the repository when I ran across a problem

$ sudo apt-get install virtualbox

At the end of the installation I was greeted with the following 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.

It turns out that ‘/etc/init.d/vboxdrv’ doesn’t exist, but I solved the problem by installing the kernel headers.

$ sudo apt-get install linux-headers-uname -r

Now you should be able to reinstall Virtualbox successfully. Strangely there is still no /etc/init.d/vboxdrv.