Debian 9: Install VirtualBox Guest Additions on Debian 9 on VirtualBox

This article will describe installing Guest Additions.

1 Install build dependencies for Guest Additions

Install kernel header and build dependencies for kernel.

$ sudo apt install -y linux-headers-amd64
$ sudo apt build-dep -y linux

2 Mount Guest Additions CD image

Insert iso file of VirtualBox Guest Additions from window menu of VirtualBox.

Devices -> Insert Guest Additions CD image

If an automount is running, an automount will mount CD image to /media/<username>/<virtualbox> automatically. If an automount is not running, mount CD image manually.

sudo mount -t iso9660 /dev/sr0 /media/cdrom

3 Build Guest Additions

Run VBoxLinuxAdditions.run.

$ cd /media/cdrom
$ sudo sh ./VBoxLinuxAdditions.run
Verifying archive integrity... All good.
Uncompressing VirtualBox 5.0.40 Guest Additions for Linux............
VirtualBox Guest Additions installer
Removing installed version 5.0.40 of VirtualBox Guest Additions...
Removing existing VirtualBox non-DKMS kernel modules ...done.
update-initramfs: Generating /boot/initrd.img-4.9.0-3-amd64
Copying additional installer modules ...
Installing additional modules ...
Removing existing VirtualBox non-DKMS kernel modules ...done.
Building the VirtualBox Guest Additions kernel modules
The headers for the current running kernel were not found. If the following
module compilation fails then this could be the reason.

Building the main Guest Additions module ...done.
Building the shared folder support module ...done.
Building the graphics driver module ...done.
update-initramfs: Generating /boot/initrd.img-4.9.0-3-amd64
Doing non-kernel setup of the Guest Additions ...done.
Starting the VirtualBox Guest AdditionsInstalling the Window System drivers
 ...done.
Installing graphics libraries and desktop services components ...done.
 ...done.

Reboot virtual machine.

$ sudo reboot

4 Execution result

Check whether driver which has a vbox prefix is loaded.

$ lsmod | grep vbox
vboxsf                 45056  0
vboxvideo              49152  2
ttm                    98304  1 vboxvideo
drm_kms_helper        139264  1 vboxvideo
drm                   360448  5 ttm,drm_kms_helper,vboxvideo
syscopyarea            16384  2 drm_kms_helper,vboxvideo
sysfillrect            16384  2 drm_kms_helper,vboxvideo
sysimgblt              16384  2 drm_kms_helper,vboxvideo
vboxguest             282624  8 vboxsf,vboxvideo

Display resolution supports all size. When you change VirtualBox window size, a resolution will be chagned automatically.

0001_DisplayResolution.png