Cannot reinstall VirtualBox on Ubuntu 16.04

Solution 1:

I found the answer, it was that secure boot thing installed by Ubuntu while upgrading. The instructions were not clear as to how to remove that secure boot thing but i managed to do it.

  1. Restart your computer after installed the DKMS drivers for VBOX
  2. You will be prompted with a blue screen with 2 options: wait or change MDK settings
  3. Choosing change MDK settings and enter the password characters as requested, you have to press on the key corresponding to the character index being asked for and then press ENTER.
  4. After entering 2 or 3 characters, they will ask you if you want to remove secure boot, say yes!
  5. Computer will restart, once you are back it should work!

Solution 2:

I had the same problem when updating to Ubuntu 16.04 and found the following error message:

Starting VirtualBox kernel modules ...failed!
  (modprobe vboxdrv failed. Please use 'dmesg' to find out why)

It also was caused by UEFI boot. The solution is quite simple:

  1. Reboot your machine and enter the BIOS Menu (In my case pressing F2)
  2. Search for Secure Boot and change to Legacy

    In an ASUS motherboard:

    • Go to the Advanced Mode (F7)
    • Go in the Secure Boot option under the Boot section
    • Change "Windows UEFI mode" with "Other OS"
    • Save and restart to apply settings (F10)
  3. After restarting make sure drivers are loaded

Type:

sudo /sbin/rcvboxdrv setup

And you should get

Stopping VirtualBox kernel modules ...done.
Uninstalling old VirtualBox DKMS kernel modules ...done.
Trying to register the VirtualBox kernel modules using DKMS ...done.
Starting VirtualBox kernel modules ...done.