VirtualBox, an open-source virtualization software, enables users to run multiple guest virtual machines on a single computer, regardless of the operating system.

For instance, if VirtualBox is installed on a Linux system, it allows running guest operating systems like Windows as virtual machines. Similarly, on a Windows system, Linux OS can be run as a guest operating system, providing flexibility and versatility. The number of guest operating systems that can be installed and operated depends primarily on available disk space and memory.

Recently, Oracle released VirtualBox 7.0, a significant stable version that introduces numerous notable changes and exciting new features. For a comprehensive overview of the updates, users can refer to the Official Changelog Page provided by VirtualBox.

This guide offers step-by-step instructions on installing VirtualBox 7.0 on RHEL-based distributions, including RHEL, Fedora, Rocky Linux, AlmaLinux, and CentOS Stream. The installation process involves utilizing VirtualBox’s dedicated repository and employing YUM and DNF commands. Furthermore, the guide also covers the installation of VirtualBox 7.0 on Debian-based distributions like Debian, Ubuntu, and Linux Mint, utilizing VirtualBox’s repository in conjunction with APT-GET or APT commands.

Installing VirtualBox 7.0 in RHEL-based Systems

To install the latest stable version of VirtualBox, you need to first download the virtualbox.repo configuration file using the following wget command and then import the public key using the rpm command.

----------------- On RHEL-based Distributions ----------------- 
# wget https://download.virtualbox.org/virtualbox/rpm/rhel/virtualbox.repo -P /etc/yum.repos.d/
# rpm --import https://www.virtualbox.org/download/oracle_vbox.asc

----------------- On Fedora Linux -----------------
# wget http://download.virtualbox.org/virtualbox/rpm/fedora/virtualbox.repo -P /etc/yum.repos.d/
# rpm --import https://www.virtualbox.org/download/oracle_vbox.asc

Next, enable the EPEL repository to install build tools and dependencies on the system.

----------------- On RHEL-based 9 Release ----------------- 
# dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm

----------------- On RHEL-based 8 Release ----------------- 
# yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

----------------- On RHEL-based 7 Release ----------------- 
# yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

Install Dependency Packages for VirtualBox

VirtualBox relies on the vboxdrv kernel module to manage and allocate physical memory for guest operating systems’ execution. In the absence of this module, VirtualBox can still be used for virtual machine creation and configuration, but the virtual machines will be non-functional.

To ensure the full functionality of VirtualBox, it is necessary to update your system and subsequently install additional modules, including DKMS, kernel-headers, kernel-devel, and relevant dependency packages. These components are crucial for proper integration with your system and seamless operation of VirtualBox.

----------------- On RHEL-based Distributions ----------------- 
# yum update
# yum install binutils kernel-devel kernel-headers libgomp make patch gcc glibc-headers glibc-devel dkms -y

----------------- On Fedora Linux -----------------
# dnf update
# dnf install @development-tools
# dnf install kernel-devel kernel-headers dkms qt5-qtx11extras  elfutils-libelf-devel zlib-devel

Install VirtualBox 7.0 in RHEL-based Systems

After successfully installing all the necessary dependency packages, you can proceed with the installation of the latest version of VirtualBox by executing the following command:

# dnf install VirtualBox-7.0
OR
# yum install VirtualBox-7.0

At this stage, you can start using VirtualBox by executing the following command in the terminal:

# virtualbox

If you encounter the following error during the VirtualBox installation, it means there is a conflict between the two Kernel versions.

This system is currently not set up to build kernel modules.
Please install the Linux kernel "header" files matching the current kernel

To resolve the issue, first, check your installed kernel and then update the Linux kernel by running the command:

# uname -r
# dnf update kernel-*
Or
# yum update kernel-*

After the update is complete, it is recommended to reboot your system to apply the changes. During the boot process, you will be presented with the GRUB boot menu, where you can select the latest kernel version. In most cases, the latest kernel entry will be listed as the first option.

To reboot and select the latest kernel from the GRUB boot menu, follow these steps:

Save any unsaved work and close all applications.

Restart your system by running the following command:

# reboot


Once your system has finished booting and you have logged in, you can confirm that the kernel-devel version now matches the version of the Linux kernel

# rpm -q kernel-devel
# uname -r

Then, re-start the build set-up process and confirm that your VirtualBox installation was successful by running:

# /sbin/vboxconfig
# systemctl status vboxdrv

Troubleshooting

If you encounter an error message related to KERN_DIR or if the kernel source directory is not automatically detected during the build process, you can manually set it by using the following command:

# KERN_DIR=/usr/src/kernels/4.19.0-1.el7.elrepo.x86_64
# export KERN_DIR

Installing VirtualBox 7.0 in Debian, Ubuntu, and Linux Mint

To install the latest stable version of VirtualBox, you can add the official VirtualBox repository by using the following command:

$ wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
$ wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add -
$ sudo apt install software-properties-common
$ echo "deb [arch=amd64] https://download.virtualbox.org/virtualbox/debian $(lsb_release -sc) contrib" | sudo tee /etc/apt/sources.list.d/virtualbox.list

Then, update the software package list and install the latest version of VirtualBox.

$ sudo apt-get install virtualbox-7.0

To start VirtualBox from the terminal, you can simply execute the following command:

virtualbox

This command will launch VirtualBox and open the graphical user interface (GUI), allowing you to manage and operate your virtual machines.

Alternatively, if you prefer to use the launcher from the menu, you can search for “VirtualBox” in your system’s application menu or launcher. Click on the VirtualBox icon to start the application.

Both methods will initiate VirtualBox and provide you with the necessary interface to create, configure, and control your virtual machines.

Installing VirtualBox Extension Pack in Linux

To obtain additional functionality in VirtualBox, such as VirtualBox RDP, PXE, ROM with E1000 support, and USB 2.0 Host Controller support, you can download and install the VirtualBox Extension Pack. Use the provided wget command to initiate the download:

# wget https://download.virtualbox.org/virtualbox/7.0.0/Oracle_VM_VirtualBox_Extension_Pack-7.0.0.vbox-extpack

To install the extension pack, you must have Virtualbox 7.0 installed, once you downloaded vbox-extpack open with Virtualbox as shown below.

If it doesn’t work out, then open Virtualbox –> File –> Preferences –> Tools –> Extension Manager and browse for the vbox-extpack to install it.

Updating VirtualBox in Linux Systems

To update VirtualBox to the latest version in the future, you can use the following command:

On RHEL-based Systems

# yum update VirtualBox-*
On Debian-based Systems
# apt-get install VirtualBox-*

Remove VirtualBox from Linux Systems

To remove VirtualBox completely from your system, you can use the following commands based on your system’s package manager:

On RHEL-based systems:

sudo rm -rf /etc/yum.repos.d/virtualbox.repo
sudo yum remove VirtualBox-*

On Debian-based systems:

sudo apt-get remove VirtualBox-*

Please note that running these commands will remove VirtualBox and its associated packages from your system. Make sure to back up any important virtual machines or data before proceeding with the removal.

Comments to: How to Install VirtualBox 7.0 on RHEL and Debian-Based Distributions

    Your email address will not be published. Required fields are marked *