Install and Use VirtualBox 6.1 on Rocky Linux 9

Posted on 145 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 6.1 on Rocky Linux 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 6.1, which was made in December 2019. The cool features associated with VirtualBox 6.1 are:

  • Nested virtualization on Intel CPUs
  • Offers the ability to create multiple VM instances
  • Has imported VM groups and storage settings
  • Updated and extensible Firmware Interfaces and use
  • Allows importing and exporting a VM from OCI

Before you Begin

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 on Rocky Linux 9

Virtualbox does not reside in the default Rocky Linux 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

Install the required build tools:

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

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 kernel-*

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 6.1 on Rocky Linux 9

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

dnf search virtualbox

Sample Output:

Oracle Linux / RHEL / CentOS-9 / x86_64 - Virtu 125 kB/s | 7.8 kB     00:00    
====================== Name & Summary Matched: virtualbox ======================
VirtualBox-6.1.x86_64 : Oracle VM VirtualBox

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

sudo dnf install VirtualBox-6.1

Dependency Tree:

Dependencies resolved.
================================================================================
 Package             Arch   Version                            Repository  Size
================================================================================
Installing:
 VirtualBox-6.1      x86_64 6.1.36_152435_el9-1                virtualbox  90 M
Upgrading:
 pcre2               x86_64 10.37-5.el9_0                      baseos     229 k
 pcre2-syntax        noarch 10.37-5.el9_0                      baseos     139 k
 pcre2-utf32         x86_64 10.37-5.el9_0                      appstream  199 k
Installing dependencies:
 SDL2                x86_64 2.0.20-2.el9                       appstream  606 k
 libdecor            x86_64 0.1.0-3.el9                        appstream   40 k
 pcre2-utf16         x86_64 10.37-5.el9_0                      appstream  208 k
 qt5-qtbase          x86_64 5.15.2-29.el9                      appstream  3.6 M
 qt5-qtbase-common   noarch 5.15.2-29.el9                      appstream   12 k
 qt5-qtbase-gui      x86_64 5.15.2-29.el9                      appstream  6.3 M
 qt5-qtx11extras     x86_64 5.15.2-6.el9                       appstream   35 k
 sdl12-compat        x86_64 0.0.1~git.20211125.4e4527a-4.el9   appstream   83 k
 xcb-util-image      x86_64 0.4.0-19.el9                       appstream   19 k
 xcb-util-keysyms    x86_64 0.4.0-17.el9                       appstream   14 k
 xcb-util-renderutil x86_64 0.3.9-20.el9                       appstream   17 k
 xcb-util-wm         x86_64 0.4.1-22.el9                       appstream   31 k

Transaction Summary
================================================================================
Install  13 Packages
Upgrade   3 Packages

Total download size: 102 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 on Rocky Linux 9

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

VirtualBox-6.1-on-Rocky-Linux-9

It is also possible to download the pack via wget

wget https://download.virtualbox.org/virtualbox/6.1.36/Oracle_VM_VirtualBox_Extension_Pack-6.1.36a-152435.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

#4. How to Use VirtualBox 6.1

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

How to Use VirtualBox 6.1

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

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

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

p6-X56FMp24VUh7sR8ps25y3Aa3w8TW4VMuhkZA0aOgdSAinQUjf3Eq2bkkYGW2c52h4FFQryc1idItRyD6YzayLHFQ0tibzjIPsOuUpTvcjaQgJTTciDMyOVtrstDiBoU1GHBaWfEp9FwrhK_n2Eyo

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.

e2nfJUq8L51fspKcvpAO7k-vmw1yrWAxTtusaU7mFxrAX5V1bP1vIm15xm9RiZ2bkLzHN6FLgO87lvSNn0t0nrWP1rOpCWq6rvLlbKFPRCm-WsMHNP0DLq4PRKkf93RQs2PHltZbVxDLf7-qV4T3va8

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.

h78kU7CheXXHD2LGpvAUE_XCXlXJzSR9yON-0HCAY2SHMymNeci9LviGjRrXuA144ObLP4aGkGmR86RexiF_CrWmplqUbLIpRXDr0yL0w5N5iTQGbs8aLwAUzG5Vx_cf32TTlGl-Lupok6l1m4-NQFU

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

dAthchZAIbW_2lW1d1Ou1ga02Z8dha1irqr8o5QEb2li146mB4EWjBFe5A5NCt78OVWMP9lSJe4kUvzPhwsofSVQ7Z7vuT4RTI9GitOlq9YdbfqjiIP01e8HGFGdIfmalkutarhz8mBCxje8lC9e0uU

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 6.1 on Rocky Linux 9. You are now able to create and use VMs on your system as desired. I hope this was significant.

coffee

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