Debian 10 is almost ready to transition to the newest Stable release of Debian Linux. However, since it’s relatively new, some apps that users come to expect on Debian via software repositories aren’t yet ready. One of the biggest apps not yet officially supporting Debian 10 with a dedicated software repository is Oracle VM VirtualBox. Currently, the website only has a repo for Debian 9 and older releases. So, if you rely on VirtualBox and are a Debian 10 user, you’ll need to look to other ways to get Virtualbox 6 on Debian 10.
Note: this method involves enabling third-party software sources on Debian. If you prefer to use Virtualbox another way, click on “All Linux” on the VirtualBox website for more info.
Enable the repo
As of writing this post, the best way to get VirtualBox 6 on Debian 10 is with the Ubuntu 18.04 LTS software repository. Not to say that Oracle won’t create a standalone Debian Buster repo in the future, but if you want regular updates, this is the way to go.
To enable the repo, start by creating a backup of your sources list. This backup will ensure that in the event anything goes wrong your repos are safe.
su - cp /etc/apt/sources.list /etc/apt/sources.list.bak
With everything backed up, open up the sources file in the Nano text editor.
nano -w /etc/apt/sources.list
RECOMMENDED FOR YOU
Scroll to the bottom of the file and find an open space. Then press Enter on the keyboard to create a new line. On the new line, add the code below. This line of code is a comment, which will remind you what repository you are adding.
# VirtualBox Ubuntu Repo
Press Enter a second time under the code you just added and paste in the second line of code in the file. In this line, you’ll add in the actual software repository.
deb [arch=amd64] http://download.virtualbox.org/virtualbox/debian bionic contrib
From here, you can save the Sources.list file in Nano by pressing Ctrl + O on the keyboard. Then, when your changes are successfully saved, close the editor by pressing Ctrl + X.
Set up the repo key
The new VirtualBox software repository is set up on Debian Linux, but it’s not ready to use yet, as the repo doesn’t have the signed GPG key set up. Without this key, your Debian system will refuse to refresh the repo, going so far as to call it a security risk.
To get the key working, you must first download it from Oracle. Open up a terminal and move to the /tmp directory with CD. Then, grab the key file.
cd /tmp wget https://www.virtualbox.org/download/oracle_vbox_2016.asc
Using the apt-key command, load in the oracle_vbox_2016.asc file to your Debian 10 system.
sudo apt-key add oracle_vbox_2016.asc
With the repo key up and running on Debian 10, move on to the next step in the guide.
Refreshing software sources
Now that the VirtualBox software repository is set up, and the key file is loaded into the system, it’s time to update Debian to finish setting up the software repository. To do this, you need to run the apt-get update command.
sudo apt-get update
Assuming you set up the key file on your Linux PC correctly, Debian’s package management system will let you refresh everything, and the VirtualBox software repository will be working on Debian 10. To finish up, run the upgrade command to install any pending system upgrades.
sudo apt-get upgrade -y
Installing Oracle VM VirtualBox is very easy to do on Debian 10 now that the software repository is set up, the key is working, and everything is up to date. To get the software, open up a terminal and enter the command below.
apt-get install virtualbox-6*
Along with having the absolute latest release of VirtualBox, you’ll also be able to install version 5.2 and 5.1 with:
apt-get install virtualbox-5.2*
apt-get install virtualbox-5.1*
When the Debian package manager finishes downloading and installing packages, VirtualBox will be ready to use!
Don’t want to use VirtualBox on your Debian 10 system anymore? Here’s how to quickly get rid of it. First, open up a terminal window and uninstall the package from the system.
apt-get remove virtualbox-6* --purge
apt-get remove virtualbox-5.2* --purge
apt-get remove virtualbox-5.1* --purge
Next, you need to delete your current Sources.list file from the system using the rm command.
cd /etc/apt/ rm sources.list
Following getting rid of the sources file, move the sources.list.bak file so it is now the new sources.list file.
mv sources.list.bak sources.list
Run the update command to refresh Debian 10’s software sources.
Uninstall any VirtualBox dependencies that remain installed (if any) using the autoremove command.