59

What is the best way to install Guest Additions with all the resize and clipboard and file sharing features on Ubuntu 16.04?

64

For Ubuntu Server, it is necessary to install guest additions from command line.

sudo apt-get update
sudo apt-get install virtualbox-guest-dkms 
  • 4
    I had to do this to enable file sharing from the host operating system. – ThisClark Nov 19 '16 at 3:11
  • 14
    why would I follow the crazy "insert cd" type instructions when I can run this? honest question – Colin D May 3 '17 at 3:28
  • @ColinD This method hasn't worked for me personally on Desktop. – jtpereyda Feb 9 '18 at 23:41
  • 1
    Couldn't get anything to work. "DKMS" seems to do the trick on ubuntu server 17.10, VirtualBox 5.2.6 – willem Feb 16 '18 at 14:54
  • tried this an now my ubuntu vm doesn't accept any input from mouse and keyboard – Alex G Jun 12 '18 at 10:38
32

There is a guest additions package, but this only enabled some of the features for me.

The most reliable way is probably to use the built-in installer that comes with VirtualBox.

This is for Ubuntu Desktop. For Ubuntu Server, see @ThisClark's answer.

Updates

  1. Make sure you have the latest version of VirtualBox.
  2. It might be good to first sudo apt update and sudo apt upgrade and restart if needed.

Guest Additions

  1. Power on virtual machine
  2. Click "Devices" on the VirtualBox menu at the top of the screen
  3. Click "Install Guest Additions CD Image..."
  4. Follow the on-screen prompts as needed, enter your password, etc.
  5. Restart the virtual machine

Enable features

  1. Machine -> Settings -> General -> Advanced -> enable Shared Clipboard and/or Drag'n'Drop.
  2. Make sure View -> Auto-resize Guest Display is checked.
  • 1
    Sorry, but this answer says nothing about required packages. On my fairly default install of Ubuntu 16.04.1 Server, required development packages are not installed. – Colin 't Hart Aug 20 '16 at 17:44
  • @Colin'tHart Thanks for the info. Which packages did you need to install, besides doing the steps listed? If your situation is different enough, feel free to write your own answer. – jtpereyda Aug 20 '16 at 18:38
  • When you run the installer of the guest additions it tells you what you need. Out of the top of my head I do believe that you need the kernel headers which can be installed via apt-get or aptitude. – rbaleksandar Aug 26 '16 at 6:01
  • @jtpereyda: works like a charm :) to enable the features, do not restart but do it in the first vb screen before starting the machine – cwhisperer Aug 26 '16 at 6:05
  • 2
    Couple notes: You may have to create an optical drive if you don't have one so that you can insert the guest additions cd. I had to select "insert guest additions cd image..." from the devices dropdown. After this, the autorun didn't open on boot, so i had to open a terminal and run ./autorun.sh. – Blaskovicz Mar 19 '17 at 17:21
14

If you don't download the ISO, you won't get the "latest and greatest" version. If you'd like to stick with this option, please see the following notes for dependencies.

I have tested these instructions successfully under an Ubuntu 16.04 guest:

  1. Create Ubuntu server instance under VirtualBox (obviously).
  2. Start VM, go to Devices -> Insert Guest Additions CD image to mount the ISO image.

  3. From the terminal, run the following commands:

    sudo -i  
    apt install gcc make  
    mkdir -p /media/cdrom  
    mount /dev/cdrom /media/cdrom  
    /media/cdrom/VBoxLinuxAdditions.run  
    reboot  
    
  4. After reboot:

    sudo usermod --append --groups vboxsf USERNAME
    
  5. Host shares should now be mounted in Ubuntu guest under /media via the installed VBoxService service, set to start on system boot-up.

This impacted my install.

Noted from comment:

  • Log out and back in again after adding user account to vboxsf group
  • 1
    This worked for me, thanks! One note, I had to log out and back in again after adding my user account to the vboxsf group before I could access the share. – Guy Starbuck Oct 4 '18 at 14:42
9

1) Install a package through the usual channels for your distribution. For example, you might use:

sudo apt-get install virtualbox-guest-additions-iso

2) Add in the guest additions by choosing Devices > Optical Drives > VBoxGuestAdditions.iso

When you use the above command to download the iso file. It can be found here:

/usr/share/virtualbox/VBoxGuestAdditions.iso
4

This worked for me:

sudo mount /dev/cdrom /media/cdrom
sudo apt install -y dkms build-essential linux-headers-generic linux-headers-$(uname -r)
sudo sh /media/cdrom/VBoxLinuxAdditions.run

Then rebooted the virtual machine.

  • 1
    This fixed it for 16.04 for me. – Karl Morrison Jan 29 '18 at 12:43
2

This worked for VirtualBox 5.1.28 MacOS host running Ubuntu Server 16.04.3 LTS guest. All instructions are for the guest Ubuntu Server.

Note: do not use the VirtualBox GUI to "Insert Guest Additions CD Image." It did not invoke "vboxadd.sh" as did the up-to-date .iso downloaded from the virtualbox website. In addition, your guest must have internet access (use "NAT" instead of "bridged adapter" if you are having trouble with your guest OS internet).

In terminal, download the VBoxGuestAdditions.iso for your version of VirtualBox (for me it's 5.1.28).

wget http://download.virtualbox.org/virtualbox/5.1.28/VBoxGuestAdditions_5.1.28.iso

Then create an empty directory in /media and mount it there:

sudo mkdir /media/iso

sudo mount VBoxGuestAdditions_5.1.28.iso /media/iso

Then go there and run the Linux installer:

cd /media/iso

sudo ./VBoxLinuxAdditions.run

Reboot your guest OS:

reboot

You should be able to access your shared folder under /media/sf_[your_folder_name]

1

Virtual Box 5.1 wanted?

If you intend to get and use Virtual Box 5.1 (not 5.0), at the time of writing, you won't afaik get it through apt. And adding 3rd party repos can get you unintendedly the 32bit version with an obscure error version, see this answer.

Thus it's probably best to download VirtualBox itself and the Guest Additions (now renamed/part of "Extension Pack" it directly from the highest 5.1.x version you can find here:

http://download.virtualbox.org/virtualbox/

i.e.

http://download.virtualbox.org/virtualbox/5.1.28/

(After abovemtioned 32bit nuisances, ) I got lucky with

virtualbox-5.1_5.1.28-117968~Ubuntu~xenial_amd64.deb

The two offered extension packs are identical (same checksum), pick any:

Oracle_VM_VirtualBox_Extension_Pack-5.1.28-117968.vbox-extpack
Oracle_VM_VirtualBox_Extension_Pack-5.1.28.vbox-extpack  

How to install all of that? Double-click. Opens standard ".deb"-Installer, respectively virtual box, to take care of the extension pack. (Yes, windows-ish, uncool, but works!)

0

I had the same problem as you, I'll explain what I've done:

  • I read the VirtualBox User Guide corresponding to the version of VB installed.

  • I installed the VB from the repositories of Ubuntu; it is now(july2017) the version 5.0.40

  • I download from VB www the extension pack corresponding to this version, double click and it is installed: I had access to USB devices.
  • It seems that the VBGuestAdditions.iso has to be installed with the installation of VM

    by checking in settings->user interface ->devices ->insert GuestAdditions CD image,

    but in my case it did not so I searched this ISO file in the host and in the case of the VB version this ISO file is in /usr/share/virtualbox.

  • Finally in the settings of the VM (the VBGuestAdditions is to be installed in the guest)

    in Storage, in controller IDE I put the path to the file VBGuestAdditions.iso and it appears in the VM as a CD device and you can access it and run the VBGuestAdditions and obtain the correct resizing of screen and access to the shared folder (this last feature at least in guest win7).

protected by Community Mar 22 at 21:00

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.