Skip to Content

How to Install VirtualBox Guest Additions in Ubuntu 20.04?

How to Install VirtualBox Guest Additions in Ubuntu 20.04?

The VirtualBox guest additions are like a driver installed on a PC. It improves the virtual machine’s performance and allows easy usability of the virtual machine.

In the last couple of blogs, we have taken a look at how you can install ubuntu desktop and Server on VirtualBox. In this blog, we will look at how you can install virtual box guest additions on the Ubuntu VM in VirtualBox.

Read also,

How to Install Ubuntu 20.04 Server on VirtualBox?
How to Install Ubuntu 20.04 Desktop on VirtualBox?
When you install the Ubuntu Desktop/Server on the VirtualBox, it comes pre-installed with the VirtualBox guest additions, but that’s not always up to date with the software you have available on the VirtualBox hypervisor.

So follow the steps below to install the guest additions on Ubuntu.

What are the benefits of VirtualBox guest additions?

The Virtualbox guest additions provide better integration with the host and the guest operating system. And also improve the performance of the virtual machine. Below are the benefits you get when installing the VirtualBox guest additions on the virtual machine.

Mouse Pointer Integration, Shared folder, Better video support, Seamless windows, Generic host/guest communication channels, Time synchronization, Shared clipboard, Automated logins

You can learn more about the VirtualBox guest additions here.

The installation of the Virtualbox guest additions can be performed using GUI or with the CLI. The GUI installation usually happens on Ubuntu Desktop but can be done on the Server as well, as long as it has a GUI.

The VirtualBox guest additions installation using GUI is pretty straightforward. And it include only 2-3 steps.

  • Power on the Ubuntu virtualbox.
  • Insert the virtualbox Guest-additions.iso ->Devices-> Insert Guest Additions CD image..
install virtualbox guest additions ubuntu 20.04
  • After a second or two, you will get a pop-up to install the guest additions. You may click on Run.
install virtualbox guest additions ubuntu 20.04
  • Reboot the machine and done.

However, that’s not the case with installing guest additions on the CLI-based machine, for example, on a Ubuntu server.

Install VirtualBox guest additions using CLI.

You may not always have the luxury of GUI access. At that point, you will have to rely on the CLI itself. For example, by default Ubuntu server doesn’t have GUI access. It has only CLI. So let’s take a look at how you can install VirtualBox guest additions on an Ubuntu machine that has only CLI.

Note: The below steps can be performed on both the GUI and on the CLI, while performing on GUI, you will have to enter the command in the terminal.

  • After the Ubuntu server installation, you may power on the virtual machine.
  • You will be required to install two packages, VirtualBox guest utils, and dkms.
  • Enter the command below to install both packages.
sudo apt-get update
sudo apt install virtualbox-guest-utils virtualbox-guest-dkms -y
  • After both the packages are installed, click on Devices -> Insert Guest Additions CD Image..

We have attached the Guest additions iso into the virtual machine, and It has a script to install the VirtualBox guest additions.

The file is now located in the CDROM of the Ubuntu machine.

So create a directory called CDROM in the MNT directory and mount the virtual CDROM to that directory.

sudo mkdir /mnt/cdrom
sudo mount /dev/cdrom /mnt/cdrom

Run the list command to see the list of files in the mounted CDROM.

As you can see, you will have VirtualBox guest additions packages that are available for pretty much all the operating systems. Since we are using Ubuntu, you will have to run the script vboxlinuxAdditions.run

You can either go to the mounted directory and run the command from there or anywhere on the Ubuntu virtual machine as long as you point the command to right directory.

Run the command as below to install the Vbox Linux guest additions.

sudo /mnt/cdrom/VBoxLinuxAdditions.run

After the command is completed, you will see two modules shown below are loaded in the Ubuntu virtual machine. To see the kernel modules you can type lsmod on the VirtualBox.

vboxvideo
drm_vram_helper

 In order for the changes to take affect you will be required to restart the virtual machine.

That’s it we have successfully installed the virtualbox guest additions on the Ubuntu virtual machine. You may observe the gain in performance on the virtual machine afterwards.

How to uninstall VirtualBox guest additions from your Ubuntu virtual machine?

Sometimes, you require the Virtualbox guest additions to be removed when things don’t work fine.

Follow the steps here to successfully remove the VirtualBox guest additions from the Ubuntu desktop and the Server.

  • Like we did in the previous guest additions installation procedure, you will have to insert the guest additions iso file, by clicking Device-> Insert Guest additions CD image.

Note: If you have already attached the CDROM you will get the below error message, which says ‘Unable to insert the virtual optical disk……’ which means you already attached the Virtualbox guest additions to the virtual machine.

So you may ignore the error and go to the next step.

How to uninstall VirtualBox guest additions from your Ubuntu virtual machine?

Sometimes, you require the Virtualbox guest additions to be removed when things don’t work fine.

Follow the steps here to successfully remove the VirtualBox guest additions from the Ubuntu desktop and the Server.

  • Like we did in the previous guest additions installation procedure, you will have to insert the guest additions iso file, by clicking Device-> Insert Guest additions CD image.

Note: If you have already attached the cdrom you will get the below error message, which says ‘Unable to insert the virtual optical disk……’ which means you already attached the virtualbox guest additions to the virtual machine.

So you may ignore the error and go to the next step.

  • Mount the virtual CDROM to the mnt directory.

If you don’t have a CDROM directory in the MNT directory, you may create one.

sudo mkdir /mnt/cdrom
sudo mount /dev/cdrom /mnt/cdrom
  • Run the VirtualBox guest addition run script with uninstalling command at the end.
  • I went to the /mnt/cdrom directory.
  • Issue the command as below.
sudo ./VBoxLinuxAdditions.run uninstall

The VirtualBox guest additions will now be uninstalled, you may go ahead and reboot the virtual machine for the changes to take effect.