update: 2019-01 if you are having trouble getting VirtualBox Additions to run on your guest vm, you might want to checkout this article and compile your own kernel.

how to compile latest kernel under debian: https://dwaves.org/2017/06/28/debian-compiling-the-latest-kernel-compile-customize-kernel-download-install-linux-kernel-headers/

it is a little annoying that VirtualBoxGuestAdditions setup, might be a little different from version to version, it would be great if Oracle says: „our setup script is compatible with those distributions in those versions“, so people know what to expect.

try to keep it ASAP (As Simple As Possible 🙂

update: 2018-06-05: also tested on:
host: Operating System: CentOS Linux 7 (Core) / Kernel: Linux 4.15.9
guest:  Operating System: Debian GNU/Linux 9 (stretch) / Kernel: Linux 4.9.0-6-amd64

also tested on/with:

host: Linux Debian 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt7-1 (2015-03-01) x86_64 GNU/Linux
+guest: Linux debian 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt9-3~deb8u1 (2015-04-24) x86_64 GNU/Linux
host: windows server 2012
+guest: Linux Debian 
apt-get install build-essential module-assistant linux-headers-$(uname -r); # install stuff needed to compile
m-a prepare; # do stuff with the module assistant (optional in debian9?)

virtualbox insert guest additions cd

# it should get mounted automatically if you have a GUI (gnome-core) installed if not:
mkdir /media/cdrom; # might allready exist
mkdir /virtualbox; # i am used to copy this over to root before compiling

# Debian8: jessie
mount /dev/cdrom /media/cdrom; # should work

# Debian9: stretch
mount /dev/sr0 /media/cdrom; # should work

cp -rv /media/cdrom/* /virtualbox; # i like to copy all the stuff to a harddisk folder before executing
sh /virtualbox/VBoxLinuxAdditions.run; # run stuff

vim /var/log/vboxadd-install.log; # in case of error - check logs
vim /var/log/VBoxGuestAdditions.log; # in case of error - check logs
# if you need more verbose output, open a second terminal an paste, before compiling: (monitor all logs)
find /var/log/ -type f \( -name "*" \) ! -path '*.gz*' -exec tail -n0 -f "$file" {} +

# check if modules/drivers were installed
modprobe|grep --color vbox; # should list a bunch of virtualbox related modules

reboot; # and test if it's workin' now


how to check if vbox additions are installed correctly:


lsmod|grep vbox; # test if virtualbox additions were compiled and installed correctl
vboxsf                 45056  0
vboxguest             286720  5 vboxsf
vboxvideo              36864  2
ttm                    98304  1 vboxvideo
drm_kms_helper        155648  1 vboxvideo
drm                   360448  5 vboxvideo,ttm,drm_kms_helper

# check installed version
lsmod | grep -io vboxguest | xargs modinfo | grep -iw version
version:        5.2.23 r128039

uninstall guest additions:

which vbox-uninstall-guest-additions 

# This executable provides a well-known way to uninstall VirtualBox Guest
# Additions in order to re-install them from a different source. A common case
# is uninstalling distribution-provide Additions to install the version provided
# by VirtualBox. Distributions should put the right command in here to do the
# removal, e.g. "dnf remove VirtualBox-guest-additions". Leaving kernel modules
# provided by the distribution kernel package in place is acceptable if the
# location does not clash with the VirtualBox-provided module location (misc).