Install VirtualBox Guest Additions on Linux guest

If you’re running Linux inside a VirtualBox virtual machine, installing the Guest Additions software will help you get the most out of the system. VirtualBox Guest Additions will give the machine more capabilities, such as a shared clipboard with the host system, drag and drop file transfer, time synchronization, shared folders, automatic window resizing, and more.

This makes copying data to and from a host system much more convenient. It also changes the virutal machine’s resolution automatically when its window is resized, so you do not need to change it manually. Guest Additions will work with just about any Linux distribution, but instrutions can differ because of dependencies and package managers.

In this guide, we’ll be going over the step by step instructions to get VirtualBox Guest Additions installed on Debian based and Red Hat based Linux systems. With these instructions, it doesn’t matter what host system you’re using, as long as the virtual machine is running Linux. This guide assumes that you’ve already installed your Linux operating system in the VM correctly.

In this tutorial you will learn:

  • How to install VirtualBox Guest Addition on Debian based systems
  • How to install VirtualBox Guest Addition on Red Hat based systems
Install VirtualBox Guest Additions on Linux guest
Install VirtualBox Guest Additions on Linux guest
Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Any Debian based or Red Hat based Linux distro
Software Oracle VirtualBox Guest Additions
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

Install VirtualBox Guest Additions on Debian Based distros




If you’re using a Debian based Linux distro, such as Ubuntu, Linux Mint, Elementary OS, etc. The following steps will work for installing VirtualBox Guest Additions.

  1. The first thing we need to do is install a few prerequisite packages. Open a terminal and use your system’s package manager to install them with the following commands.
    $ sudo apt update
    $ sudo apt install build-essential dkms linux-headers-$(uname -r)
    
  2. Next, on the virtual machine window, click on Devices > Insert Guest Additions CD Image.

    Inserting the Guest Additions CD Image in VirtualBox
    Inserting the Guest Additions CD Image in VirtualBox
  3. Instead of running the software on the disc image when the prompt pops up, we will make a new directory to which we can mount the Guest Additions CD Image. Make the directory and then execute the mount command to mount it.
    $ sudo mkdir -p /mnt/cdrom
    $ sudo mount /dev/cdrom /mnt/cdrom
    
  4. Now we can run the software off of the mounted Guest Additions CD image.
    $ cd /mnt/cdrom
    $ sudo ./VBoxLinuxAdditions.run
    

    You should now see VirtualBox Guest Additions being installed. This may take a few minutes.

    The terminal output shows VirtualBox Guest Additions is being installed
    The terminal output shows VirtualBox Guest Additions is being installed
  5. Once the installation is complete, all we need to do now is reboot the system for the new changes to take effect.
    $ reboot
    



  6. That’s all there is to it. When the virtual machine finishes loading back up, you’ll be able to utilize the shared clipboard, drag and drop function, automatic resolution resizing, and other features mentioned earlier. Make sure you enable the shared clipboard and drag and drop option if you wish to use them, from inside the Devices menu.

    Enable the shared clipboard and drag and drop features from the Devices menu
    Enable the shared clipboard and drag and drop features from the Devices menu
  7. To verify successful installation of VirtualBox Guest Additions, you can run the following lsmod command in terminal. As long as you receive some output similar to that in the screenshot below, then Guest Additions is installed and running.
    $ lsmod | grep vboxguest
    

    Verifying successful installation of VirtualBox Guest Additions with the lsmod command
    Verifying successful installation of VirtualBox Guest Additions with the lsmod command

Install VirtualBox Guest Additions on Red Hat Based distros

If you’re using a Red Hat based Linux distro, such as Fedora, AlmaLinux, CentOS, Rocky Linux, etc. The following steps will work for installing VirtualBox Guest Additions.

  1. The first thing we need to do is install a few prerequisite packages. Open a terminal and use your system’s package manager to install them with the following commands.
    $ sudo dnf install tar bzip2 kernel-devel kernel-headers perl gcc make elfutils-libelf-devel
    



  2. Next, on the virtual machine window, click on Devices > Insert Guest Additions CD Image.

    Inserting the Guest Additions CD Image in VirtualBox
    Inserting the Guest Additions CD Image in VirtualBox
  3. Instead of running the software on the disc image when the prompt pops up, we will make a new directory to which we can mount the Guest Additions CD Image. Make the directory and then execute the mount command to mount it.
    $ sudo mkdir -p /mnt/cdrom
    $ sudo mount /dev/cdrom /mnt/cdrom
    
  4. Now we can run the software off of the mounted Guest Additions CD image.
    $ cd /mnt/cdrom
    $ sudo ./VBoxLinuxAdditions.run
    

    You should now see VirtualBox Guest Additions being installed. This may take a few minutes.

    The terminal output shows VirtualBox Guest Additions is being installed
    The terminal output shows VirtualBox Guest Additions is being installed
  5. That’s all there is to it. When the virtual machine finishes loading back up, you’ll be able to utilize the shared clipboard, drag and drop function, automatic resolution resizing, and other features mentioned earlier. Make sure you enable the shared clipboard and drag and drop option if you wish to use them, from inside the Devices menu.


    Enable the shared clipboard and drag and drop features from the Devices menu
    Enable the shared clipboard and drag and drop features from the Devices menu
  6. To verify successful installation of VirtualBox Guest Additions, you can run the following lsmod command in terminal. As long as you receive some output similar to that in the screenshot below, then Guest Additions is installed and running.
    $ lsmod | grep vboxguest
    

    Verifying successful installation of VirtualBox Guest Additions with the lsmod command
    Verifying successful installation of VirtualBox Guest Additions with the lsmod command

Closing Thoughts

In this guide, we saw how to install VirtualBox Guest Additions on a Debian based or Red Hat based virtual machine. VirtualBox’s Guest Additions software makes virtual machines much easier to use. You now know how to manually install the Guest Additions software, as well as enable its features from inside the VirtualBox menus.



Comments and Discussions
Linux Forum