Error installing virtualbox-dkms on Ubuntu 20 [duplicate]

Ubuntu 20.04. I installed virtualbox using package; it worked, I created and ran a RM. But then stopped to work after software update. I cannot run the VMs, message says :

Kernel driver not installed (rc=-1908)

The VirtualBox Linux kernel driver is either not loaded or not set up correctly. 
Please reinstall virtualbox-dkms package and load the kernel module by executing

'modprobe vboxdrv'

as root.

I managed to disable secure boot, so this is not related to this.

Now I try to reinstall virtualbox-dkms package as requested :

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

But then I get the following error :

Préparation du dépaquetage de .../virtualbox-dkms_6.1.10-dfsg-1~ubuntu1.20.04.1_amd64.deb ...
Dépaquetage de virtualbox-dkms (6.1.10-dfsg-1~ubuntu1.20.04.1) ...
Paramétrage de virtualbox-dkms (6.1.10-dfsg-1~ubuntu1.20.04.1) ...
Loading new virtualbox-6.1.10 DKMS files...
Building for 5.8.0-34-generic
Building initial module for 5.8.0-34-generic
Error! Bad return status for module build on kernel: 5.8.0-34-generic (x86_64)
Consult /var/lib/dkms/virtualbox/6.1.10/build/make.log for more information.
dpkg: erreur de traitement du paquet virtualbox-dkms (--configure) :
 installed virtualbox-dkms package post-installation script subprocess returned error exit status 10
Des erreurs ont été rencontrées pendant l'exécution :
 virtualbox-dkms
E: Sub-process /usr/bin/dpkg returned an error code (1)

If I look at /var/lib/dkms/virtualbox/6.1.10/build/make.log I see :

/var/lib/dkms/virtualbox/6.1.10/build/vboxdrv/linux/SUPDrv-linux.c:760:38: error: ‘cpu_tlbstate’ undeclared (first use in this function); did you mean ‘cpuhp_state’?
  760 |     RTCCUINTREG uOld = this_cpu_read(cpu_tlbstate.cr4);
      |                                      ^~~~~~~~~~~~
./include/linux/percpu-defs.h:318:9: note: in definition of macro ‘__pcpu_size_call_return’
  318 |  typeof(variable) pscr_ret__;     \
      |         ^~~~~~~~
/var/lib/dkms/virtualbox/6.1.10/build/vboxdrv/linux/SUPDrv-linux.c:760:24: note: in expansion of macro ‘this_cpu_read’
  760 |     RTCCUINTREG uOld = this_cpu_read(cpu_tlbstate.cr4);
      |                        ^~~~~~~~~~~~~
/var/lib/dkms/virtualbox/6.1.10/build/vboxdrv/linux/SUPDrv-linux.c:760:38: note: each undeclared identifier is reported only once for each function it appears in
  760 |     RTCCUINTREG uOld = this_cpu_read(cpu_tlbstate.cr4);
      |                                      ^~~~~~~~~~~~
./include/linux/percpu-defs.h:318:9: note: in definition of macro ‘__pcpu_size_call_return’
  318 |  typeof(variable) pscr_ret__;     \
      |         ^~~~~~~~
/var/lib/dkms/virtualbox/6.1.10/build/vboxdrv/linux/SUPDrv-linux.c:760:24: note: in expansion of macro ‘this_cpu_read’
  760 |     RTCCUINTREG uOld = this_cpu_read(cpu_tlbstate.cr4);
      |                        ^~~~~~~~~~~~~
make[2]: *** [scripts/Makefile.build:290 : /var/lib/dkms/virtualbox/6.1.10/build/vboxdrv/linux/SUPDrv-linux.o] Erreur 1
make[2]: *** Attente des tâches non terminées....
make[1]: *** [scripts/Makefile.build:519 : /var/lib/dkms/virtualbox/6.1.10/build/vboxdrv] Erreur 2

What I am missing ?


Solution 1:

That is a bug with the 5.8 kernel and Virtualbox version 6.1.10 https://bugs.launchpad.net/ubuntu/+source/virtualbox/+bug/1891916

However, you can install Virtualbox version 6.1.16 from Virtualbox themselves that does work with kernel 5.8 and will stay updated. https://www.virtualbox.org/wiki/Linux_Downloads

From the instructions:

Add the Repo:

echo "deb [arch=amd64] https://download.virtualbox.org/virtualbox/debian $(lsb_release -sc) contrib" | sudo tee /etc/apt/sources.list.d/virtualbox.list

Install the key:

wget https://www.virtualbox.org/download/oracle_vbox_2016.asc
sudo apt-key add oracle_vbox_2016.asc

Update your repos:

sudo apt update

Install Virtualbox 6.1

sudo apt install virtualbox-6.1

Hope this helps!