Introduction:
VirtualBox is an open source software that helps in running various Virtual machines on your single operating system. It helps us to test , learn or use the various operating system at a time without installing them on the physical system.
Requirements:
Make sure your hardware supports Virtualization. Follow the below steps to easily install the VirtualBox on your CentOS operating system.
Step 1: Update your System
Fire the given command to update your system.
yum update -y
Step 2: Install Development Tools
Install the required Development Tools by running
yum install -y kernel-devel kernel-headers gcc make perl elfutils-libelf-devel
Install wget as it will require to Install files from Terminal.
yum -y install wget
Now, reboot your system.
reboot
Step 3: Set up VirtualBox repository
Type the below command to download the Oracle VirtualBox public key.
wget https://www.virtualbox.org/download/oracle_vbox.asc
Now, import the VirtualBox key to the system.
rpm --import oracle_vbox.asc
After importing key, download the VirtualBox repository file for CentOS 8 / RHEL 8 from their official site and move it to the /etc/yum.repos.d/ directory.
wget http://download.virtualbox.org/virtualbox/rpm/el/virtualbox.repo -O /etc/yum.repos.d/virtualbox.repo
To manually add a repository, paste the below data in your Terminal.
cat <<EOF>> /etc/yum.repos.d/virtualbox.repo
[virtualbox]
name=Oracle Linux / RHEL / CentOS - 8 x86_64 - VirtualBox
baseurl=http://download.virtualbox.org/virtualbox/rpm/rhel/8/x86_64/
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://www.virtualbox.org/download/oracle_vbox.asc
EOF
Install the VirtualBox by using the below command
Virtual Box 6.1
yum install -y VirtualBox-6.1
For Virtual Box 6.0
yum install -y VirtualBox-6.0
VirtualBox 5.2 run
yum install -y VirtualBox-5.2
You can check the status of the VirtualBox Linux kernel module service by
systemctl status vboxdrv
If it is disabled, start and enable it.
systemctl start vboxdrv
[root@localhost sabi]# systemctl status vboxdrv
● vboxdrv.service - VirtualBox Linux kernel module
Loaded: loaded (/usr/lib/virtualbox/vboxdrv.sh; enabled; vendor preset: disa>
Active: active (exited) since Tue 2019-12-24 00:03:47 GMT; 2min 44s ago
Process: 11958 ExecStart=/usr/lib/virtualbox/vboxdrv.sh start (code=exited, s>
Dec 24 00:03:47 localhost.localdomain systemd[1]: Starting VirtualBox Linux ker>
Dec 24 00:03:47 localhost.localdomain vboxdrv.sh[11958]: vboxdrv.sh: Starting V>
Dec 24 00:03:47 localhost.localdomain systemd[1]: Started VirtualBox Linux kern>
lines 1-8/8 (END)
Step 4: Accessing VirtualBox
Type virtualbox in the terminal
VirtualBox
OR
Navigate to Activaties and search for Oracle VirtualBox

Step 5: Creating Virtual Machine
Choose new and set up new virtual machine followed by the Operating System requirements.

Installing Extension Pack
Extension pack offers you to add additional functionalities to VirtualBox including virtualBox Remote Desktop Protocol, usb 2.0/3.0 and others.
Note: Install the same version as you have installed the VirtualBox.
cd /tmp
[root@localhost tmp]# wget https://download.virtualbox.org/virtualbox/6.1.0/Oracle_VM_VirtualBox_Extension_Pack-6.1.0.vbox-extpack
--2019-12-24 00:12:06-- https://download.virtualbox.org/virtualbox/6.1.0/Oracle_VM_VirtualBox_Extension_Pack-6.1.0.vbox-extpack
Resolving download.virtualbox.org (download.virtualbox.org)… 2.21.36.34
Connecting to download.virtualbox.org (download.virtualbox.org)|2.21.36.34|:443… connected.
HTTP request sent, awaiting response… 200 OK
Length: 10923164 (10M) [text/plain]
Saving to: ‘Oracle_VM_VirtualBox_Extension_Pack-6.1.0.vbox-extpack’
Oracle_VM_VirtualBo 100%[===================>] 10.42M 2.26MB/s in 5.7s
2019-12-24 00:12:14 (1.83 MB/s) - ‘Oracle_VM_VirtualBox_Extension_Pack-6.1.0.vbox-extpack’ saved [10923164/10923164]
Now, Navigate to VirtualBox>>Preference>>Extensions>> and click on the + icon.

Click on the Install button to Install Extension pack and Accept License Agreements.


You will be asked to provide pass for authentication

You will see the screen similar to below upon successful installation.

This is how You can Install VirtualBox on CentOS 8 / RHEL 8 and enjoy the amazing features.