How To Install VirtualBox 7.0 on Rocky Linux 9 / AlmaLinux 9

Posted on 235 views

Virtualization is one of the oldest technology in the tech field but is still very useful up to date. It can simply be defined as dividing and sharing the resources of a computer locally. This helps in creating virtual/software versions of the resources on a system such as storage, networks, applications e.t.c.

Many people/organizations use Virtualization in different methods to divide a single machine into several VMs that run independently. For virtualization to occur, a Hypervisor is required. There tow major types of Hypervisors, i.e

  • Type 1/Bare Metal Hypervisors: They are normally installed directly on a physical machine. They include the open-source Kernel-based VMs (KVMs), VMware ESXi, Microsoft Hyper-V e.t.c
  • Type 2/Hosted Hypervisors: They earn the name “hosted” because they are installed on top of an Operating system. These include the Oracle VirtualBox and VMware Workstation

In this guide we will learn how to install and use VirtualBox 7.0 on Rocky Linux 9 / AlmaLinux 9.

What is VirtualBox?

Virtualbox is an open-source hosted/type 2 hypervisor for both enterprise and home use. It can be used to create and run Virtual Machines on an Operating system such as Windows, Linux, OS/2, Solaris, macOS e.t.c. This tool was first released in 2007. It not only offers high performance but also a rich feature set.

The latest release version is 7.0, which was made in October 2022. The cool features associated with VirtualBox 7.0 are:

  • Virtual machines can be fully encrypted now, including the VM config logs and saved states (CLI only for now)
  • Added a new GUI utility which lists performance statistics (CPU usage, RAM usage, disk I/O rate, etc.) of running guests
  • Improved GUI theme support on all platforms – Linux and macOS use native engine while for Windows host it is separately implemented.
  • Implemented initial support for automatic updating of Guest Additions for Linux guests
  • Implemented ability to wait for and/or reboot the guest when updating Guest Additions via VBoxManage
  • Linux Guest Additions: Reworked guest screen re-size functionality, added basic integration with some of guest Desktop Environments
  • Implemented new 3D support based on DirectX 11 (and DXVK on non Windows hosts)
  • Added virtual TPM 1.2 and 2.0 devices
  • Added EFI support for Secure Boot
  • The EHCI and XHCI USB controller devices are now part of the open source base package
  • Added experimental support for guest debugging through GDB and highly experimental support for guest debugging through KD/WinDbg
  • Cloud virtual machines can be added to Virtual Machine Manager and controlled as local VMs
  • Cloud networks can now be configured via Network Manager tool same way as it is done for Host-only and NAT networks

Install VirtualBox 7.0 on Rocky Linux 9 / AlmaLinux 9

In order to install VirtualBox on your system, you need to ensure that Virtualization is enabled on your processor. This is normally made in BIOS/UEFI configurations. To check if it is enabled, execute the command:

$ lscpu | grep Virtualization
Virtualization:                  VT-x
Virtualization type:             full

Also, verify that you are running a 64-bit system.

$ lscpu
Architecture:            x86_64
  CPU op-mode(s):        32-bit, 64-bit
  Address sizes:         39 bits physical, 48 bits virtual
  Byte Order:            Little Endian
CPU(s):                  1
  On-line CPU(s) list:   0
Vendor ID:               GenuineIntel
  Model name:            Intel(R) Xeon(R) CPU E3-1275 v5 @ 3.60GHz
    CPU family:          6
    Model:               94

#1. Add Virtualbox Repository

Virtualbox does not reside in the default Rocky /AlmaLinux 9 repositories. To be able to install it, you need to add the official repositories.

First, enable the EPEL repository:

sudo dnf install epel-release -y

Install the required build tools:

sudo dnf install wget curl gcc make perl bzip2 dkms kernel-devel kernel-headers  -y

Once installed, compare the kernel-devel versions and the kernel versions:

$ 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

Since the two do not match, we need to update the Linux Kernel

sudo dnf update -y

Reboot the system for the Kernel updates to apply:

sudo reboot now

Once the system boots, verify if the Kernel and kernel-devel are of the same version. Then add the VirtualBox repositories to the system:

sudo dnf config-manager --add-repo=https://download.virtualbox.org/virtualbox/rpm/el/virtualbox.repo

#2. Install VirtualBox 7.0 on Rocky /AlmaLinux 9

Once the repository has been added, identify the available VirtualBox versions

dnf search virtualbox

Sample Output:

================================================================================= Name & Summary Matched: virtualbox =================================================================================
VirtualBox-6.1.x86_64 : Oracle VM VirtualBox
VirtualBox-7.0.x86_64 : Oracle VM VirtualBox

As seen, we have VirtualBox 7.0 provided, proceed and install it using the command:

sudo dnf install VirtualBox-7.0 -y

Dependency Tree:

Dependencies resolved.
================================================================================
 Package             Arch   Version                            Repository  Size
================================================================================
........

Transaction Summary
================================================================================
Install  63 Packages

Total download size: 134 M
Is this ok [y/N]: y

Accept the GPG key to be imported:

Oracle Linux / RHEL / CentOS-9 / x86_64 - Virtu 3.0 kB/s | 1.7 kB     00:00    
Importing GPG key 0x98AB5139:
 Userid     : "Oracle Corporation (VirtualBox archive signing key) "
 Fingerprint: 7B0F AB3A 13B9 0743 5925 D9C9 5442 2A4B 98AB 5139
 From       : https://www.virtualbox.org/download/oracle_vbox.asc
Is this ok [y/N]: y

#3. Install Virtualbox Extension Pack

Wait until the installation has been completed then proceed and install the Virtualbox Extension Pack. This provides features such as Virtualbox RDP, disk encryption, NVMe and PXE boot for intel cards, USB 2.0, USB 3.0 devices to VirtualBox.

To download the Virtualbox Extension Pack, visit the official Virtualbox downloads page. On the page, download the “all supported platforms” pack

It is also possible to download the pack via wget

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

Now build the kernel modules using the command:

$ sudo /sbin/vboxconfig
vboxdrv.sh: Stopping VirtualBox services.
vboxdrv.sh: Starting VirtualBox services.
vboxdrv.sh: Building VirtualBox kernel modules.

Once downloaded, navigate to the location of the file and install it with the command:

sudo VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-*.vbox-extpack

Proceed as shown;

VirtualBox Extension Pack Personal Use and Evaluation License (PUEL)

License version 11, 21 May 2020

PLEASE READ THE FOLLOWING ORACLE VM VIRTUALBOX EXTENSION PACK PERSONAL
USE AND EVALUATION LICENSE CAREFULLY BEFORE DOWNLOADING OR USING THE
ORACLE SOFTWARE. THESE TERMS AND CONDITIONS CONSTITUTE A LEGAL AGREEMENT
BETWEEN YOU AND ORACLE.

ORACLE AMERICA, INC. ("ORACLE") IS WILLING TO LICENSE THE PRODUCT DEFINED
IN SECTION 1 BELOW ONLY ON THE CONDITION THAT YOU ACCEPT ALL OF THE TERMS
CONTAINED IN THIS VIRTUALBOX EXTENSION PACK PERSONAL USE AND EVALUATION
LICENSE AGREEMENT ("AGREEMENT").
......
Do you agree to these license terms and conditions (y/n)? y
License accepted. For batch installation add
--accept-license=33d7284dc4a0ece381196fda3cfe2ed0e1e8e7ed7f27b9a9ebc4ee22e24bd23c
to the VBoxManage command line.

0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Successfully installed "Oracle VM VirtualBox Extension Pack".

#4. How to Use VirtualBox 7.0

Once installed, Virtualbox 7.0 is ready for use. Launch it from the App Menu as shown:

Start-VirtualBox

To create a Virtual Machine, click on New and set the name of the VM as shown.

VirtualBox-6.1-on-Rocky-Linux-9-2

Assign the memory size for your Virtual Machine.

VirtualBox-6.1-on-Rocky-Linux-9-3

Create a hard disk for the VM. This will act as storage for your VM

VirtualBox-6.1-on-Rocky-Linux-9-4

Set the disk size.

VirtualBox-6.1-on-Rocky-Linux-9-5

Now you will have your VM created. There are some configurations you can make before you begin the installation.

Navigate to the VM’s Settings -> Storage and load the ISO file to be used to install the required Operating System.

VirtualBox-6.1-on-Rocky-Linux-9-6

It is also possible to configure the Network. Here, you can choose between NAT, bridged,l internal Network, host-only e.t.c

VirtualBox-6.1-on-Rocky-Linux-9-7

#5. Transfer Files Between Virtual Machine To Host

There are three ways how to transfer files between the Host and VM. These are:

  • Drag and drop & Shared Clipboard
  • USB drive
  • Shared Folder

Top configure Drag and Drop, which is typically copy and paste, navigate to the VM’s settings-> General settings-> Advanced settings and enable it as shown.

VirtualBox-6.1-on-Rocky-Linux-9-8

To allow data to be copied from USB Stick to your VM, enable the USB controller and set the controller. You can now click on + to add the USB device.

VirtualBox-6.1-on-Rocky-Linux-9-9

To configure a shared folder between the host and VM, 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.

VirtualBox-6.1-on-Rocky-Linux-9-10

Once the desired configurations have been made click Ok and start the VM. The installation will begin as shown:

VirtualBox-6.1-on-Rocky-Linux-9-11

#6. Configure VirtualBox Networking

VirtualBox supports several network modes that include:

  1. NAT
  2. NAT Network
  3. Bridged Adapter
  4. Internal Network
  5. Host-Only Adapter
  6. Generic Driver

In this guide, we will discuss and learn how to set 3 commonly used modes which are:

NAT Networking

This is the default enabled mode, the VM is able to access hosts in a physical area network using the virtual NAT. The internet is also accessible from the guest OS. Using this mode, allows the VM to be accessed internally and cannot be accessed remotely. The NAT mode has a internal DHCP server with the default IP address as 10.0.2.2

11

Bridged Networking

With this mode, the VM’s adapter is connected to the host’s physical network adapter. The VM now uses the hots network interface for internet connection. Here, the VMs are fully accessible from the physical LAN. The IP is assigned from your physical network using the IP address of the default gateway in the physical network.

2

Host-only Networking

This mode is used to establish communication between the host and the guest. The VM is also able to communicate with other VMs that are connected to the host-only network. The host-only network can be created on Virtualbox by navigating to File > Host Network Manager. Create the network and check the properties. You can edit them manually or configure them automatically.

2

Once the host-only network has been created, you can now use it on VMs as shown.

1

That is it, now proceed and install the VirtualBox Guest Additions that consist of a set of device drivers and system applications used to optimize the performance of the VM. They provide a number of features such as Mouse pointer integration, shared folders, shared clipboards e.t.c

This can be achieved using the aid in the guide below

Closing Thoughts

That marks the end of this guide on how to install and use VirtualBox 7.0 on Rocky Linux 9 / AlmaLinux 9. You are now able to create and use VMs on your system as desired. I hope this was significant.

Gravatar Image
A systems engineer with excellent skills in systems administration, cloud computing, systems deployment, virtualization, containers, and a certified ethical hacker.