How to install Virtualbox guest additions on Ubuntu 14.04

By | January 15, 2023

After installing Ubuntu inside virtualbox, you need to install the guest additions to get better hardware functionality inside it. These include full screen resolution, mouse wheel and pointer integration, copy paste from host os (shared clipboard), shared folders etc.

This tutorial shows you how to install VirtualBox guest additions in Ubuntu. The same method works for similar distros like Xubuntu, Kubuntu and Lubuntu.

1. Install kernel headers and build tools

Virtualbox guest additions are compiled for the target system, so it needs the necessary kernel headers and related programs. Install the following 2 packages.

$ sudo apt-get install build-essential module-assistant

Now run

$ sudo m-a prepare

2. Compile virtualbox guest additions

Now click "Devices > Insert guest additions CD image" in the virtualbox window. This will insert the guest additions cd image into the guest OS. On Xubuntu the cd should get mounted automatically inside the /media directory.

On Ubuntu unity, you should see the cd icon on the left panel towards the lower side. Click it to open the VBox guest additions cd in file manager.

Kubuntu would give you a device notification on bottom right and you can click "open with file manager" which will mount the cd and open it up in dolphin.

Check the path of the cd file system inside the file manager (press Ctrl + L). The location should be something similar to this

/media/<username>/VBOXADDITIONS_4.3.10_93012

The shall contain your username on the system.

Mount manually

If it does not mount by itself, then you can manually mount it. Find out the device using blkid and then use the mount command to mount it somewhere in your home directory

# find out the device
$ sudo blkid
/dev/sr0: LABEL="VBOXADDITIONS_4.3.10_93012" TYPE="iso9660" 

# Or use the lsblk command
$ sudo lsblk -o NAME,TYPE,SIZE,LABEL,MOUNTPOINT,MODEL
NAME   TYPE   SIZE LABEL                      MOUNTPOINT MODEL
sda    disk     8G                                       VBOX HARDDISK   
├─sda1 part     6G                            /          
├─sda2 part     1K                                       
└─sda5 part     2G                            [SWAP]     
sr0    rom   61.7M VBOXADDITIONS_4.3.10_93012            CD-ROM

Note down the device name which is "/dev/sr0" here. Next we have to mount this device (cdrom) to access the contents.

# create directory to mount
$ mkdir cdrom

# mount the cd
$ sudo mount /dev/sr0 ~/cdrom/
[sudo] password for silver: 
mount: block device /dev/sr0 is write-protected, mounting read-only

# get inside the mounted directory
$ cd cdrom/
~/cdrom$ ls
32Bit        cert                    VBoxSolarisAdditions.pkg
64Bit        OS2                     VBoxWindowsAdditions-amd64.exe
AUTORUN.INF  runasroot.sh            VBoxWindowsAdditions.exe
autorun.sh   VBoxLinuxAdditions.run  VBoxWindowsAdditions-x86.exe

Start compiling

Navigate to the directory and run the script named VBoxLinuxAdditions.run

/media/silver/VBOXADDITIONS_4.3.10_93012$ ls
32Bit        cert                    VBoxSolarisAdditions.pkg
64Bit        OS2                     VBoxWindowsAdditions-amd64.exe
AUTORUN.INF  runasroot.sh            VBoxWindowsAdditions.exe
autorun.sh   VBoxLinuxAdditions.run  VBoxWindowsAdditions-x86.exe


/media/silver/VBOXADDITIONS_4.3.10_93012$ sudo ./VBoxLinuxAdditions.run 
[sudo] password for silver: 
Verifying archive integrity... All good.
Uncompressing VirtualBox 4.3.10 Guest Additions for Linux............
VirtualBox Guest Additions installer
Copying additional installer modules ...
Installing additional modules ...
Removing existing VirtualBox DKMS kernel modules ...done.
Removing existing VirtualBox non-DKMS kernel modules ...done.
Building the VirtualBox Guest Additions kernel modules ...done.
Doing non-kernel setup of the Guest Additions ...done.
Starting the VirtualBox Guest Additions ...done.
Installing the Window System drivers
Installing X.Org Server 1.15 modules ...done.
Setting up the Window System to use the Guest Additions ...done.
You may need to restart the hal service and the Window System (or just restart
the guest system) to enable the Guest Additions.

Installing graphics libraries and desktop services components ...done.

Note the line

Building the VirtualBox Guest Additions kernel modules ...done.

If it shows done, then virtualbox guest additions are compiled successfully.
Now restart the guest OS.

3. Verify that guest additions are working

After rebooting the OS, the screen resolution of the guest OS should adjust with the window size of virtualbox. Other things like mouse scroller, copy paste from guest to host should also work.

You can verify that the guest additions are loaded with the following command

# check loaded modules
$ lsmod | grep -io vboxguest
vboxguest

# check module 
$ modinfo vboxguest
filename:       /lib/modules/3.13.0-24-generic/updates/dkms/vboxguest.ko
version:        4.3.10
license:        GPL
description:    Oracle VM VirtualBox Guest Additions for Linux Module
author:         Oracle Corporation
.....

$ lsmod | grep -io vboxguest | xargs modinfo | grep -iw version
version:        4.3.10

4. Configure Shared folders

After installing guest additions you can share folders across the guest and host OS, allowing each of them to access each other's files. The folder exists on the host OS and is shared to the guest OS. The guest may or may not be given the permission to write to the shared folder.

Click Devices > Shared folder settings on the virtualbox window. Click the plus icon on the right side and select the directory from the host OS that you want to share with the guest OS.

If you choose "Make permanent" it becomes a Machine folder, else it is a Transient folder. You also have the option to make it read only, so that the guest OS cannot make modifications to the folder.

Once you have specified the shared directory, its time to mount it inside the guest OS. The list of shared folders would show you the name and path of the shared directory. Note down the name, and mount it using the following command

# create a directory in your home directory
$ mkdir shared

# mount using the mount command. SHARENAME is the name of the shared directory
$ sudo mount -t vboxsf SHARENAME ~/shared

# or
$ sudo mount.vboxsf SHARENAME ~/shared

You might comes across the following error message - "mount: wrong fs type, bad option".
Or "The program 'mount.vboxsf' is currently not installed."

This error is caused by a bug in VirtualBox due to which /sbin/mount.vboxsf points to a wrong path.

To fix this, you have to use the full path to the mount.vboxsf command

$ sudo /usr/lib/x86_64-linux-gnu/VBoxGuestAdditions/mount.vboxsf SHARENAME ~/shared

The bug will be fixed in upcoming releases of VirtualBox.

About Silver Moon

A Tech Enthusiast, Blogger, Linux Fan and a Software Developer. Writes about Computer hardware, Linux and Open Source software and coding in Python, Php and Javascript. He can be reached at [email protected].

32 Comments

How to install Virtualbox guest additions on Ubuntu 14.04
  1. Michy

    I followed these steps, the additions are correctly loaded, but still I can’t see the window size scaling or use the mouse. Do you have any idea why this happens?
    Thanks anyway for posting this.

    1. Somebody

      Did you set the VM to use full screen mode ( View > Full Screen Mode (Host+F)). Also make sure you have the latest version of Virtualbox installed.

      Also, there are a number of settings you can adjust on the VM from the main Virtualbox app, such as increasing the Video Memory (Highly recommended), and enabling 2D or 3D acceleration.

  2. Alan Croft

    Hi ..
    When I ran the command “sudo m-a prepare”, it gave error “Symlink creation failed”.

    And the Guest addition did not install.. Can the above error be problem why guest addition did not install?

    Please help me..

  3. phipix01

    thank god finally someone wrote a newb-friendly tutorial!
    couldn’t be written better ;) i appreciate you work sir!

    one simple addition: is there a way to access ubuntu’s guest file system via my windows host?

  4. dc

    first post on this that could be followed and made sense. Thanks! Nice to get shared folders working in 10 minutes after trying for hours.

    1. ANKUSH MENAT

      because this way is for those who need to install guest additions on multiple appliances. So it’s easy to just download it once (iso) and use it with all appliance

  5. Bin

    I tried many other suggestions which did not solve my problem until find yours. Thanks so much!!! Now i can use shared folders.

  6. maastrix

    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    E: Unable to locate package build-essential
    E: Unable to locate package module-assistant

    What’s the issue? Any idea?

  7. Andrew Schwartzmeyer

    That last line there, `sudo /usr/lib/x86_64-linux-gnu/VBoxGuestAdditions/mount.vboxsf backup /mnt/backup`, was exactly what I needed after updating my kernel and installing the latest guest additions. Thank you for the post.

    Out of curiosity, is there anyway to make that a permanent fix? Right now my box hangs on boot because it fails to mount the share and wants me to type something to skip trying to mount it, and there is no timeout.

    1. Silver Moon

      To make the fix permanent, point the /sbin/mount.vboxsf binary to the right executable

      Something like this should work, but I have not tested
      sudo ln -sf /usr/lib/x86_64-linux-gnu/VBoxGuestAdditions/mount.vboxsf /sbin/mount.vboxsf

      1. Andrew Schwartzmeyer

        Ah, close! To repair the, according to the bug report, do ‘sudo ln -s /opt/VBoxGuestAdditions-4.3.10/lib/VBoxGuestAdditions /usr/lib/VBoxGuestAdditions’. That puts it back in place so the original ‘/sbin/mount.vboxsf’ works.

Leave a Reply

Your email address will not be published. Required fields are marked *