- Setting up VirtualBox Guest Additions
- For recent guest OSs
- Ubuntu or similar
- Getting VBoxGuestAdditions.iso
- Making VBoxGuestAdditions.iso visible to the guest
- Executing install script for Guest Additions on older Linux guests
- References
- Install the VirtualBox guest additions in Ubuntu 22.04
- Background
- What do you need
- Update your Ubuntu operating system
- Install the dependencies for building kernel modules
- Insert the VirtualBox guest additions CD image
- Install the VirtualBox guest additions in Ubuntu
- Checking the VirtualBox guest additions
- Enable the bi-directional clipboard
- Enable shared folders
- Wrap up
Setting up VirtualBox Guest Additions
Guest Additions are distributed on their own CD image (.iso file) named VBoxGuestAdditions.iso. How you get that file to the guest can depend on the OS of the guest — see below.
After installing Guest Additions, on some, older guests you might need to restart the guest.
For recent guest OSs
In the guest virtual machine, choose Devices -> Install Guest Additions from the menubar of VirtualBox.
VirtualBox will look for the needed file. Failing to find it, it may give you an opportunity to download the file from the internet.
If all that fails, follow one of the steps below.
Ubuntu or similar
Getting VBoxGuestAdditions.iso
- Download a VirtualBox package from https://www.virtualbox.org/wiki/Downloads (you might have installed this package when you installed VirtualBox). The package should include the VBoxGuestAdditions.iso file.
- Open http://download.virtualbox.org/virtualbox/ and enter the subdirectory for the latest version of VirtualBox. It should contain the corresponding VBoxGuestAdditions_X.Y.Z.iso file.
- Install a package through the usual channels for your distribution. For example, you might use:
sudo apt-get install virtualbox-guest-additions-iso
Some, recent versions of VirtualBox will now be able to find the file on the host when you choose Device -> Install Guest Additions on the VirtualBox running a guest. Continue with instructions for setting up file sharing.
For other, older versions of guest OS’s and VirtualBox, the .iso file is on the host, but the guest needs to see it (and file sharing is not yet enabled.) Follow the next two steps for mounting the .iso file and executing the scripts in the .iso file.
Making VBoxGuestAdditions.iso visible to the guest
Just as you mounted a .iso CD image for your guest OS when installing it on the guest, now mount VBoxGuestAdditions.iso as a CD on the guest. For example, in the VirtualBox window, choose the Storage section under Details, and so forth.
Note that recent versions of VirtualBox have changed the method of mounting .iso files.
Executing install script for Guest Additions on older Linux guests
Make sure you have the image, for example VBoxGuestAdditions.iso or VBOXADDITIONS, mounted as CDROM.
If you are running a Linux guest, open a terminal and type:
in for instance Ubuntu Lucid, the CD image should mount at /media/ so that would be
sudo sh ./VBoxLinuxAdditions.run
If you would like to uninstall the Guest Additions, run:
sudo sh ./VBoxLinuxAdditions.run uninstall
References
VirtualBox/GuestAdditions (последним исправлял пользователь 78-0-208-105 2012-10-20 16:28:08)
The material on this wiki is available under a free license, see Copyright / License for details
You can contribute to this wiki, see Wiki Guide for details
Install the VirtualBox guest additions in Ubuntu 22.04
Bummed that you can’t change the screen resolution in your freshly installed Ubuntu virtual machine? An easy fix exists for this: You just need to install the VirtualBox guest additions in your Ubuntu 22.04 VirtualBox virtual machine. Besides automatically adjusting the screen resolution, you also get support for a bi-directional clipboard and shared folders. This article explains how to install the VirtualBox guest additions in an Ubuntu 22.04 virtual machine.
Background
In you ever installed Ubuntu in a VirtualBox virtual machine, you probably noticed that you can’t change the screen resolution. For example after resizing the virtual machine window or going into full-screen mode. The reason for this is that the Ubuntu 22.04 installer does not install the so called VirtualBox guest additions.
The VirtualBox guest additions consist of a set of drivers and kernel modules for the operating system, when installed as a VirtualBox virtual machine. They offer quality of life type improvements for working with your virtual machine:
- Improved display driver that automatically adjusts the screen resolution, when resizing the window of the virtual machine.
- Bi-directional clipboard for copy-pasting text between the host and the guest operating system.
- Shared folders for exchanging files between the host and the guest operating system.
Because of these added benefits, I highly recommend installing the VirtualBox guest additions right after you finished installing Ubuntu in a VirtualBox virtual machine. This tutorial walks you through the steps of how to install the VirtualBox guest additions in an Ubuntu virtual machine.
What do you need
In this article, I’ll explain step-by-step how to install the VirtualBox guest additions for an Ubuntu virtual machine. This assumes that you already installed Ubuntu as a virtual machine in VirtualBox. The presented instructions work for any type of Ubuntu flavor or derivative, for example Xubuntu, Linux Mint and Pop!_OS.
At the time of this writing, Ubuntu 22.04 is the latest long term support (LTS) release. In preparation for this article, I created a VirtualBox virtual machine based on Xubuntu 22.04. The XFCE desktop environment feels nice and snappy, especially on a resource constrained virtual machine.
Update your Ubuntu operating system
Before installing anything on your Ubuntu system, you should always update the operating system first. Why? Because package dependencies might have changed since your last update. This could lead to potential installation issues when installing new software.
To update the currently installed packages on your Ubuntu system, start the virtual machine and run the following two commands from the terminal:
Install the dependencies for building kernel modules
The VirtualBox guest additions for Linux consist of a bunch of Linux kernel modules. When installing the VirtualBox guest additions, these kernel modules are automatically built, specifically for the kernel version currently running in Ubuntu. Building kernel modules requires certain software packages. Therefore we need to first install these, prior to installing the VirtualBox guest additions in Ubuntu.
With your Ubuntu virtual machine running, open the terminal and run the following commands. This installs the required software packages for building kernel modules:
Insert the VirtualBox guest additions CD image
The guest additions CD image holds the installer for the VirtualBox guest additions. This CD image ships with VirtualBox. So there is no need to separately download this CD image. As a first step in installing the VirtualBox guest additions, you need to insert the guest additions CD image into the virtual CD drive of your Ubuntu virtual machine. As shown in the screenshot, you achieve this by selecting Devices → Insert Guest Additions CD Image from the menu of your Ubuntu virtual machine:
Give Ubuntu a few seconds time to automatically mount the CD image. Once mounted, Ubuntu opens up the file manager, showing you the CD contents.
Install the VirtualBox guest additions in Ubuntu
After Ubuntu mounted the guest additions CD, open up your terminal program. Then change to the directory where Ubuntu mounted the CD image of the VirtualBox guest additions. If you don’t remember the mount point, you can find out by running command:
- lsblk | grep «rom»
Alternatively and in my opinion easier: Simply right-click on the white space in the file manager, which popped up after Ubuntu mounted the CD. Then select Open Terminal Here from the context menu:
When you opened the terminal in the directory of the VirtualBox guest additions CD, start the VirtualBox guest additions installer, by running command:
Follow the installation progress on the terminal screen. Once done, you just need to restart your Ubuntu virtual machine, to activate the newly built and installed kernel modules.
Checking the VirtualBox guest additions
How do you know if the installation for the VirtualBox guest additions was successful for your Ubuntu virtual machine? It installed an improved display driver that allows automatic screen resolution adjustment. To test this, you simply resize the windows of your Ubuntu virtual machine. Then check if the screen resolution properly changed.
In my case, I switched the Ubuntu virtual machine window to full screen and checked the screen resolution in the Display section of the XFCE Settings application:
The screen resolution of 1920 x 1080 resembles what I expect for my monitor. In conclusion, this verifies that the VirtualBox guest additions were successfully installed on my Ubuntu virtual machine.
Enable the bi-directional clipboard
In addition to an improved display driver, the VirtualBox guest additions offer a bi-directional clipboard. This allows you to copy-paste text between the host operating system and your Ubuntu virtual machine. You just need to enable this feature. From the menu of your Ubuntu virtual machine, select Devices → Shared Clipboard → Bidirectional:
From now on both your host operating system and your guest operating system can access text on the clipboard.
Enable shared folders
A feature I use myself quite often, is the VirtualBox shared folders. With the help of the VirtualBox shared folders, you can select a directory on your host operating system. Your Ubuntu virtual machine then automatically mounts this directory. Effectively, this means that you can exchange files between your host operating system and your Ubuntu virtual machine, through this selected directory.
Getting shared folders to work, is a bit trickier. For these reason, I dedicated an entire article towards the topic of how to mount a shared folder in VirtualBox. In this section, I’ll summarize how to setup a shared folder.
The first thing to do is add your user to the group vboxsf . Otherwise you user does not have permissions to access the shared folder. Inside your Ubuntu virtual machine, open a terminal and run this command:
Next reboot your Ubuntu virtual machine, to activate these user and group changes.
Once the reboot completed, open the shared folders settings by selecting Devices → Shared Folders → Shared Folders Settings from the Ubuntu virtual machine menu. Continue by adding a shared folder on this settings dialog and make sure to enable the Auto-mount option. Enable Make Permanent if you want the shared folder to persist with each reboot. I typically select my user’s Desktop folder as the directory to share:
If you now open the file manager on your Ubuntu virtual machine, you’ll notice that you can immediately access the shared folder. Its name is sf_ . In my case sf_Desktop :
Wrap up
The VirtualBox guest additions make working with your Ubuntu virtual machine more pleasant. Its most prominent features are:
- An improved display driver that supports automatic screen resolution changes.
- A bi-directional clipboard for copy-pasting text between the host and the guest operating system.
- One or more shared folders to exchange files between the host and guest operating system.
Your Ubuntu virtual machine does not offer the VirtualBox guest additions by default. Therefore, it is recommended to install the VirtualBox guest additions, after you completed a fresh installation of Ubuntu in your virtual machine.
This article showed you step-by-step how to install the VirtualBox guest additions in an Ubuntu virtual machine. As whip-cream on top, you also learned how to enable the bi-directional clipboard and setup shared folders.
You can find more Ubuntu and VirtualBox related articles here: