How to install VirtualBox Guest Additions in Ubuntu 20

How to install VirtualBox Guest Additions in Ubuntu 20.04

This article will step through how to install VirtualBox Guest Additions in Ubuntu Desktop 20.04 running on Windows 10. For this tutorial I will be using Windows 10 Pro 64-bit (the host) and will describe how to install VirtualBox Guest Additions in Ubuntu Desktop 20.04.1 (the guest).

VirtualBox Guest Additions provides enhanced functionality for using Ubuntu in VirtualBox, such as improved graphic support for dynamic resizing of the VM window, shared clipboard support, shared folders, and enhanced mouse/keyboard integration.

For these steps I am using VirtualBox 6.1.14. If you haven’t already installed Ubuntu in VirtualBox then see my article here: Install Ubuntu 20 in VirtualBox.

Step 1: Update Ubuntu

First, make sure Ubuntu has the latest updates. Open a terminal and enter the below commands:

sudo apt-get update
sudo apt-get upgrade

Enter your password when prompted.

If any updates were installed then you will need to restart Ubuntu after the updates have been applied.

Step 2: Install required packages

VirtualBox Guest Additions requires some additional packages to be installed in Ubuntu.

If you try to install Guest Additions without these additional packages you will get an error like the below:

    This system is currently not set up to build kernel modules.
    Please install the gcc make perl packages from your distribution.

Guest Additions error message

To avoid this, open a new terminal and enter the below command to install the required packages:

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

Restart Ubuntu once the install is complete.

Step 3: Install Guest Additions

  1. Ensure Ubuntu is running and you are logged in.

  2. From the VirtualBox menu, select Devices > Insert Guest Additions CD image…

    Note: If you get an error in this step, see the Troubleshooting section below.

    VirtualBox insert guest cd image

  3. The software will automatically start. In the prompt, click Run.

    Guest Additions run prompt

  4. Enter your password and click Authenticate.

    Root user password prompt

  5. A new terminal window will open and the installation will proceed.

    Note: This step may take several minutes to complete.

    Terminal Guest Additions installation

  6. Once the install is complete, hit Enter to close the terminal window.

  7. Restart Ubuntu.

You have now successfully installed VirtualBox Guest Additions in Ubuntu 20.

Troubleshooting

You may get an error when selecting Devices > Insert Guest Additions CD image…:

Unable to insert the virtual optical disk C:\Program Files\Oracle\VirtualBox\VBoxGuestAdditions.iso into the machine Ubuntu 20 LTS.
Could not mount the media/drive 'C:\Program Files\Oracle\VirtualBox\VBoxGuestAdditions.iso' (VERR_PDM_MEDIA_LOCKED).

VirtualBox mount error

In this case, you may already have media loaded which will need to be removed before you can proceed.

Click OK to close the error message window.

In VirtualBox, navigate to Devices > Optical Drives > Remove disk from virtual drive.

VirtualBox remove disk

If prompted, click Force Unmount.

VirtualBox force unmount prompt

Resume the above steps from Devices > Insert Guest Additions CD image….