1

I was running Virtualbox happily on an Ubuntu 22.04 box. After a recent update (there have been several, I don't know which one broke it) virtualbox would not start, complaining the necessary kernel module was not loaded.

The kernel module was not present. I uninstalled virtualbox*, purged it and its dependencies, and tried reinstalling. This fails consistently at building the Kernel module.

Any ideas?

virtualbox-6.1.34, kernel 5.15.0-47-generic, gcc (Ubuntu 10.3.0-15ubuntu1) 10.3.0.

gcc-11 (Ubuntu 11.2.0-19ubuntu1) 11.2.0 is installed and active, but not the default gcc.

The installation log:

Setting up virtualbox-dkms (6.1.34-dfsg-3~ubuntu1.22.04.1) ...
Loading new virtualbox-6.1.34 DKMS files...
Building for 5.15.0-47-generic
Building initial module for 5.15.0-47-generic
Error! Bad return status for module build on kernel: 5.15.0-47-generic (x86_64)
Consult /var/lib/dkms/virtualbox/6.1.34/build/make.log for more information.

The contents of make.log:

DKMS make.log for virtualbox-6.1.34 for kernel 5.15.0-47-generic (x86_64)
wo 14 sep 2022 11:36:34 CEST
make: Entering directory '/usr/src/linux-headers-5.15.0-47-generic'
warning: the compiler differs from the one used to build the kernel
  The kernel was built by: gcc (Ubuntu 11.2.0-19ubuntu1) 11.2.0
  You are using:           gcc (Ubuntu 10.3.0-15ubuntu1) 10.3.0
  CC [M]  /var/lib/dkms/virtualbox/6.1.34/build/vboxdrv/linux/SUPDrv-linux.o
  CC [M]  /var/lib/dkms/virtualbox/6.1.34/build/vboxdrv/SUPDrv.o
  CC [M]  /var/lib/dkms/virtualbox/6.1.34/build/vboxdrv/SUPDrvGip.o
  CC [M]  /var/lib/dkms/virtualbox/6.1.34/build/vboxdrv/SUPDrvSem.o
  CC [M]  /var/lib/dkms/virtualbox/6.1.34/build/vboxdrv/SUPDrvTracer.o
  CC [M]  /var/lib/dkms/virtualbox/6.1.34/build/vboxdrv/SUPLibAll.o
  CC [M]  /var/lib/dkms/virtualbox/6.1.34/build/vboxdrv/r0drv/alloc-r0drv.o
  CC [M]  /var/lib/dkms/virtualbox/6.1.34/build/vboxdrv/r0drv/initterm-r0drv.o
  CC [M]  /var/lib/dkms/virtualbox/6.1.34/build/vboxdrv/r0drv/memobj-r0drv.o
  CC [M]  /var/lib/dkms/virtualbox/6.1.34/build/vboxdrv/r0drv/mpnotification-r0drv.o
gcc: error: unrecognized command-line option ‘-mharden-sls=all’
  CC [M]  /var/lib/dkms/virtualbox/6.1.34/build/vboxdrv/r0drv/powernotification-r0drv.o
make[2]: *** [scripts/Makefile.build:297: /var/lib/dkms/virtualbox/6.1.34/build/vboxdrv/linux/SUPDrv-linux.o] Error 1
make[2]: *** Waiting for unfinished jobs....
gcc: error: unrecognized command-line option ‘-mharden-sls=all’
make[2]: *** [scripts/Makefile.build:297: /var/lib/dkms/virtualbox/6.1.34/build/vboxdrv/SUPDrv.o] Error 1
gcc: error: unrecognized command-line option ‘-mharden-sls=all’
make[2]: *** [scripts/Makefile.build:297: /var/lib/dkms/virtualbox/6.1.34/build/vboxdrv/SUPDrvSem.o] Error 1
gcc: error: unrecognized command-line option ‘-mharden-sls=all’
make[2]: *** [scripts/Makefile.build:297: /var/lib/dkms/virtualbox/6.1.34/build/vboxdrv/SUPLibAll.o] Error 1
gcc: error: unrecognized command-line option ‘-mharden-sls=all’
make[2]: *** [scripts/Makefile.build:297: /var/lib/dkms/virtualbox/6.1.34/build/vboxdrv/SUPDrvGip.o] Error 1
gcc: error: unrecognized command-line option ‘-mharden-sls=all’
make[2]: *** [scripts/Makefile.build:297: /var/lib/dkms/virtualbox/6.1.34/build/vboxdrv/SUPDrvTracer.o] Error 1
gcc: error: unrecognized command-line option ‘-mharden-sls=all’
gcc: error: unrecognized command-line option ‘-mharden-sls=all’
gcc: error: unrecognized command-line option ‘-mharden-sls=all’
make[2]: *** [scripts/Makefile.build:297: /var/lib/dkms/virtualbox/6.1.34/build/vboxdrv/r0drv/powernotification-r0drv.o] Error 1
make[2]: *** [scripts/Makefile.build:297: /var/lib/dkms/virtualbox/6.1.34/build/vboxdrv/r0drv/alloc-r0drv.o] Error 1
make[2]: *** [scripts/Makefile.build:297: /var/lib/dkms/virtualbox/6.1.34/build/vboxdrv/r0drv/initterm-r0drv.o] Error 1
gcc: error: unrecognized command-line option ‘-mharden-sls=all’
gcc: error: unrecognized command-line option ‘-mharden-sls=all’
make[2]: *** [scripts/Makefile.build:297: /var/lib/dkms/virtualbox/6.1.34/build/vboxdrv/r0drv/memobj-r0drv.o] Error 1
make[2]: *** [scripts/Makefile.build:297: /var/lib/dkms/virtualbox/6.1.34/build/vboxdrv/r0drv/mpnotification-r0drv.o] Error 1
make[1]: *** [scripts/Makefile.build:560: /var/lib/dkms/virtualbox/6.1.34/build/vboxdrv] Error 2
make: *** [Makefile:1881: /var/lib/dkms/virtualbox/6.1.34/build] Error 2
make: Leaving directory '/usr/src/linux-headers-5.15.0-47-generic'
EvertW
  • 131

3 Answers3

3

I also had the similar problem: after Ubuntu kernel upgrade to 6.1.0-1015-oem, my virtual machines could not start with the following error: VirtualBox Kernel driver not installed (rc=1908) with result code:

ns_error_failure (0x80004005)

It turned out to be due to inconsistent upgrade of Ubuntu kernel, namely the linux-header files that virtualbox-dkms installation use to build appropriate VirtualBox Linux kernel files were missing after Linux kernel version upgrade. So this is how I fixed my problem (use sudo where needed):

  1. Check your current Ubuntu kernel version:

    uname -r
    
  2. Check if there are linux header files for your kernel version

    apt search linux-headers-$(uname -r)
    
  3. And if there are some files already in the appropriate location:

    ls -l /usr/src/linux-headers-$(uname -r)
    

    (expected: "cannot access", because there are no files currently - so they should be installed)

  4. Apply these commands:

    sudo apt update && sudo apt install linux-headers-$(uname -r)
    

    Now the same command from 3. should return the list of header files

  5. Reinstall virtualbox-dkms, so virtualbox kernel driver files can be built during installation process:

    sudo apt remove virtualbox-dkms
    sudo apt install virtualbox-dkms
    

After these commands were executed, I was able to use VirtualBox machines again!!

1

The problem is that your /usr/bin/gcc does not point to the default gcc compiler, but to an older one. The build script uses the generic gcc compiler, even though it is not compatible with any compiler older than gcc-11. It would have been better for the build script to explicitly use gcc-11.

To solve the issue, let /usr/bin/gcc point to /usr/bin/gcc-11.

EvertW
  • 131
0

I was running Virtualbox happily on an Ubuntu 22.04 box. After a recent update (there have been several, I don't know which one broke it) virtualbox would not start, complaining the necessary kernel module was not loaded.

I had the exact same issue. In my case, virtualbox was complaining that the modules were not signed. I don't have secure boot enabled (triple checked), so that wasn't the issue.

I tried reinstalling virtualbox with apt, from the official deb, an older deb (virtualbox 6.1.36, instead of 6.1.38, which is the latest), a prerelease version (as @Rishon JR suggested), nothing worked.

I then thought that maybe there are some incompatibilities with the kernel version. I too, as you, had the kernel version 5.15.0-47-generic.

How I fixed it

I downgraded my kernel version to 5.10.133-0510133-generic using mainline: see this answer. I installed it from PPA.

You'll need to reboot your PC and select Start Linux with kernel version 5.10.x from Advanced Options. Don't delete your 5.15.x version yet, to make sure you didn't break anything.

Then, I installed Virtualbox from Oracle's repositories: details here. Add the keys and sources.list, and apt purge the old virtualbox, do an apt update and apt install virtualbox.

This solved the issue for me.

If you're satisfied with the results you can remove the 5.15.x kernel or edit grub so the system will boot by default with the 5.10.x kernel. The steps to edit your default grub entry are explained here

Hope it helps!