20

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
2
  • 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
    Commented Aug 4, 2015 at 10:34
  • 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
    Commented Aug 4, 2015 at 10:41

3 Answers 3

33

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
15
  • Where do I get the VBoxGuestAdditions.iso CD file from? The manual (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
    Commented Aug 4, 2015 at 11:42
  • It's bundled with VirtualBox, just click the menu item I have highlighted on a screenshot and VBox will insert it.
    – gronostaj
    Commented Aug 4, 2015 at 11:44
  • 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
    Commented Aug 4, 2015 at 11:54
  • 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
    Commented Aug 4, 2015 at 12:00
  • 2
    Try installing the build-essential package.
    – gronostaj
    Commented Aug 4, 2015 at 12:09
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.
4
  • if you get an error that the mount point doesn't exist, create it: mkdir /media/cdrom
    – AndrewD
    Commented Nov 16, 2016 at 2:40
  • 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
    Commented Nov 17, 2016 at 4:27
  • I don't see any option that says "Install Guest Addition" on the Devices menu there is only "Insert guest addition CD image"
    – samayo
    Commented Jan 17, 2017 at 19:44
  • @samayo its just changed menu item name in new version of VirtualBox from "Install Guest Additions" to "Insert guest addition CD image" (imgur.com/a/9AVVC)
    – menkow
    Commented Jan 18, 2017 at 22:01
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.

1
  • 1
    instead, just type bash VBoxLinuxAdditions.run to save yourself the trouble.
    – Tongfa
    Commented Feb 7, 2017 at 3:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .