Debian – How to install Virtual Box Guest Additions on Debian

debianvirtualbox

I have a Debian 8.1 (headless) virtual machine (guest). How do I install the Virtual Box Guest Additions?

The question How can I install virtual box guest addition is answered for Ubuntu by

sudo apt-get install virtualbox-ose-guest-utils

but that doesn't work for me:

E: Unable to locate package virtualbox-ose-guest-utils

Best Answer

From my experience Guest Additions that are bundled with VirtualBox work better. Here are steps to install them. All commands have to be executed as root.

  1. Install kernel headers, build tools and DKMS:

     # apt update
     # apt install build-essential dkms
    

    DKMS isn't required, but it will keep Guest Additions working after kernel updates. Otherwise you'd have to reinstall them.

  2. Insert the virtual CD using appropriate menu item in VirtualBox menu:

    Please note that this is a host menu. It's not inside the Debian VM. In fullscreen you may have to move your mouse to the top of the screen to reveal it. If it's hidden in windowed mode, see this question.

    Menu screenshot

  3. Mount the CD:

     # mount /dev/cdrom /media/cdrom
    
  4. cd into the mounted directory:

     # cd /media/cdrom
    
  5. Run the installer:

     # ./VBoxLinuxAdditions.run
    

Or alternatively, if you really want to install from repository:

# apt install virtualbox-guest-utils