Install VirtualBox Guest Additions on Ubuntu 20.04

Introduction

In this guide I will be showing you the process for installing VirtualBox Guest Additions on Ubuntu 20.04. This will include the following

  • Installing packages required for building Guest Additions
  • Building and installing Guest Additions

Install Prerequisites

In order to build and install Guest Additions, you will require the following packages.

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

Install Guest Additions

Now, you will need to make sure that you have mounted the Guest Additions CD. This can be done from within VirtualBox by going to Devices -> Install Guest Additions CD image. If you have done this, great, you're done! If you did this previously and it is already mounted, you need to find out where it is mounted. Try checking these locations:

ls /media/$USER/VBox*
ls /media/cdrom*/VBox*

For me, this was mounted at /media/user/VBox_GAs_6.1.8/. Once you've found it, you can run it. Make sure to substitude in the appropriate directory but for most, this should work:

sudo /media/$USER/VBox*/VBoxLinuxAdditions.run

If you get the following error
sudo: unable to execute VBoxLinuxAdditions.run: Permission denied then you will need to copy this to another folder and execute it from there.

cp /media/$USER/VBox*/VBoxLinuxAdditions.run ~/
chmod +x ~/VBoxLinuxAdditions.run
sudo ~/VBoxLinuxAdditions.run

After installing, you can remove the file again and reboot

rm ~/VBoxLinuxAdditions.run

After a reboot, your VM should now have Guest Additions installed!