Last Updated:

Install Virtual Box on Debian 11

masonbee Debian

In this post I will show how to install Virtual Box from Oracle. There are a many different ways to run virtual machines on Debian 11 but an easy tried and true favorite of mine is Virtual Box. It has easy to use and at the same time there are lots of options available if you need them.

Table of Contents

Add the Oracle repository

Firstly you need to add the Oracle repository to your apt sources.list. The easiest way to do this is to open up a terminal and type,

sudo nano /etc/apt/sources.list

This will open the text file using the basic text editor called nano. You  will need to be using your administrative account and enter your password to do this.

Once opened you should see a list such as,

# deb cdrom:[Official Debian GNU/Linux Live 11.1.0 gnome 2021-10-09T12:28]/ bullseye main

#deb cdrom:[Official Debian GNU/Linux Live 11.1.0 gnome 2021-10-09T12:28]/ bullseye main

deb bullseye main
deb-src bullseye main

deb bullseye-security main
deb-src bullseye-security main

# bullseye-updates, to get updates before a point release is made;
# see
deb bullseye-updates main
deb-src bullseye-updates main

# This system was installed using small removable media
# (e.g. netinst, live or single CD). The matching "deb cdrom"
# entries were disabled at the end of the installation process.
# For information about how to configure apt package sources,
# see the sources.list(5) manual.

It may be a little different depending on how your system was installed. The important parts are the lines without a # infrount of them. These are the lines that apt reads when reading the file.

Arrow down to the bottom of the file, push enter once to add a new line and then copy and paste this into it.

#Oracle Virtual Box
deb [arch=amd64] bullseye contrib

Then use ctrl + x and answer y to save the file. Nano will close.

Add Oracles public key

You need to add Oracles public key to use the repository. To add it, right click and save this link

Go to the folder that you downloaded the key to and open a terminal. This can be done in the Gnome Desktop by right clicking on empty space in the folder and selecting open a terminal. 

In the terminal paste the below code and push enter to add the key. You will again need to enter your password and it will say that apt-key has been depreciated. It's OK, it still works.

sudo apt-key add oracle_vbox_2016.asc

Install Virtual Box

After the above steps you will need to refresh apt with,

sudo apt update

and then you can install Virtual Box with,

sudo apt install virtualbox

You may have to wait a little while for the packages to download and install and you may have to enter your password again and confirm the download by entering y when asked.

Add user to vboxusers group

The final step before rebooting is to add your user to the vboxusers group. This is also easily done in the terminal with,

sudo adduser yourusernamehere vboxusers

After that you should be able to reboot and start using the program. It can be found in you applications menu.

Some notes about usage

One of the more used features of Virtual Box is the ability to have a copy of Windows available in case you need it while running Linux. There can be a number of problems using Windows in Virtual Box, all of them stemming from Microsoft.

For instance if you are going to change a Windows install from physical hardware to virtual it will still be covered as a separate install in the licensing so you will probably need to run sysprep before deleting the install. Do not unlink your install in your Microsoft account as you will end up having to call support (Don't bother with the webpages, they are a merry go round even if you have a valid key).