How to Install VirtualBox Guest Additions on Ubuntu 18.04

Published on

3 min read

Install VirtualBox Guest Additions on Ubuntu 18.04

VirtualBox is an open-source, cross-platform virtualization software that allows you to run multiple guest operating systems (virtual machines) simultaneously.

VirtualBox provides a set of drivers and applications (VirtualBox Guest Additions) which can be installed in the guest operating system. The Guest Additions offer several useful functionalities for guest machines such as shared folders, shared clipboard, mouse pointer integration, better video support, and more.

In this tutorial, we will show you how to install VirtualBox Guest Additions on Ubuntu 18.04 guests. The same instructions apply for Ubuntu 16.04 and any Ubuntu-based distribution, including Linux Mint and Elementary OS.

Installing Guest Additions on Ubuntu Guest

VirtualBox ships with an image ISO file called “VBoxGuestAdditions.iso” containing Guest Additions installers for all supported guest operating systems. This file is located on the host machine and can be mounted on the guest system using the VirtualBox GUI manager. Once mounted, the guest additions installer can be used to install the guest additions on the guest system.

Below are the step-by-step instructions to install VirtualBox guest additions on Ubuntu guests. These steps will work on both Ubuntu Desktop and Server guest installations.

  1. Open VirtualBox GUI Manager.

  2. Start the Ubuntu guest virtual machine.

  3. Login to the Ubuntu guest as a sudo user and install the packages required for building external kernel modules:

    sudo apt updatesudo apt install build-essential dkms linux-headers-$(uname -r)

    $(uname -r) prints the running Kernel version .

  4. From the virtual machine menu, click Devices -> “Insert Guest Additions CD Image” as shown on the image below:

    Insert Guest Additions CD Image

    If you get an error saying the guest system has no CD-ROM, stop the virtual machine, open the virtual machine settings and from the “Storage” tab, add a new CD-ROM device to the machine by clicking on the plus sign (Adds optical device). Once done, reboot the virtual machine.

  5. Open the Ubuntu guest terminal, create a new directory as the mount point for the CD drive and mount the ISO file:

    sudo mkdir -p /mnt/cdromsudo mount /dev/cdrom /mnt/cdrom
  6. Navigate to the directory and run the VBoxLinuxAdditions.run script to install the Guest Additions. The --nox11 option will tell the installer not to spawn an xterm window:

    cd /mnt/cdromsudo sh ./VBoxLinuxAdditions.run --nox11

    The output will look like below:

    Verifying archive integrity... All good.
    Uncompressing VirtualBox 5.2.32 Guest Additions for Linux........
    ...
    VirtualBox Guest Additions: Starting.
  7. Reboot the Ubuntu guest for changes to take effect:

    sudo shutdown -r now
  8. Once the virtual machine is booted, log into it and verify that the installation was successful and the kernel module is loaded using the lsmod command:

    lsmod | grep vboxguest

    The output will look something like this:

    vboxguest             303104  2 vboxsf

    No output means that the VirtualBox kernel module is not loaded.

    Now that VirtualBox Guest Additions are installed on the Ubuntu guest machine, you can enable Shared clipboard and Drag’n Drop support from the virtual machine settings “Storage” tab, Enable 3D acceleration from the “Display” tab, create Shared folders and more.

Conclusion

Installing VirtualBox Guest Additions on Ubuntu 18.04 virtual machine is an easy task. The Guest Additions will optimize the guest operating system for better performance and enhance usability.

To find more information about the Guest Additions, visit the official VirtualBox Guest Additions documentation page.

If you have any questions, please leave a comment below.