Virtualbox is an open-source Type 2 hypervisor developed by Oracle. It can be used for home and enterprise purposes to create virtual machines that share the host’s resources. This tool was first developed in 2007 and from that time onwards, it has gained high popularity dues to its high performance and rich feature set. Virtualbox is a cross-platform tool that can be installed and used on Windows, Linux, OS/2, Solaris, macOS e.t.c.
Virtualbox Guest Additions comprise a set of drivers and applications with the ability to optimize the performance and usability of the Virtual Machine. They are usually installed inside a Virtual machine after the guest OS has been installed. They offer the following features:
- Mouse pointer integration that provides seamless mouse support. You do not need to press the Host key to prevent the mouse from being captured by the guest OS.
- Drag and drop allows one to copy files between the Host and guest systems.
- Shared clipboard ton allow copy and paste between the host and guest systems.
- Shared folders allow one to share/exchange files between the host and guest systems.
- Time synchronization for better time synchronization between the host and guest.
- Better video support that provides accelerated video performance and automatic resolution adjustment.
- Automated logins also make it possible to automate logins on the guest.
- Seamless Windows that allows seamless running of the guest and host windows
This guide will demonstrate how to install VirtualBox guest additions on Rocky /AlmaLinux 9 and enjoy the extended Virtualbox features.
#1. Installing VirtualBox
Before we begin, you need to have Virtualbox installed on your Rocky Linux 9 / AlmaLinux 9 system. The below guide can be used to achieve this;
Once installed, proceed as shown below
#2. Install Build Tools and Kernel Headers
After installing the Rocky /AlmaLinux 9 as the guest operating system, install the following build tools and kernel headers.
sudo dnf install epel-release -y sudo dnf install dkms kernel-devel kernel-headers gcc make bzip2 perl elfutils-libelf-devel
Ensure that both the kernel-devel versions and the kernel versions are the same:
$ rpm -q kernel-devel kernel-devel-5.14.0-70.17.1.el9_0.x86_64 $ uname -r 5.14.0-70.13.1.el9_0.x86_64
If they do not match, update Kernel:
sudo dnf update -y
Now reboot the system for the changes to apply;
sudo reboot now
Now the two should be of the same version.
#3. Install VirtualBox Guest Additions
Now you are set to install VirtualBox Guest Additions on the Rocky /AlmaLinux 9 VM. There are two ways how you can mount the VirtualBox Guest Additions CD. These are:
- Using the Command-line
- Using the Virtualbox GUI
First, identify the Virtualbox version on the host system:
$ VBoxManage --version 6.1.36r152435
Option 1 – Using the Command-line
From the VM’s command line, download the guest additions. Check out the latest release from the VirtualBox downloads page. You can pull the ISO file using wget to the /tmp directory:
wget https://download.virtualbox.org/virtualbox/<VERSION>/VBoxGuestAdditions_<VERSION>.iso -P /tmp
Example on downloading latest release:
sudo dnf -y install wget curl VER=$(curl -s https://download.virtualbox.org/virtualbox/LATEST.TXT) wget https://download.virtualbox.org/virtualbox/$VER/VBoxGuestAdditions_$VER.iso -P /tmp
Mount the downloaded iso file to /run/media/
sudo mount /tmp/VBoxGuestAdditions_*.iso /run/media/
Install the guest additions in the Rocky /AlmaLinux 9 VM
Verifying archive integrity... All good. Uncompressing VirtualBox 6.1.36 Guest Additions for Linux........ VirtualBox Guest Additions installer Copying additional installer modules ... Installing additional modules ... VirtualBox Guest Additions: Starting. VirtualBox Guest Additions: Building the VirtualBox Guest Additions kernel modules. This may take a while. VirtualBox Guest Additions: To build modules for other installed kernels, run VirtualBox Guest Additions: /sbin/rcvboxadd quicksetup <version> VirtualBox Guest Additions: or VirtualBox Guest Additions: /sbin/rcvboxadd quicksetup all VirtualBox Guest Additions: Building the modules for kernel 5.14.0-70.17.1.el9_0.x86_64.
Power of the VM:
sudo shutdown now
Option 2 – Using the Virtualbox GUI
You can also download the ISO file on your host system and mount it onto your Rocky /AlmaLinux 9 VM:
Navigate to the VM’s Devices tab and load the VirtualBox Guest Additions CD
Once loaded, proceed with the installation as above
#4. Configure VM to use the Guest Additions
Now there are several things we can configure. These are:
- Drag and drop & Shared Clipboard
- USB drive
- Shared Folder
Drag and drop & Shared Clipboard
Navigate to the VM’s settings->General->Advanced settings to enable drag and drop and shared clipboard between the host system and guest.
This allows the host and guest system to access and use a single USB drive. To enable this, navigate to USB, and select the controller. You can now click on + to add the USB device.
This is used to create folder shares between the host and guest system. To configure this, click on Shared Folders and set the host folder to be shared, the share name then the required permissions. You also need to specify a mount point on the VM as shown.
Now power on the VM and enjoy the awesomeness. Once the system powers on, log in and verify if the shared folder is available at /mnt
You can also switch between several view modes.
You can also try drag and drop or the shared clipboard with copy and paste as shown.
The VirtualBox guest additions really play a big role in a closer integration between the host and guest operating systems. Now you can easily use the Rocky /AlmaLinux 9 with the extended Virtualbox featured. I hope this was significant.