VirtualBox is an open-source hypervisor software that helps you create and run multiple guest operating systems (“virtual machines”) on a single hardware machine. VirtualBox can be installed on host operating systems, including Linux, Windows, Solaris, OS X, and OpenSolaris.
From version 2.0, VirtualBox supports 32 and 64bit host and guest operating systems. If you want to install 64bit guests, then your processor must support hardware virtualization, and, of course, the host operating system must be 64bit as well.
VirtualBox is released under GPL v2 and Oracle VM VirtualBox extension pack is released under PUEL (Personal Use and Evaluation License).
This tutorial shows how to install VirtualBox on CentOS 7 / RHEL 7.
Prerequisites
Update System
Update the system to the latest version.
yum update -y
Install Development Tools
Once the system is up, install header and development tools.
yum install -y kernel-devel kernel-headers gcc make perl
Also, install the wget package to download items using the terminal.
yum -y install wget
Reboot the system.
reboot
Install VirtualBox on CentOS 7 / RHEL 7
Set up VirtualBox repository
Download the Oracle public key.
wget https://www.virtualbox.org/download/oracle_vbox.asc
Import the Oracle public key.
rpm --import oracle_vbox.asc
Download the VirtualBox repository file for CentOS 7 / RHEL 7 and move it into /etc/yum.repos.d/
directory.
wget http://download.virtualbox.org/virtualbox/rpm/el/virtualbox.repo -O /etc/yum.repos.d/virtualbox.repo
OR
Create the /etc/yum.repos.d/virtualbox.repo
file with the following repository information.
[virtualbox] name=Oracle Linux / RHEL / CentOS-$releasever / $basearch - VirtualBox baseurl=http://download.virtualbox.org/virtualbox/rpm/el/$releasever/$basearch enabled=1 gpgcheck=1 repo_gpgcheck=1 gpgkey=https://www.virtualbox.org/download/oracle_vbox.asc
Install VirtualBox
Install VirtualBox using the yum
command.
VirtualBox v6.0
yum install -y VirtualBox-6.0
VirtualBox v5.2
yum install -y VirtualBox-5.2
Run the below command to check the status of the VirtualBox Linux kernel module service.
systemctl status vboxdrv
Output:
● vboxdrv.service - VirtualBox Linux kernel module Loaded: loaded (/usr/lib/virtualbox/vboxdrv.sh; enabled; vendor preset: disabled) Active: active (exited) since Wed 2019-11-20 02:46:52 EST; 29s ago Process: 6389 ExecStart=/usr/lib/virtualbox/vboxdrv.sh start (code=exited, status=0/SUCCESS) Tasks: 0 Nov 20 02:46:52 centos7.itzgeek.local systemd[1]: Starting VirtualBox Linux k... Nov 20 02:46:52 centos7.itzgeek.local vboxdrv.sh[6389]: vboxdrv.sh: Starting ... Nov 20 02:46:52 centos7.itzgeek.local systemd[1]: Started VirtualBox Linux ke... Hint: Some lines were ellipsized, use -l to show in full.
Access VirtualBox
Start VirtualBox: Application >> System Tools >> Oracle VM VirtualBox.
OR
virtualbox
What are you waiting for? just go and create virtual machines.
Install Oracle VM VirtualBox Extension Pack
Oracle offers an extension pack to add additional functionalities such as USB 2.0/3.0, VirtualBox Remote Desktop Protocol (VRDP) support, Disk encryption, Host webcam passthrough, Intel PXE boot ROM, and PCI passthrough.
Download the Oracle VM VirtualBox extension pack using the wget command.
### VirtualBox 6.0 ### cd /tmp wget https://download.virtualbox.org/virtualbox/6.0.14/Oracle_VM_VirtualBox_Extension_Pack-6.0.14.vbox-extpack ### VirtualBox 5.2.22 ### cd /tmp wget https://download.virtualbox.org/virtualbox/5.2.34/Oracle_VM_VirtualBox_Extension_Pack-5.2.34.vbox-extpack
To install the extension pack, go to VirtualBox >> Preference >> Extensions >> browse for extension pack (/tmp) by clicking on the + icon.
Click on the Install button to install the VirtualBox extension pack.
Accept the VirtualBox license to start the installation.
Conclusion
That’s All. You have successfully installed VirtualBox on CentOS 7 / RHEL 7. Please share your feedback in the comments section.
I have problem with VirtualBox on CentOS7 running 3.10.0-123.6.3.el7.x86_64 kernel.
# service vboxdrv setup
Stopping VirtualBox kernel modules [ OK ]
Uninstalling old VirtualBox DKMS kernel modulesldconfig: Can’t create temporary cache file /etc/ld.so.cache~: Permission denied
ldconfig exited ungracefully
ldconfig: Can’t create temporary cache file /etc/ld.so.cache~: Permission denied
ldconfig exited ungracefully
Error! There are no instances of module: vboxhost
4.3.16 located in the DKMS tree.
[ OK ]
Trying to register the VirtualBox kernel modules using DKMSldconfig: Can’t create temporary cache file /etc/ld.so.cache~: Permission denied
ldconfig exited ungracefully
ldconfig: Can’t create temporary cache file /etc/ld.so.cache~: Permission denied
ldconfig exited ungracefully
[ OK ]
Starting VirtualBox kernel modules [FAILED]
(modprobe vboxdrv failed. Please use ‘dmesg’ to find out why)
Any ideas?
Dear P,
Disable SELinux, that will solve your problems
Dear Sir, how, In the World, can you tell the guy to disable the WHOLE!! SELinux system. Do you think it’s there for fun?
What you can do is to follow the suggestions of the SELinux message browser… all you have to do is to follow the steps described in the Details section… (i extended by the sudo command because this has to be done as root)
Step 1
sudo grep ldconfig /var/log/audit/audit.log | audit2allow -M mypol
Step 2
sudo semodule -i mypol.pp
Or do:
setenforce Permissive
service vboxdrv setup
setenforce Enforcing
Hi
Thanks for the great tutorial again. Small question, can we install Virtualbox directly without the Gnome desktop ? To maybe get better performance…
But, be able to have remote access to the virtualbox management.. ?
Like is xrdp need a desktop to run on ? Or it can run over just a app ?
Thanks again
Dear Johnny,
Take a look here
https://www.itzgeek.com/how-tos/virtualization/manage-virtualbox-with-phpvirtualbox-web-based-interface.html#axzz3FEj2j0iy
Hi !!
I’m trying to follow the steps but I get this error :
http://download.virtualbox.org/virtualbox/rpm/el/7Server/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 – Not Found
Can you hel me please ?
Hi Fourat,
There is some issue in repo file,
kindly add the following in virtualbox.repo
[virtualbox]
name=Oracle Linux / RHEL / CentOS-$releasever / $basearch – VirtualBox
baseurl=http://download.virtualbox.org/virtualbox/rpm/el/7/x86_64/
enabled=1
gpgcheck=1
gpgkey=https://www.virtualbox.org/download/oracle_vbox.asc
thanks a lot for this tutorial good one
in step 5 its better to add it repo file manually because when i installed it there was a difference in baseurl
Thanks
Failed to install using DKMS, attempting to install without
Makefile:183: *** Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR= and run Make again. Stop.
Dear Lucas,
Reboot the machine as the yum update contains the latest kernel.
You must run the
service vboxdrv setup
after rebooting.
Starting VirtualBox kernel modules [FAILED]
(Running VirtualBox in a Xen environment is not supported)
HI I received the above error
Dear John,
Kindly use non xen kernel and re run setup
Thank you so much, worked like a charm!
Thanks, work for me
great worked perfectly!! Thanks mate
Hi Ashok,
Since the machine is not connected to the internet, you do not need to configure repo.
Download the oracle_vbox.asc file to desktop and upload it to the server. Then use rpm –import oracle_vbox.asc to import.
Download the latest vbox rpm.
http://download.virtualbox.org/virtualbox/rpm/rhel/7/x86_64/VirtualBox-5.2-5.2.4_119785_el7-1.x86_64.rpm
If you install VirtualBox with rpm command, it may tell you that there are some dependency errors. You need to fix that issue by downloading those (dependent) rpm from CentOS.
Dependent rpm is different for each system. Mine is SDL and libvpx.
Install all the dependent rpm one by one by downloading it from CentOS. Then finally install the VirtualBox.
https://uploads.disquscdn.com/images/661b0ee42e3f94b1fbecea5e7a82d2a6bf8b0bc4ab7c1cfc01aae84a93f4bb92.jpg
Hi, Many thanks for the help.
I’m listing the dependencies for rpm and its an exhaustive list. Will updating CentOS reduce some of this dependencies? I’m also getting error “key 1 not an armored public key” while importing 2 dependency package.
How to resolve the following dependency.
/bin/sh
/bin/sh
/bin/sh
/bin/sh
/bin/sh
/usr/bin/env
iproute
Hi Ashok,
Most of the dependencies are installed by default. Don’t give rpm -qpR command. This will list all dependencies irrespective of whether they are installed or not.
Just use
rpm -ivh virtualbox.rpm to install it.
The above command will let you know the exact dependencies detail.
Thanks.
Many Thanks! finally installed the dependent rpm and installation was successful.