One of the ways Secure Boot maintains system security is by only allowing trusted kernel extensions to load. You must intervene if you want to run third-party modules like the VirtualBox Kernel Driver (vboxdrv).
On macOS, this is very easy to do as you can allow the module to load from System Preferences.
On Linux systems, you should ensure the kernel and GCC versions are compatible with the vboxdrv module. You can also manually sign the module using mokutil.
If such methods fail or you don’t care about Secure Boot, you can always disable Secure Boot to resolve this error.
How to Fix This Error on MacOS
Allow Module to Load
Users must manually allow the loading of kernel extensions (KEXTs) on macOS 10.13 and newer versions. To do this,
- Click on the Apple Menu and go to System Preferences > Security & Privacy.
- Press the Allow button towards the bottom.
Restart VirtualBoxStartup Service
Use the following one-liner in the terminal to restart the startup service for loading the kernel module.
sudo /Library/Application\ Support/VirtualBox/LaunchDaemons/VirtualBoxStartup.sh restart
Repeat the steps from the previous section and reboot. Then, check if you can start your VM in VirtualBox.
Register the vboxdrv Module
Registering the VirtualBox kernel extension directly via the terminal can also help. Enter the following one-liner in the terminal to do this:
sudo kmutil load -p '/Library/Application Support/VirtualBox/VBoxDrv.kext'
Reboot and check if you can launch the VM now.
Approve Oracle’s Dev ID
If manually loading vboxdrv doesn’t work, add Oracle’s developer ID to the security assessment policy. This will allow programs from Oracle (i.e. VirtualBox) to access the kernel.
Enter the following command in the terminal to do this:
spctl kext-consent add VB5E2TV963
Also, try the same in Recovery Mode.
- Restart your Mac and hold Command + R to boot into recovery mode.
- Click on Utilities and select the Terminal.
- Add the dev ID like so:
spctl kext-consent add VB5E2TV963
- Restart your Mac and check if the VM works now.
Install VirtualBox Extension Pack
The VirtualBox Extension Pack is usually installed to add extra functionality like virtual USB 3.0 devices. In this case, installing it is worth it as that can potentially resolve the kernel driver issue.
- First, download the extension pack from the VirtualBox downloads page.
- Launch VirtualBox and select Tools > Extensions.
- Click on the Install button and open the extension pack.
Flush Kernel Extension Cache
Use the following command in the terminal to clear the kernel extension cache:
sudo kextcache --clear-staging
Check if the VM works now. If it doesn’t, restart your Mac and try the command once more.
Try Another VirtualBox Version
Reinstalling VirtualBox is one of the most effective ways to resolve this error. Specifically, try different versions of VirtualBox (the latest one, as well as older stable versions). To do this,
- Open the VirtualBox installation file and click on
VirtualBox_uninstall.tool
. - Enter Yes to confirm that you want to uninstall VirtualBox and all its packages.
- Restart your Mac. Now, download and install the latest VirtualBox version.
- If this version doesn’t work, repeat the steps to remove VirtualBox and try a different version.
Set Kernel Extension Flag Correctly
If the restricted flag is not set against KernelExtensionManagement, this will affect how System Integrity Protection (SIP) interacts with directories. This can ultimately lead to the VirtualBox Kernel Driver Not Installed error. To resolve this:
- Uninstall Virtualbox.
- Restart your Mac and hold Command + R to boot into recovery mode.
- Select Utilities > Terminal and enter the following command:
chflags restricted /Volumes/Macintosh\ HD/private/var/db/KernelExtensionManagement
- Restart your Mac, reinstall VirtualBox, and check if you can launch the VM now.
Disable Secure Boot
If nothing else works, you can disable Secure Boot as the last resort. With Secure Boot disabled, you’ll have no problems loading unsigned KEXTs like vboxdrv. To do this:
- Boot into recovery mode again (hold Command + R while turning on your Mac).
- Select Utilities > Startup Security Utility.
- In the Secure Boot window, select No Security.
- Restart your Mac and check if VirtualBox works now.
How to Fix This Error on Linux
I’ll provide commands for Debian-based distros for demonstration. Remember to modify the commands (like apt
to dnf
) according to your distro.
Restart your PC
Linux distros frequently receive minor kernel updates, which can lead to incompatibility between vboxdrv and the updated kernel. Rebooting your PC is often the easiest way to resolve this problem.
Resolve Kernel Version Problems
Sometimes, there won’t be a vboxdrv version compatible with the latest kernel. Other times, you’ll have to manually install the headers and install VirtualBox afterward. You’ll encounter the error unless you do this in this specific order.
To resolve such problems, first try reinstalling VirtualBox and the kernel headers:
sudo apt purge virtualbox dkms linux-headers-$(uname -r)
sudo apt install linux-headers-$(uname -r)
sudo apt install virtualbox
If the error persists, reinstall the vboxdrv kernel module. Then, reconfigure the VirtualBox package and load the module like so:
sudo /etc/init.d/vboxdrv setup
sudo dpkg-reconfigure virtualbox-dkms
sudo modprobe vboxdrv
Roll Back Kernel
Oracle may take a little while to release a vboxdrv version compatible with the latest kernel version. This is especially likely if you’re running a custom or obscure kernel.
In such cases, you can try rolling back to an older supported kernel version to resolve this error.
Download the kernel files from your distro’s kernel archive and install them. After rebooting with the newly installed kernel, the error should be resolved.
Change GCC Version
Users also face this error because the current GCC version is different from the one that was used to compile the module. In such cases, switching to the same compiler should resolve the problem.
For instance, to change the GCC version to GCC 8:
- First, remove VirtualBox and its config files with the following command:
sudo apt purge virtualbox
- Install the GCC version you want (8 in this case):
sudo apt install gcc-8 g++-8
- Set the default GCC to GCC 8:
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 800 --slave /usr/bin/g++ g++ /usr/bin/g++-8
- Finally, reinstall VirtualBox and check if the issue is resolved.
sudo apt install virtualbox
Fix Module Signature Issues
DKMS modules are generally configured at installation to work with Secure Boot. But sometimes modules won’t be allowed to load due to signature issues.
In such cases, you can sign the modules yourself using the mokutil tool. I recommend checking this GitHub post by reillysiemens as it covers this process in detail.
Turn Off Secure Boot
The main problem with manually signing modules is that you have to resign them after each kernel update. And kernel updates on Linux are very frequent. So, my preferred solution is to simply disable secure boot:
- Execute the
sudo mokutil --disable-validation
command. - Enter a temporary password and confirm it.
- Reboot your system and press any key on the MOK Management screen.
- Select Change Secure Boot State. Enter the specified character of the temporary password (e.g., 7th character).
- Select Yes > OK to disable Secure Boot.
sudo mokutil --enable-validation
to re-enable Secure Boot later if you want.