VirtualBox

How to Install VirtualBox on CentOS 9

Welcome to the Greenhost.cloud blog! In today’s post, we’ll walk you through the simple steps to install VirtualBox on CentOS 9. VirtualBox is an open-source virtualization software that enables you to run multiple operating systems on a single machine. It’s especially useful for developers, testers, and anyone who wants to experiment with different OS environments without needing extra hardware.

Prerequisites

Before we begin, ensure you have the following:

  • A CentOS 9 system with root privileges (or a user with sudo access).
  • An active internet connection.
  • Basic knowledge of the command line.

Step 1: Update Your System

First, it’s always a good practice to update your system to ensure all software packages are current. Open the terminal and run the following command:

sudo dnf update -y

Step 2: Install Required Dependencies

Before installing VirtualBox, you need to install some required dependencies. Execute the following commands:

sudo dnf install -y gcc make perl

Step 3: Add the Oracle VirtualBox Repository

Oracle provides a repository that contains the latest version of VirtualBox. To add it, create a new repository file using your favorite text editor. Here, we’ll use nano:

sudo nano /etc/yum.repos.d/virtualbox.repo

Then, add the following lines to the file:

[virtualbox]
name=Oracle Linux / RHEL / CentOS-$releasever
baseurl=https://download.virtualbox.org/virtualbox/rpm/el/7/$basearch/
gpgcheck=1
repo_gpgcheck=1
enabled=1
gpgkey=https://www.virtualbox.org/download/oracle_vbox_2016.asc

Save the file and exit the editor (in nano, you can do this by pressing CTRL + X, then Y, and Enter).

Step 4: Install VirtualBox

Now that you have the repository in place, you can install VirtualBox. First, check for the latest version available by listing the packages:

sudo dnf list virtualbox-*

To install the latest version, use:

sudo dnf install -y VirtualBox-6.1

Adjust the version number based on what is available if it’s different. During installation, you may be prompted to import the Oracle public key for the repository; type ‘Y’ and hit Enter.

Step 5: Install DKMS

DKMS (Dynamic Kernel Module Support) helps automatically rebuild kernel modules when a new kernel is installed. To ensure VirtualBox functions properly across kernel updates, install DKMS:

sudo dnf install -y dkms

Step 6: Load the VirtualBox Kernel Modules

After installation, you need to load the VirtualBox kernel modules:

sudo /sbin/vboxconfig

This command will compile and load the necessary kernel modules.

Step 7: Launch VirtualBox

You can now start VirtualBox. You can either find it in your applications menu or run it from the terminal using:

virtualbox

Step 8: (Optional) Add Your User to the vboxusers Group

To allow your user account to run VirtualBox without requiring elevated permissions, add your user to the vboxusers group:

sudo usermod -aG vboxusers $(whoami)

Log out and log back in (or reboot) for the changes to take effect.

Conclusion

Congratulations! You’ve successfully installed VirtualBox on CentOS 9. You can now create and manage virtual machines, providing a fantastic way to test new operating systems and applications.

If you encounter any issues or have questions, feel free to leave a comment below, and we’ll be happy to assist you!

For more tutorials and insights into utilizing cloud services effectively, stay tuned to our blog at Greenhost.cloud. Happy virtualizing!