Virtualbox on Debian

Last modified on 2020-05-12

Virtualbox is virtualization software that allows a Linux user to host multiple guest operating systems as virtual machines. A cool tool for experimenting with different Linux distros and configurations!

Let’s go!

In this HOWTO I install Virtualbox (version 6.1.6) on a Debian 10 “buster” HOST and create a Debian GUEST virtual machine.

1. Install VirtualBox on HOST

Kernel modules for Virtualbox are built via Dynamic Kernel Module Support (DKMS). After installing Virtualbox below, the vbox modules should be auto-built and -loaded. First, install a few tools …

$ sudo apt install dkms module-assistant linux-headers-$(uname -r)

Packages for Virtualbox have been removed from Debian buster, so I retrieve the latest *.deb package from Oracle itself by configuring a Debian third-party repository.

Install the Oracle signed GPG public keys …

$ wget -q -O- | sudo apt-key add -

Run command apt-key list and confirm the VirtualBox archive signing key fingerprint matches …

B9F8 D658 297A F3EF C18D  5CDF A2F6 83C5 2980 AECF
Oracle Corporation (VirtualBox archive signing key) <>

Add virtualbox.list to /etc/apt/sources.list.d

$ sudo sh -c "echo 'deb buster contrib' >> /etc/apt/sources.list.d/virtualbox.list

Refresh package listings, install Virtualbox, and assign your username (example: foo) to the vboxusers group …

$ sudo apt update && sudo apt install virtualbox-6.1
$ sudo adduser foo vboxusers

Log out and back in and see the new group added …

$ id

2. Launch Virtualbox and create GUEST

Run …

$ VirtualBox

With the current release, I immediately ran into the issue of VB using an unreadable colour scheme of light grey foreground text on a white background. Unlike other QT apps, Virtualbox does not respect GTK dark themes (which I am using).

[ Fix! ] Start VB with a more usable colour scheme (black text foreground/white background) …

$ VirtualBox -style Fusion %U

Default Machine Folder where Virtual Machine (VM) images are stored is ~/Virtualbox VMs (this can be modified in File->Preferences->General).

See the User Manual for creating a GUEST VM. I use the Debian netinst installer to create a new virtual machine with a minimal system configuration.

3. Console display

Debian GUEST in console mode defaults to a small 80x40 window. Resize by rebooting the GUEST and configure GRUB:

4. Guest additions

Guest Additions is an iso image file included in the VirtualBox package, and is installed inside the virtual machine GUEST after the operating system is installed. It enables extra features such as the ability to tweak display settings and add a shared folder between HOST and GUEST.

Launch the new Debian GUEST. Refresh package listings and install build tools …

# apt update && apt install dkms module-assistant linux-headers-$(uname -r) && m-a prepare

In the Debian GUEST window, load Devices->Insert Guest Additions CD Image .... If the image is not auto-mounted, mount it manually …

# mount /media/cdrom0

Install the Linux Additions on GUEST …

# sh /media/cdrom0/

Assign username (example: foo) to group vboxsf

# adduser foo vboxsf

Reboot GUEST.

5. Graphical desktop display

Tweak display settings by going to Machine->Settings->Display to add more video memory and enable 3D acceleration.

Display settings

Display and resolution can be changed when running a graphical environment. If the GUEST VM does not use a graphical login manager to launch its desktop, then modify ~/.xinitrc to start VBoxClient services …

VBoxClient --clipboard &
VBoxClient --display &
VBoxClient --seamless &

6. Shared folder

Create a shared folder on HOST. Make it accessible to GUEST virtual machines by going to Machine->Settings->Shared Folders. Click on Adds new shared folder, set the Folder Path, and select Auto-Mount.

Shared folder settings

7. SSH from HOST to GUEST

Host-only networking with Virtualbox was a big help getting this properly configured.

Scenario: I want to SSH from my HOST to GUEST. Default configuration supplies GUEST with a NAT interface for internet access but no HOST<->GUEST connectivity. A solution for local access is creating a host-only adapter.

On the HOST

In the Tools sidebar, click the Menu icon and select Network. Click Create and a new host-only network card - vboxnet0 - is configured with default address and DHCP Server enabled.

Select the GUEST virtual machine and in Machine->Settings->Network click on Adapter 2, click on Enable Network Adapter and Attached to Host-only Adapter, and select vboxnet0.

Host-only Adapter settings

On the GUEST

Start GUEST. Install the SSH server …

# apt install openssh-server                                                         

Confirm the new interface has been created …

$ ip a

Add the interface to /etc/network/interfaces (example: enp0s8) …

# Host-only interface
auto enp0s8                                                                          
iface enp0s8 inet dhcp                                                               

Bring up the interface …

# ifup enp0s8

Interface is assigned an address (example: and can now be accessed via SSH.

Optional: Assign GUEST a static address outside the range of the DHCP server (ports 101-254) …

# Host-only interface
auto enp0s8
    iface enp0s8 inet static

Happy hacking!