This article will describe how to install or update VirtualBox Guest Additions in Linux, showing the commands you need to run.
VirtualBox is a free, open source virtualization platform that allows you to create virtual machines that run on your Linux system. These virtual machines act just like their own self-contained computers, and can run other Linux distributions, or even other operating systems entirely, such as Windows, or MS-DOS.
Virtual Machines – Hosts vs Guests
In virtualization terminology, the Host is the computer that runs a virtual machine, and a Guest is the virtualized computer running in the virtual machine.
The VirtualBox software is installed on the host, and is used to manage and run guest virtual machines.
VirtualBox Guest Additions
The VirtualBox Guest Additions is a software package that is installed on the Guest – the virtual machine. It provides drivers to make the guest operating system run properly – allowing it to use the virtual network interface and fully utilize the system resources allocated to it, as well as extra software to make working with the virtual machine easier, such as sharing folders between the guest and host, or allowing your mouse-pointer to move seamlessly between the two.
Installing VirtualBox Guest Additions
Here are the steps you need to follow to install the guest additions in Linux – we’ll do it from the command line, so it will work on both desktop and server distributions.
All of the following commands are to be run on the guest!
Installing Requirements – Red Hat Linux
First, you’ll need to run the following command to install the software required to build and install the guest additions package:
sudo dnf install tar bzip2 kernel-devel kernel-headers perl gcc make elfutils-libelf-devel
If you do not do this, you’ll get an error about not being able to build kernel modules, and the guest additions will not be fully installed.
Installing Requirements – Ubuntu/Debian Linux
If you’re on Ubuntu/Debian, run the following to install dependencies:
sudo apt install build-essential dkms linux-headers-generic
Attach the VirtualBox Guest Additions CD Image
VirtualBox Guest Additions are supplied in a CD image with VirtualBox, and are available to every virtual machine that you create. To attach the CD image so that the guest can read it, open your virtual machine and click Devices in the menu bar, then click Insert Guest Additions CD Image….
Mount the CD Image
If the image does not mount automatically (likely the case if you are using a server-focussed Linux distribution), mount it by running the following commands:
mkdir /media/cdrom sudo mount /dev/cdrom /media/cdrom
Then, navigate to the mounted CD-ROM by running:
cd /media/cdrom
Install VirtualBox Guest Additions for Linux
Finally, run the following command to perform the installation:
sudo ./VBoxLinuxAdditions.run
You will see something like the following to indicate that the installation has started:
Verifying archive integrity... All good. Uncompressing VirtualBox 6.1.40 Guest Additions for Linux. VirtualBox Guest Additions installer
Additional output will be presented, and the process may take several minutes.
When the installation has successfully completed, reboot:
sudo reboot
You can confirm the modules have been installed successfully by running:
lsmod -l | grep -io vboxguest