How to Install VirtualBox on CentOS and Rocky Linux

Introduction

Oracle VirtualBox is a virtualization software solution that allows users to create and run multiple virtual machines on a single hardware machine. Using a Type 2 hypervisor, like VirtualBox, the host operating system stays unaffected by the virtual environment.

This guide outlines how to install VirtualBox on CentOS and Rocky Linux.

How to Install VirtualBox on CentOS and Rocky Linux.

Prerequisites

  • CentOS or Rocky Linux installed.
  • Command-line access.
  • A user with sudo privileges.

Installing VirtualBox from Oracle Repositories on CentOS and Rocky Linux

Setting up VirtualBox on CentOS and Rocky Linux involves downloading dependencies, adding the Oracle repository, and installing via YUM. Follow the steps in the sections below to install VirtualBox.

Step 1: Install vboxdrv Kernel Module

VirtualBox uses the vboxdrv kernel module to control and allocate physical memory for the guest operating systems. The following is the procedure to install additional modules and other dependency packages:

1. Update YUM repositories:

sudo yum update

2. Use the following command to install the kernel and necessary tools:

sudo yum install –y patch gcc kernel-headers kernel-devel make perl wget

Wait for the installation to finish.

3. Reboot the system to start using the new kernel:

sudo reboot

Step 2: Download VirtualBox Repository

The official Oracle's VirtualBox repository contains the latest versions of VirtualBox binaries available for download. To download the VirtualBox repository, enter the following wget command:

sudo wget http://download.virtualbox.org/virtualbox/rpm/el/virtualbox.repo -P /etc/yum.repos.d

The command downloads the repository file and places it in the /etc/yum.repos.d directory.

Confirmation of downloading and saving the virtualbox repository file.

Step 3: Install VirtualBox

Install the latest version of VirtualBox from the official repository. The following example downloads version 7.1:

1. Enter the following command:

sudo yum install VirtualBox-7.1

When prompted, enter Y to continue the process.

Installing VirtualBox with YUM.

2. The system prompts the user to accept the GPG key. Enter Y to confirm, and wait for the installation to finish.

3. Check the status of the VirtualBox Linux kernel module service:

sudo systemctl status vboxdrv

The output confirms that the service is active.

Image shows that VirtualBox Linux kernel module is active with date and time.

Step 4: Install Oracle VirtualBox Extension Pack (Optional)

Additional packs for functions like USB drives, remote desktop protocols, or disk encryption must be installed separately. Proceed with the steps below to download and import the VirtualBox extension pack:

1. Download the extension pack:

wget http://download.virtualbox.org/virtualbox/7.1.4/Oracle_VirtualBox_Extension_Pack-7.1.4.vbox-extpack

The terminal confirms that the pack has been downloaded.

The extension pack is saved to the correct file.

2. Import the pack to VirtualBox:

sudo VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-7.1.4.vbox-extpack

3. Accept the terms and conditions by entering Y. The system confirms the successful installation of the extension pack.

Confirmation that the extension pack is installed successfully.

Step 5: Start VirtualBox

Use the command below to access the newly installed VirtualBox:

VirtualBox

The VirtualBox manager interface appears.

Oracle VM VirtualBox Manager welcome page.

If you prefer using the graphical interface to access the application, follow the steps below:

1. Click Activities in the upper-left corner of the screen

2. Select the Applications button in the dash.

3. Click the Oracle VirtualBox icon.

Navigating to VirtualBox in GUI.

Conclusion

By following these instructions, you have learned how to install VirtualBox on your CentOS and Rocky Linux systems. VirtualBox provides a simple, cost-effective method for setting up multiple virtual environments. Still, its performance depends on the physical limitations of memory and the processing power of the host machine.

Learn more about VirtualBox and its features in our article Virtualbox vs. VMware.

Was this article helpful?
YesNo
Vladimir Kaplarevic
Vladimir is a resident Tech Writer at phoenixNAP. He has more than 7 years of experience in implementing e-commerce and online payment solutions with various global IT services providers. His articles aim to instill a passion for innovative technologies in others by providing practical advice and using an engaging writing style.
Next you should read
Raid Levels and Types: Advantages and Disadvantages of 0,1,5,10
July 23, 2019

RAID (redundant array of independent disks) is a setup consisting of multiple disks for data storage. They...
Read more
How to Install Kali Linux on VirtualBox
March 28, 2024

Kali Linux is a Debian-derived Linux distribution designed for penetration testing. With over 600...
Read more
How to Install VirtualBox on Ubuntu
March 13, 2024

VirtualBox is a powerful tool for running a virtual operating system on your computer. In this tutorial learn...
Read more
What is Server Virtualization? Definition and How it Works
February 24, 2019

A virtualized server allows one piece of hardware to be used as multiple virtual servers. Learn about Server...
Read more