I needed to install Virtual Box on Kali Linux for training purposes. It provides a possibility to create pentesting labs. But I faced a problem that a virtual machine didn’t want to start and complained about missing vboxdrv. Here I will describe the way how to resolve missing vboxdrv on Kali Linux by installing linux-headers.
First – install virtual box using this instruction from Kali – https://www.kali.org/docs/virtualization/install-virtualbox-host/
Then create a virtual instance and try to run it. Hopefully, everything will go well and you will just enjoy the virtual box.
But that was not my case. I got an error telling me that there is no vboxdrv driver on my machine.
I tried
modprobe vboxdrv
and got
modprobe: fatal: module vboxdrv not found in directory /lib/modules/5.10.0-kali9-amd64
All the internet says that I need to install linux-headers for my version of Kali Linux using this command
sudo apt install linux-headers-$(uname -r)
But in my case it returns (since my uname -r = 5.10.0-kali9-amd64):
E: Unable to locate package linux-headers-5.10.0-kali9-amd64
E: Couldn't find any package by glob 'linux-headers-5.10.0-kali9-amd64'
Install linux-headers
So the solution is to install the linux-headers manually.
The first thing we need is to know what version of linux-headers you need. You can do it using this command:
echo linux-headers-$(uname -r)
In my case the result is
linux-headers-5.10.0-kali9-amd64
Now you need to download the .deb package of your version of linux-headers. There is a mirror with all the versions: http://mirror.internode.on.net/pub/kali/pool/main/l/linux/. You can use page search to find your version – select the latest one if there is more than one.
Try to install it. Most likely you will not be able to do this as the installation will ask for the dependencies it cannot resolve. Read it carefully – the packages you need are downloadable from the same mirror.
So let’s try to install your version of linux-headers. Note that your path to file and the file name can be different from mine
dpkg -i Downloads/linux-headers-5.10.0-kali9-amd64_5.10.46-4kali1_amd64.deb
I got an error that said that I need these dependencies:
dpkg: dependency problems prevent configuration of linux-headers-5.10.0-kali9-amd64:
linux-headers-5.10.0-kali9-amd64 depends on linux-headers-5.10.0-kali9-common (= 5.10.46-4kali1); however:
Package linux-headers-5.10.0-kali9-common is not installed.
linux-headers-5.10.0-kali9-amd64 depends on linux-kbuild-5.10 (>= 5.10.46-4kali1); however:
Package linux-kbuild-5.10 is not installed.
Download the packages from the same mirror (same – download the latest version if there are many of them) and install them:
dpkg -i Downloads/linux-headers-5.10.0-kali9-common_5.10.46-4kali1_all.deb
dpkg -i Downloads/linux-kbuild-5.10_5.10.46-4kali1_amd64.deb
And then finally install your version of linux-headers:
dpkg -i Downloads/linux-headers-5.10.0-kali9-amd64_5.10.46-4kali1_amd64.deb
Now it should be installed without errors and you will be able to run virtual instances in Virtual Box.