On my Ubuntu 20.04 system (upgraded from 18.04), every time a new kernel is installed and used, Virtualbox stops working.
It gives a messages "Kernel driver not installed (rc=-1908) ... please try setting it up again by executing /sbin/vboxconfig as root
But running vboxconfig gives an output like this:
vboxdrv.sh: Stopping VirtualBox services.
depmod: WARNING: could not open modules.order at /lib/modules/5.4.166: No such file or directory
depmod: WARNING: could not open modules.builtin at /lib/modules/5.4.166: No such file or directory
vboxdrv.sh: Starting VirtualBox services.
vboxdrv.sh: Building VirtualBox kernel modules.
At main.c:271:
- SSL error:02001002:system library:fopen:No such file or directory: ../crypto/bio/bss_file.c:69
- SSL error:2006D080:BIO routines:BIO_new_file:no such file: ../crypto/bio/bss_file.c:76
kmodsign: /lib/modules/5.4.0-104-generic/misc/vboxdrv.ko.~signed~: No such file or directory
At main.c:271:
- SSL error:02001002:system library:fopen:No such file or directory: ../crypto/bio/bss_file.c:69
- SSL error:2006D080:BIO routines:BIO_new_file:no such file: ../crypto/bio/bss_file.c:76
kmodsign: /lib/modules/5.4.0-104-generic/misc/vboxnetflt.ko.~signed~: No such file or directory
At main.c:271:
- SSL error:02001002:system library:fopen:No such file or directory: ../crypto/bio/bss_file.c:69
- SSL error:2006D080:BIO routines:BIO_new_file:no such file: ../crypto/bio/bss_file.c:76
kmodsign: /lib/modules/5.4.0-104-generic/misc/vboxnetadp.ko.~signed~: No such file or directory
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.
As too often with computers, the error message will not really help you understand how to overcome the problem. But there's a clue, it says it's looking for modules.order in "/lib/modules/5.4.166", and that file location doesn't exist.
For whatever reason, Virtualbox install script is looking for the kernel modules in /lib/modules/; whereas Ubuntu places them in /lib/modules/. The fix is simple, determine both numbers and make a symlink from the location vboxconfig is expecting to the location where Ubuntu packages actually left them.
UBUNTUVER=$(uname -r)
RELEASEVER=$(< /usr/src/linux-headers-$UBUNTUVER/include/config/kernel.release)
# Show the contents of these variables
root@ubuntu# echo $UBUNTUVER
5.4.0-104-generic
root@ubuntu# echo $RELEASEVER
5.4.166
# now check the the contents of each folder, should look similar to this:
root@ubuntu:~# cd /lib/modules/
root@ubuntu:/lib/modules# ls $UBUNTUVER
build modules.builtin.alias.bin modules.order
initrd modules.builtin.bin modules.softdep
kernel modules.builtin.modinfo modules.symbols
modules.alias modules.dep modules.symbols.bin
modules.alias.bin modules.dep.bin updates
modules.builtin modules.devname vdso
root@sterling:/lib/modules# ls $RELEASEVER
misc
Well, actually the folder 5.4.166 (RELEASEVER) is not empty, but if you have a look a the timestamps, you'll see these files were created at the moment you ran vboxconfig, so move this folder out of the way, and create a symlink from the $RELEASEVER to the $UBUNTUVER:
mv $RELEASEVER ${RELEASEVER}_backup
ln -s $UBUNTUVER $RELEASEVER
ls -l $RELEASEVER
lrwxrwxrwx 1 root root 17 mrt 15 09:01 5.4.166 -> 5.4.0-104-generic
Now run /sbin/vboxconfig again, it should finish successfully and you can use VirtualBox again... until next kernel update at least.