How to install Virtual Box Guest Additions on Debian?

18

23

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

Gustave

Posted 2015-08-04T10:32:02.697

Reputation: 997

The package in repositories if often outdated, consider using the one that is bundled with VirtualBox and can be inserted as a virtual CD. – gronostaj – 2015-08-04T10:34:00.140

The answer to mentioned question says: "Instead, install the virtualbox additions from your distro version's official repositories." So what now? So far I used only apt-get to install Software. How would I install something from a CD? – Gustave – 2015-08-04T10:41:24.430

Answers

29

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:

    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

gronostaj

Posted 2015-08-04T10:32:02.697

Reputation: 33 047

Where do I get the VBoxGuestAdditions.iso CD file from? The manual (https://www.virtualbox.org/manual/ch04.html) says: "The VirtualBox Guest Additions for Linux are provided on the same virtual CD-ROM file as the Guest Additions for Windows described above." but I only have a VirtualBox-4.3.30-101610-OSX.dmg file (MAC).

– Gustave – 2015-08-04T11:42:33.240

It's bundled with VirtualBox, just click the menu item I have highlighted on a screenshot and VBox will insert it. – gronostaj – 2015-08-04T11:44:55.257

Thanks! `sudo apt-cache pkgnames | grep virtualbox' doesn't give results. VBoxLinuxAdditions.run complains: tar: Exiting with failure status due to previous errors ./install.sh: 357: ./install.sh: bzip2: not found. After installing bzip2 (apt-get install bzip2) I get the warning; "You appear to have a version of the VBoxGuestAdditions software on your system which was installed from a different source or using a different type of installer (...)". I am ignoring this. – Gustave – 2015-08-04T11:54:31.167

It seems I have to install make and gcc, too. After installing them (apt-get install make, apt-get install gcc) I still get two warnings but some messages that indicate success, too. – Gustave – 2015-08-04T12:00:22.370

2Try installing the build-essential package. – gronostaj – 2015-08-04T12:09:00.147

Is there a possibilty to check if the installation was succesful? – Gustave – 2015-08-04T12:15:23.847

If it works after a reboot, then yes, it was successful ;) Installer should finish without any errors. It may complain that you don't have X Window installed, but other than that, no errors should appear. – gronostaj – 2015-08-04T12:22:36.157

OK. That just broke my machine. It doesn't startup anymore. Sorry, doesn't convince me. As I failed doing it with the virtualbox manual, too. I'll give up for now. – Gustave – 2015-08-04T12:29:37.187

It seems Debian comes with the Virtual Box Guest Additions pre-installed: http://www.binarytides.com/virtualbox-guest-additions-debian-wheezy/

– Gustave – 2015-08-04T13:32:18.043

@Gustave - you need to add "contrib" which are the non-free packages to your /etc/apt/sources.list – Colin – 2017-02-12T05:36:28.570

There is no need for sudo when searching packages, e.g. with apt-cache pkgnames. – amn – 2017-05-10T10:57:05.990

run upgrade first. sudo apt-get update && sudo apt-get upgrade -- kernel header may not find a match using uname -r otherwise. (Kali/Debian did this to me.). had to use sh to start the CD file, too. All the rest worked 100%. Solid answer, still. – bshea – 2018-07-12T18:07:56.283

I also had to install x11-xserver-utils. – grooveplex – 2019-05-15T14:18:56.243

15

This works for me (Debian GNU/Linux 8 (Jessie) 64-bit):

  1. Login as root with terminal command su press Enter and then type your root password
  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 VirtualBox Devices menu
  7. Run mount /dev/sr0 /media/cdrom
  8. Run sh /media/cdrom/VBoxLinuxAdditions.run, and follow the instructions on screen.

menkow

Posted 2015-08-04T10:32:02.697

Reputation: 251

if you get an error that the mount point doesn't exist, create it: mkdir /media/cdrom – AndrewD – 2016-11-16T02:40:42.477

The one that worked for me was: $su $apt-get update $apt-get upgrade $apt-get install build-essential module-assistant linux-header-$(uname -r)

Click mount Guest Additions on virtualbox

$sh /media/cdrom/VBoxLinuxAdditions.run – Esteban – 2016-11-17T04:27:56.133

I don't see any option that says "Install Guest Addition" on the Devices menu there is only "Insert guest addition CD image" – samayo – 2017-01-17T19:44:14.527

@samayo its just changed menu item name in new version of VirtualBox from "Install Guest Additions" to "Insert guest addition CD image" (http://imgur.com/a/9AVVC)

– menkow – 2017-01-18T22:01:42.260

6

I got permissions denied when I tried to run "VBoxLinuxAdditions.run" so I changed the file /etc/fstab to user,exec. Other than that the steps that gronostaj mentioned worked perfectly.

Explanation from virtualbox forum:

..the filesystem is mounted with the noexec option, so the execute permission bits on all files are ignored, and you cannot directly execute any program residing on this filesystem. Note that the noexec mount option is implied by the user option in /etc/fstab. ... If you use user and want to have executable files, use user,exec.

simen

Posted 2015-08-04T10:32:02.697

Reputation: 61

1instead, just type bash VBoxLinuxAdditions.run to save yourself the trouble. – Tongfa – 2017-02-07T03:56:59.087