I am trying to install virtualbox. I had it installed previously and it worked. Today I tried to add another virtual machine and it started complaining about problems with dkms so I tried to purge and install everything with the following failure.
$ sudo apt install virtualbox
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
dkms libgsoap-2.8.91 libqt5opengl5 libsdl1.2debian libvncserver1 virtualbox-dkms virtualbox-qt
Suggested packages:
I could not submit my question without skipping some output
Building initial module for 5.8.0-36-generic
ERROR: Cannot create report: [Errno 17] File exists: '/var/crash/virtualbox-dkms.0.crash'
Error! Bad return status for module build on kernel: 5.8.0-36-generic (x86_64)
Consult /var/lib/dkms/virtualbox/6.1.10/build/make.log for more information.
dpkg: error processing package virtualbox-dkms (--configure):
installed virtualbox-dkms package post-installation script subprocess returned error exit status 10
dpkg: dependency problems prevent configuration of virtualbox:
virtualbox depends on virtualbox-dkms (>= 6.1.10-dfsg-1~ubuntu1.20.04.1) | virtualbox-source (>= 6.1.10-dfsg-1~u
buntu1.20.04.1) | virtualbox-modules; however:
Package virtualbox-dkms is not configured yet.
Package virtualbox-source is not installed.
Package virtualbox-modules is not installed.
Package virtualbox-dkms which provides virtualbox-modules is not configured yet.
dpkg: error processing package virtualbox (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of virtualbox-qt:
virtualbox-qt depends on virtualbox (= 6.1.10-dfsg-1~ubuntu1.20.04.1); however:
Package virtualbox is not configured yet.
dpkg: error processing package virtualbox-qt (--configure):
dependency problems - leaving unconfigured
No apport report written because the error message indicates it's a follow-up error from a previous failure.
No ap
port report written because the error message indicates it's a follow-up error from a previous failure.
Processing
triggers for desktop-file-utils (0.24-1ubuntu3) ...
Processing triggers for mime-support (3.64ubuntu1) ...
Processing triggers for hicolor-icon-theme (0.17-2) ...
Processing triggers for gnome-menus (3.36.0-1ubuntu1) ...
Processing triggers for libc-bin (2.31-0ubuntu9.1) ...
Processing triggers for systemd (245.4-4ubuntu3.3) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for shared-mime-info (1.15-1) ...
Errors were encountered while processing:
virtualbox-dkms
virtualbox
virtualbox-qt
E: Sub-process /usr/bin/dpkg returned an error code (1)
$ cat /var/lib/dkms/virtualbox/6.1.10/build/make.log DKMS make.log for virtualbox-6.1.10 for kernel 5.8.0-36-generic (x86_64) Tue 12 Jan 12:40:32 GMT 2021 make: Entering directory '/usr/src/linux-headers-5.8.0-36-generic' CC [M] /var/lib/dkms/virtualbox/6.1.10/build/vboxdrv/linux/SUPDrv-linux.o
CC [M] /var/lib/dkms/virtualbox/6.1.10/build/vboxdrv/SUPDrv.o CC [M] /var/lib/dkms/virtualbox/6.1.10/build/vboxdrv/SUPDrvGip.o CC [M] /var/lib/dkms/virtualbox/6.1.10/build/vboxdrv/SUPDrvSem.o CC [M] /var/lib/dkms/virtualbox/6.1.10/build/vboxdrv/SUPDrvTracer.o CC [M] /var/lib/dkms/virtualbox/6.1.10/build/vboxdrv/SUPLibAll.o CC [M] /var/lib/dkms/virtualbox/6.1.10/build/vboxdrv/r0drv/alloc-r0drv.o CC [M] /var/lib/dkms/virtualbox/6.1.10/build/vboxdrv/r0drv/initterm-r0drv.o
CC [M] /var/lib/dkms/virtualbox/6.1.10/build/vboxdrv/r0drv/memobj-r0drv.o
CC [M] /var/lib/dkms/virtualbox/6.1.10/build/vboxdrv/r0drv/mpnotification-r0drv.o CC [M] /var/lib/dkms/virtualbox/6.1.10/build/vboxdrv/r0drv/powernotification-r0drv.o CC [M] /var/lib/dkms/virtualbox/6.1.10/build/vboxdrv/r0drv/linux/assert-r0drv-linux.o In file included from ./include/asm-generic/percpu.h:7, from ./arch/x86/include/asm/percpu.h:556, from ./arch/x86/include/asm/preempt.h:6, from ./include/linux/preempt.h:78, from ./include/linux/spinlock.h:51, from /var/lib/dkms/virtualbox/6.1.10/build/vboxdrv/linux/../SUPDrvInternal.h:79, from /var/lib/dkms/virtualbox/6.1.10/build/vboxdrv/linux/SUPDrv-linux.c:32: /var/lib/dkms/virtualbox/6.1.10/build/vboxdrv/linux/SUPDrv-linux.c: In function ‘supdrvOSChangeCR4’: /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] Error 1 make[2]: *** Waiting for unfinished jobs.... make[1]: *** [scripts/Makefile.build:519: /var/lib/dkms/virtualbox/6.1.10/build/vboxdrv] Error 2 make: *** [Makefile:1780: /var/lib/dkms/virtualbox/6.1.10/build] Error 2 make: Leaving directory '/usr/src/linux-headers-5.8.0-36-generic'
Had the same issue But finally got it fixed!!!
By removing Virtualbox completely and reinstalling it.
Tried downgarding the kernel but that did'nt work for me
$sudo apt-get purge "^virtualbox-.*"
$sudo apt-get autoremove && sudo apt-get autoclean && sudo apt-get clean
Then download the latest virtualbox version from this link for ubuntu 20.04
https://www.virtualbox.org/wiki/Linux_Downloads
I tried many other solutions,none worked for me.