Skip to Content

Virtualbox on Buster

Posted on

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

Let’s go!

In this HOWTO I install Virtualbox (version 6.0.4) on a Debian HOST running the buster release and create a Debian GUEST virtual machine.

0. Install VirtualBox on HOST

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

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

Virtualbox packages for Debian stable are available in contrib. Ensure the repository is enabled in /etc/apt/sources.list

deb http://deb.debian.org/debian/ buster main contrib
deb-src http://deb.debian.org/debian/ buster main contrib

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

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

Reload the user’s group assignments without logging out …

$ sudo adduser foo vboxusers
$ su - $USER

Command id will now list the new group …

$ id
uid=1000(foo) ... ,120(vboxusers)

1. Run VB and create Debian 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 backgroud. Unlike other QT apps, Virtualbox 6.0.4 does not respect GTK dark themes (which I am using).

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

$ VirtualBox -style Fusion %U

… which is not my preferred theme but makes everything now usable.

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.

2. Guest additions

Enable extra features such as the ability to tweak display settings and add a shared folder between HOST and GUEST machines.

Launch the new Debian GUEST. Ensure its /etc/apt/sources.list also has contrib enabled …

deb http://deb.debian.org/debian/ buster main contrib
deb-src http://deb.debian.org/debian/ buster main contrib

Refresh package listings and install build tools …

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

Install virtualbox-guest-* packages on GUEST …

# apt install virtualbox-guest-dkms virtualbox-guest-utils virtualbox-guest-x11

Assign username (example: foo) to group vboxsf

# adduser foo vboxsf

If the virtualbox modules need to be rebuilt for any reason for the running kernel …

# uname -r | xargs -n1 /usr/lib/dkms/dkms_autoinstaller start

3. Console

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

  • Grub boot screen: hit c to enter command mode
  • At the prompt grub>: run vbeinfo to display supported resolutions (example: 1024x768)
  • Modify /etc/default/grub: add …
    • GRUB_CMDLINE_LINUX_DEFAULT="nomodeset"
    • GRUB_GFXMODE=1024x768
    • GRUB_GFXPAYLOAD_LINUX=keep (Helpful!)
  • Save changes, run update-grub and reboot

4. Display

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

Display settings

With guest additions installed above, 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 &

5. Shared folder

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

Shared folder settings

6. 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.

6.1 On the HOST

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

Select the GUEST VM 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

6.2 On the GUEST

Start the 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 has been assigned address (example: 192.168.56.101) and can now be accessed from HOST via SSH.

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

# Host-only interface
auto enp0s8
    iface enp0s8 inet static
    address 192.168.56.50
    netmask 255.255.255.0
    network 192.168.56.0
    broadcast 192.168.56.255

Happy hacking!