Virtualbox vboxdrv kernel module not loaded

I installed Virtualbox version 6.1.26 on Fedora 34. according to this tutorial here https://computingforgeeks.com/how-to-install-virtualbox-on-fedora-linux/

When I now try to start a VM I get the following error:

WARNING: The vboxdrv kernel module is not loaded. Either there is no module
         available for the current kernel (5.13.14-200.fc34.x86_64) or it failed to
         load. Please recompile the kernel module and install it by

           sudo /sbin/vboxconfig

         You will not be able to start VMs until this problem is fixed.

I checked the BIOS and there Secureboot is disabled. When I run ‘/sbin/vboxconfig’ I get the following output:

vboxdrv.sh: Stopping VirtualBox services.
vboxdrv.sh: Starting VirtualBox services.
vboxdrv.sh: You must sign these kernel modules before using VirtualBox:
  vboxdrv vboxnetflt vboxnetadp
See the documentation for your Linux distribution..
vboxdrv.sh: Building VirtualBox kernel modules.
vboxdrv.sh: failed: modprobe vboxdrv failed. Please use 'dmesg' to find out why.

There were problems setting up VirtualBox.  To re-start the set-up process, run
  /sbin/vboxconfig
as root.  If your system is using EFI Secure Boot you may need to sign the
kernel modules (vboxdrv, vboxnetflt, vboxnetadp, vboxpci) before you can load
them. Please see your Linux system's documentation for more information.
$ systemctl status vboxdrv.service
× vboxdrv.service - VirtualBox Linux kernel module
     Loaded: loaded (/usr/lib/virtualbox/vboxdrv.sh; enabled; vendor preset: disabled)
     Active: failed (Result: exit-code) since Mon 2021-09-13 11:38:40 CEST; 10min ago
        CPU: 1min 8.761s

Sep 13 11:38:11 fedora vboxdrv.sh[21166]: vboxdrv.sh: You must sign these kernel modules before using VirtualBox:
Sep 13 11:38:11 fedora vboxdrv.sh[21166]:   vboxdrv vboxnetflt vboxnetadp
Sep 13 11:38:11 fedora vboxdrv.sh[21166]: See the documentation for your Linux distribution..
Sep 13 11:38:11 fedora vboxdrv.sh[21166]: vboxdrv.sh: Building VirtualBox kernel modules.
Sep 13 11:38:11 fedora vboxdrv.sh[21210]: Building VirtualBox kernel modules.
Sep 13 11:38:40 fedora vboxdrv.sh[21166]: vboxdrv.sh: failed: modprobe vboxdrv failed. Please use 'dmesg' to find out why.
Sep 13 11:38:40 fedora systemd[1]: vboxdrv.service: Control process exited, code=exited, status=1/FAILURE
Sep 13 11:38:40 fedora systemd[1]: vboxdrv.service: Failed with result 'exit-code'.
Sep 13 11:38:40 fedora systemd[1]: Failed to start VirtualBox Linux kernel module.
Sep 13 11:38:40 fedora systemd[1]: vboxdrv.service: Consumed 1min 8.761s CPU time.

Is there anything else I could do to get Virtualbox working?

2 Likes

Thank you @vgaetera for the recommendation. I’m however quite used to Virtualbox and would prefer to keep using it also I have it running on another machine although the other one is still on Fedora 33.

You might, just possibly, be able to get virtualbox to work by disabling secure boot in the bios. It was the solution for me.

The clue there is the complaint about unsigned modules.

Even though I disabled secureboot in the BIOS, it was still active. Additionally to disabling secureboot in the BIOS I had to boot from the HD where Fedora is installed in legacy mode. now Virtualbox works and I can use the VMs. Thanks!

Vladislav is correct. Fedora focuses on GNOME Boxes for virtualization.

However, you should be able to get Virtual Box running on Fedora. I don’t have experience with it on Fedora, though.

Related… On Ubuntu, you install the linux kernel headers, and then build the Vritual Box driver through dkms. In fact, once the headers are installed, you run sudo apt install virtualbox-dkms and the driver is downloaded and built for you automatically.

You dont have to turn off secure boot, just sign the virtuabox-modules, here a short walkthrough for F34:

  1. Enroll certificates as root:

openssl req -new -x509 -newkey rsa:2048
-nodes -days 36500 -outform DER
-keyout “MOK.priv”
-out “MOK.der”

  1. Import certificates as root (you will have to reboot afterwards):

mokutil --import MOK.der

  1. After installing or upgrading virtualbox, sign the modules and reload them as root, i created the script /usr/local/bin/signmodules:

#!/bin/sh

readonly hash_algo=‘sha256’
readonly key=’/root/MOK.priv’
readonly x509=’/root/MOK.der’

readonly name="$(basename $0)"
readonly esc=’\e’
readonly reset="${esc}[0m"

green() { local string="${1}"; echo “${esc}[32m${string}${reset}”; }
blue() { local string="${1}"; echo “${esc}[34m${string}${reset}”; }
log() { local string="${1}"; echo “[$(blue $name)] ${string}”; }

alias sign-file="/usr/src/kernels/$(uname -r)/scripts/sign-file"

[ -z “${KBUILD_SIGN_PIN}” ] && read -p "Passphrase for ${key}: " KBUILD_SIGN_PIN
export KBUILD_SIGN_PIN

sign-file “${hash_algo}” “${key}” “${x509}” “/lib/modules/$(uname -r)/extra/VirtualBox/vboxdrv.ko”
sign-file “${hash_algo}” “${key}” “${x509}” “/lib/modules/$(uname -r)/extra/VirtualBox/vboxnetflt.ko”
sign-file “${hash_algo}” “${key}” “${x509}” “/lib/modules/$(uname -r)/extra/VirtualBox/vboxnetadp.ko”

modprobe vboxdrv
modprobe vboxnetflt
modprobe vboxnetadp

lsmod | grep vbox

  1. the output should be:

lsmod | grep vbox
vboxnetadp 28672 0
vboxnetflt 32768 1
vboxdrv 561152 3 vboxnetadp,vboxnetflt

  1. enjoy
2 Likes

Thanks I’ll give this a try.