How To Fix Upgrading Ubuntu Repositories VirtualBox To Oracle-Provided VirtualBox

VirtualBox driver error

When I upgraded to Ubuntu 19.10 I installed VirtualBox from the Ubuntu repositories since it was the same version as the one provided by Oracle anyway. But when I upgraded to VirtualBox 6.1 downloaded from the Oracle VirtualBox website, I noticed I couldn't start any virtual machine anymore, receiving an error.

This article explains how to properly upgrade to VirtualBox downloaded from Oracle (either by downloading it from the VirtualBox website, or installed from the Oracle VirtualBox repository) when you have the Ubuntu repositories version of VirtualBox installed on your system. This also applies to those using Ubuntu-based Linux distributions, like Linux Mint, elementary OS and Pop!_OS.

The error shown in a dialog box when upgrading from the Ubuntu repositories VirtualBox to the Oracle-provided VirtualBox:

The virtual machine 'Your machine name' has terminated unexpectedly during startup with exit code 1 (0x1).

Result Code: 
NS_ERROR_FAILURE (0x80004005)
Component: 
MachineWrap
Interface: 
IMachine {85632c68-b5bb-4316-a900-5eb28d3413df}

Yet another dialog box opens after that, showing:

TR3InitEx failed with rc=-1912 (rc=-1912)
The VirtualBox kernel modules do not match this version of VirtualBox. The installation of VirtualBox was apparently not successful. Executing
'/sbin/vboxconfig'
may correct this. Make sure that you are not mixing builds of VirtualBox from different sources.
where: supR3HardenedMainInitRuntime what: 4 VERR_VM_DRIVER_VERSION_MISMATCH (-1912) - The installed support driver doesn't match the version of the user.

Running the suggested sudo /sbin/vboxconfig command doesn't solve this issue.

As a side not, why install the Oracle-provided VirtualBox instead of the one from the Ubuntu repositories? In my case, I want to be able to use the latest features.

Ubuntu doesn't ship major version updates for VirtualBox, so users are stuck with the VirtualBox version that was released when the Ubuntu version they were using came out. E.g. Ubuntu 18.04 and Linux Mint 19.* have VirtualBox 5.2 in their repositories, while Ubuntu 19.10 has VirtualBox 6.0. The latest version of VirtualBox is 6.1, so this will only be available through the Ubuntu repositories for Ubuntu 20.04 users.

So why does this happen and how to fix it?


When you install VirtualBox from the Ubuntu repositories you'll notice that a total of 3 packages are actually installed:

$ sudo apt install virtualbox
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  virtualbox virtualbox-dkms virtualbox-qt
...

If you then add the Oracle VirtualBox repository and install the latest VirtualBox 6.1, two of those packages are removed, but one is kept on the system:

$ sudo apt install virtualbox-6.1
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  virtualbox virtualbox-qt
The following NEW packages will be installed:
  virtualbox-6.1
...

So this issue happens because the Oracle-provided VirtualBox does not remove the virtualbox-dkms package on Ubuntu / Linux Mint. The fix is to remove virtualbox-dkms and then run /sbin/vboxconfig as root:

sudo apt remove virtualbox-dkms
sudo /sbin/vboxconfig

VirtualBox installed from the Oracle repository should now work properly on Ubuntu, Linux Mint, Pop!OS, elementary OS or whatever Ubuntu-based Linux distribution you're using.

Related: VirtualBox Guest Additions Installation In Ubuntu, Linux Mint, Debian, Fedora And openSUSE [How-To]

If you're still seeing an error, but a different one that looks like this:

Implementation of the USB 2.0 controller not found!
Because the USB 2.0 controller state is part of the saved VM state, the VM cannot be started. To fix this problem, either install the 'Oracle VM VirtualBox Extension Pack' or disable USB 2.0 support in the VM settings.
Note! This error could also mean that an incompatible version of the 'Oracle VM VirtualBox Extension Pack' is installed (VERR_NOT_FOUND).

Result Code: 
NS_ERROR_FAILURE (0x80004005)
Component: 
ConsoleWrap
Interface: 
IConsole {872da645-4a9b-1727-bee2-5585105b9eed}

It means the machine you tried to run was installed with VirtualBox Extension Pack support, so it needs this to run. Head over to the VirtualBox downloads page, grab the VirtualBox Oracle VM VirtualBox Extension Pack, double click the extension pack file (which has the vbox-extpack extension) and it should open with VirtualBox, allowing you to install it. The machine will then work as expected.