VirtualBox issues

Install Guest Additions

VirtualBox 4.3.18 is packaged with Debian 8 and Debian 7 backports. Debian 7 stable is packaged with VirtualBox 4.1.18, it's Guest Additions to not build on kernel 3.16 which is the latest kernel on Debian 8.5. To fix, you need to upgrade VirtualBox to 4.3.18. See Ticket #13123

Upgrade VirtualBox to 4.3.18

Follow VirtualBox on the Debian Wiki:

  1. Add Debian Backports sources to /etc/apt/sources.list, also including the “contrib” component. For example:
    # Backported packages for Debian 7 "Wheezy"
    deb http://http.debian.net/debian/ wheezy-backports main contrib
  2. Update the list of available packages:
    # apt-get update
  3. Install the relevant linux-headers package for your system, for example:
    # apt-get install linux-headers-$(uname -r|sed 's,[^-]*-[^-]*-,,')
  4. Install the wheezy-backports/virtualbox package:
    # apt-get -t wheezy-backports install virtualbox

This will also install wheezy-backports/virtualbox-dkms and other recommended packages. DKMS will build the VirtualBox modules for your system.

Check whether the Guest Additions have installed to 4.3.18, if not, then you must install the 4.3.18 Guest Additions manually:

  1. Install with:
    dpkg -i <downloaded-package>

Install USB2.0/3.0 Extension

  1. Download the extension from VirtualBox
  2. Run VirtualBox, then click “File → Preferences → Extensions”
  3. Install the extension
  4. If elevating to root permissions does not work, close all instances of VirtualBox, and restart VirtualBox as root user

Compile the Guest Additions in the guest OS

Follow these steps to install the Guest Additions on your Debian virtual machine:

  1. Login as root;
  2. Update your APT database with apt-get update;
  3. Install the latest security updates with apt-get upgrade;
  4. Install required packages with apt-get install build-essential module-assistant;
  5. Configure your system for building kernel modules by running m-a prepare;
  6. Click on “Install Guest Additions…” from the Devices menu, then run mount /media/cdrom.
  7. Run sh /media/cdrom/VBoxLinuxAdditions.run, and follow the instructions on screen.

If the header files are not found, or the wrong header files are found, do the following:

sudo apt-get remove dkms build-essential linux-headers-*
sudo apt-get install dkms build-essential linux-headers-$(uname -r)

Debian 9

enable backports with contrib; to do so, add a line like

deb http://ftp.debian.org/debian stretch-backports main contrib

to /etc/apt/sources.list (or better yet, a stretch-backports.list file in /etc/apt/sources.list.d);

install virtualbox-guest-dkms, kernel headers, and, optionally, virtualbox-guest-x11 (for the graphical guest utilities):

sudo apt update
sudo apt install virtualbox-guest-dkms virtualbox-guest-x11 linux-headers-$(uname -r)