72

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

jtpereyda
  • 2,065

9 Answers9

79

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

sudo apt-get update
sudo apt-get install virtualbox-guest-dkms 
ThisClark
  • 891
  • 4
    I had to do this to enable file sharing from the host operating system. – ThisClark Nov 19 '16 at 03:11
  • 17
    why would I follow the crazy "insert cd" type instructions when I can run this? honest question – Colin D May 03 '17 at 03:28
  • 2
    @ColinD This method hasn't worked for me personally on Desktop. – jtpereyda Feb 09 '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
  • I can't run these commands from the Guest box because it's stuck in a Read-only Filesystem, but I'm trying to run these commands to prevent the read only filesystem issue. – robert.bo.roth Jan 08 '19 at 20:15
  • @robert.bo.roth sounds like an unrelated problem and that you need a different software to resolve. Regard https://askubuntu.com/questions/197459/how-to-fix-sudo-unable-to-open-read-only-file-system – ThisClark Jan 08 '19 at 21:44
  • Thanks @ThisClark, I ended up having to e2fsck to check the disk and repaired a few errors. – robert.bo.roth Jan 09 '19 at 22:04
36

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.
jtpereyda
  • 2,065
  • 3
    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 06: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 06:05
  • It's a little confusing on the download link for the ISO that's provided at the top of the post. You have to hunt on that page for the link under Release, and then look for Downloads. There, I found the file ending in .orig.tar.gz to be the easiest option. I unzipped it on my Mac and then mounted it under Virtualbox machine storage settings, then booted. Then, because I had Lubuntu, I had to go to command line as root, find the disc under /media, and then run ./VBoxLinuxAdditions.run. Once I restarted -- kapoof -- everything worked. – Volomike Oct 01 '16 at 05:53
  • what if there is no "Devices" in the menu? I mean there is no such menu. – ses Jan 22 '17 at 00:17
  • @ses Did you start the guest VM? You won't see the "Devices" menu in the VirtualBox manager, you have to be in the guest VM window. – wisbucky Feb 07 '17 at 02:06
  • It now just inserts the ISO. So you have to run sudo sh /media/....../autorun.sh – qwertzguy Feb 15 '17 at 23:27
  • 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
  • How is video performance for everyone else using this method? I'm running Ubuntu guest under macOS host and it's pretty bad. 3D acceleration seems glitchy, so I'm trying to figure out if it's just me or not :) – jocull Jun 15 '18 at 14:45
  • 1
    "Make sure View -> Auto-resize Guest Display is checked" this made it working..thanks..you saved my day – Lins Louis May 06 '20 at 10:48
  • For Ubuntu 16 Xenial, you need to install version 5.x of virtualbox. Unfortunately this is no longer supported if running the latest version of OSX. Therefore I would advise running 18.04 or hashicorp/bionic64 – Daniel Jul 14 '21 at 12:30
23

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
jonathan
  • 359
  • 2
    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 04 '18 at 14:42
11

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
Zanna
  • 70,465
cloud99
  • 111
5

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]

Zanna
  • 70,465
5

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.

George Udosen
  • 36,677
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!)

Frank N
  • 1,340
0

I found this method was by far the easiest whilst also allowing dynamic screen resizing:

sudo apt install virtualbox-guest-dkms virtualbox-guest-utils virtualbox-guest-x11
SharpC
  • 115
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).

muru
  • 197,895
  • 55
  • 485
  • 740
aure
  • 1