How to install VirtualBox Guest Additions for Ubuntu 16.04

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

sudo apt-get update
sudo apt-get install virtualbox-guest-dkms 

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.

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