Lately I've been seeing a lot of posts regarding VirtualBox errors, errors upgrading to 5.1, and the DKMS modules errors that can happen. VirtualBox 5.1 no longer uses dkms modules, which is why I think going outside the official repo is a good idea in this instance. I'm not any kind of expert or pro. I have only been using Linux for a year or so. But I use VirtualBox on an almost-daily basis and have installed it a dozen times in both Mint and other Ubuntu flavors. I also stayed in a Holiday Inn Express last night. That and I just wanted to make a handy post that explains the situation for new VirtualBox users here in this forum who want the latest version of this awesome program. The official Oracle VirtualBox site (https://www.virtualbox.org/wiki/VirtualBox) can be confusing and the Download page really fails to mention or emphasize the importance of dkms and Mint.
First off, I'm going to suggest NOT downloading anything related to VirtualBox with the Mint Software Center. It's a helpful and friendly place for users, but it (intentionally) lacks advanced information on packages or the ability to see and select dependencies or individual parts of a package. I recommend using Synaptic, which is already installed with Mint and is the official Debian GUI tool for APT management and installation. It's listed in your main Mint Menu by default.
Next, start up Synaptic and search for "Virtualbox" with the ALL filter (normal search). It's going to show you the current VirtualBox packages in the repo. You will either have them or not, and that makes the next part very important: if you have it installed already and actually use it, do not touch anything yet. Go back and back up anything you want to keep in VirtualBox, like your virtual HDDs containing all your machine data. Otherwise they will be wiped out when we uninstall this older repo version. The backup procedure for that is beyond what I'm doing here, but if you already use VirtualBox then you know where your VM data is, where the VDI or other virtual drive stuff is kept, and should be able to make backups of it and store them somewhere safe for now (hint: you may also want to backup your preferences if you made major changes there, but it's not hard to redo that). Now, back to Synaptic's window. Even if you have never installed VirtualBox before you will have two packages listed there as installed. Those are "virtualbox-guest-utils" and "virtualbox-guest-x11". Don't touch them. I don't know why Mint installs these particular packages by default, but they are both run during start up and are important. Why? Because anything done by Mint is important, but it's beyond the scope of this little "guide" post. Then, if you have made your backups (or didn't need to do that), you are now going to remove VirtualBox. Marking the metapackage "virtualbox" for removal should then select all the other packages for removal (hint: the virtualbox package should be listed on top in Synaptic. It will also say it's a metapackage in the description box, but if you didn't know that already, this guide might not be right for you). You especially want to make sure virtualbox-dkms gets removed here!
Ok, VirtualBox is now gone. I would advise rebooting here because making DKMS changes would necessitate that unless you know the manual method of restarting DKMS/DKMS modules. That's beyond my scope, but it's not hard if you want to Google it and learn how. We won't need dkms in 5.1, but just be cautious. So, back to Mint after reboot. We no longer have VirtualBox installed (other than the two Mint packages I mentioned earlier). Next, open up a browser and go to:
https://www.virtualbox.org/wiki/Linux_Downloads.
This is the basic guide and main source for what I'm explaining here. Next we're going to add the Oracle PPA. Note: this guide explains exactly what I'm putting in this post, but it really fails to mention the importance of dkms and the difference between VirtualBox 5.0 (our repo version) and 5.1 (the version we're about to get).
Now we need to add that Oracle PPA, so here are the instructions, edited for Mint 18/18.1 and xenial-based users (note that everything I'm saying here is for xenial and Mint 18/18.1 - if you aren't using Mint based on xenial Ubuntu, it needs changed):
Step 1: Add the following line to /etc/apt/sources.list two spaces below the pre-existing line which should be a commented-out item. If there is no line, just put it at the top. (hint:
gksudo xed /etc/apt/sources.list
)deb http://download.virtualbox.org/virtualbox/debian xenial contrib
It's very important to add that source line exactly as shown without changes. The Oracle public key for apt-secure can be downloaded here separately if you want to do it manually: https://www.virtualbox.org/download/ora ... x_2016.asc
Step 2: These two commands will download and auto-add the Oracle key:
Code: Select all
wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add -
B9F8 D658 297A F3EF C18D 5CDF A2F6 83C5 2980 AECF
Oracle Corporation (VirtualBox archive signing key) <info@virtualbox.org>
And the key fingerprint for oracle_vbox.asc is
7B0F AB3A 13B9 0743 5925 D9C9 5442 2A4B 98AB 5139
Oracle Corporation (VirtualBox archive signing key) <info@virtualbox.org>
Step 3: run
sudo apt update
and the VirtualBox PPA should now be ready for us to download the latest version.The final step is to actually install VirtualBox 5.1! That is done with this command:
sudo apt install VirtualBox-5.1
It will install and there should not be any errors as long as you removed the dkms package earlier and followed this quick guide. VirtualBox 5.1+ eliminates the use of DKMS altogether! See the full list of changes from 5.0 to 5.1 here: https://www.virtualbox.org/wiki/Changelog
This worked for me in Mint 18 and 18.1 Serena, which is the current version as of Jan. 2017 and based on Ubuntu "xenial" (16.04). I cannot say with certainty if these steps will work on other versions of Mint, but as long as it's "xenial" it should be fine. If not, you would obviously need to change the line in your apt sources.list (hint: if that is the case, your current release is shown in that list, in the commented-out CDROM line). If I missed anything here, please let me know! If this still fails and still produces errors, make sure you've not changed your kernel in between adding/removing/updating VirtualBox 5.0 and lower. Kernel changes require you to recompile your DKMS modules each time! That's beyond the scope of this, but as long as you are using VirtualBox 5.1+ you should not need to worry about dkms.
Anything else? Just ask. I'm sure I missed something. If I screwed up any commands above, let me know ASAP and it'll get fixed!
PS: After a clean 5.1 install it'd be a good idea to read the Wiki page on using the Guest Additions ISO in each guest system: https://www.virtualbox.org/manual/ch04.html#idm1784