After the latest Ubuntu updates, I have not been able to open virtualbox, on starting it gives me an error saying the kernel driver is either not loaded or set up properly and that I should reinstall virtualbox-dkms package.

After removing virtualbox, and trying to reinstall I get the error below:

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-34-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~ubuntu1.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 apport report written because the error message indicates it's a follow-up error from a previous failure.
                                                        Processing triggers for menu (2.1.47ubuntu4) ...
Processing triggers for bamfdaemon (0.5.3+18.04.20180207.2-0ubuntu2) ...
Rebuilding /usr/share/applications/bamf-2.index...
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 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)

This happens even when I boot from the previous kernel using the grub menu, any help would be very appreciated.

I have also tried to use aptitude to remove any conflicting versions of virtualbox from other repositories but still the same issue.


Solution 1:

It happened because Ubuntu 20.04 upgraded kernel to 5.8, but the 6.1.10 version of VirtualBox that you installed from Ubuntu repositories doesn't support this kernel.

You have two options:

  1. Remove the existing VirtualBox using apt remove virtualbox and install VirtualBox 6.1.16 from https://virtualbox.org.

  2. Remove the 5.8 kernel and stick with the 5.4.0-xx kernels.

The first option is easier and preferable IMHO.

Solution 2:

A third solution worked for me: download and install the VirtualBox release for All distributions. (See VirtualBox download page).

  • Download latest release (currently 6.1.16) for All distribution from VirtualBox download page.
wget -O ~/Downloads/virtualbox.run https://download.virtualbox.org/virtualbox/6.1.16/VirtualBox-6.1.16-140961-Linux_amd64.run
  • Install VirtualBox
cd Downloads               # enter Downloads
chmod +x virtualbox.run    # set execution permission
./virtualbox.run           # run the installer

Note: before re-installing VirtualBox I removed my previous installation with apt purge.

Solution 3:

The Ubuntu 20.04 repos have been updated with vbox 6.1.16. I noticed this on Jan 25 but don't know when they were updated. Vbox builds and opens correctly now.