Skip to main content

Install VirualBox on Fedora, CentOS or Redhat Linux (RHEL)

VirtualBox-5.1 in not working in Fedora 25, Centos7 and Redhat Linux (RHEL)

I installed Virtualbox-5.1 from the rpmfusion repository and I was unable to create Host-Only-Netwok adapter. When I tried to start create I got the below error.
VBoxManage: error: VBoxNetAdpCtl: Error while adding new interface: 
failed to open /dev/vboxnetctl: No such file or directory

Later I started researching what is this error and why it the device is not present. And I came to know that VirtualBox kernel modules were not started and that was causing the issue. I tried to start the service and it failed. (Unfortunately I don't have that output). I got the warding that kernel-core-devel is not installed on the system.  I tried to install it and that didn't worked since there was no kernel-core-devel package was not available in fedora repositories. Later I found some blogs where I got the actual fix.

Here we have to uninstall the currently installed one from rpmfusion and we need to install the one from Virtualbox repository.

(If VirtualBox is not installed then ignore the below steps.  Start from where it mentioned about VirtualBox Installation) 

Login as root user. (if you have sudo access then you can run the command with sudo)
su -
## OR ##
sudo -i

Uninstall Virtual-Box 5.1.
## Fedora 25/24/23/22 ##
dnf remove VirtualBox-5.1

## Fedora 21/20/19/18/17/16/15/14 and CentOS/RHEL 7/6/5 ##
yum remove VirtualBox-5.1

Remove the rpmfusion Repository.
## in all versions of fedora,  CentOS and RHEL ##
mkdir /etc/yum.repos.d/disabled
mv /etc/yum.repos.d/rpmfusion*.repo /etc/yum.repos.d/disabled

Clean the DNF or YUM Cache/Packages. 
## Fedora 25/24/23/22 ##
dnf clean all
## Fedora 21/20/19/18/17/16/15/14 and CentOS/RHEL 7/6/5 ##
yum clean all


Now we have to install VirtualBox-5.1 from virtualbox.org repository.


Install Fedora, RHEL or CENTOS Repositories. 
cd /etc/yum.repos.d/

## Fedora 25/24/23/22/21/20/19/18/17/16 users
wget http://download.virtualbox.org/virtualbox/rpm/fedora/virtualbox.repo

## CentOS 7.3/6.9/5.11 and Red Hat (RHEL) 7.3/6.9/5.11 users
wget http://download.virtualbox.org/virtualbox/rpm/rhel/virtualbox.repo

Update all the packages and make sure that you have the latest kernel. 
## Fedora 25/24/23/22 ##
dnf update

## Fedora 21/20/19/18/17/16 and CentOS/RHEL 7/6/5 ##
yum update

Check that that you are running latest installed kernel version.
Output of following commands version numbers should match:
rpm -qa kernel |sort -V |tail -n 1

uname -r

Install following dependency packages.
CentOS 7/6/5 and Red Hat (RHEL) 7/6/5 needs EPEL repository, install it with following command:
## CentOS 7 and RHEL 7 ##
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

## CentOS 6 and RHEL 6 ##
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm

## CentOS 5 and RHEL 5 ##
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-5.noarch.rpm

## Fedora 25/24/23/22 ##
dnf install binutils gcc make patch libgomp glibc-headers glibc-devel kernel-headers kernel-devel dkms

## Fedora 21/20/19/18/17/16 and CentOS/RHEL 7/6/5 ##
yum install binutils gcc make patch libgomp glibc-headers glibc-devel kernel-headers kernel-devel dkms

## PAE kernel users install ##
## Fedora 24/23/22 ##
dnf install binutils gcc make patch libgomp glibc-headers glibc-devel kernel-headers kernel-PAE-devel dkms

## Fedora 21/20/19/18/17/16 and CentOS/RHEL 7/6/5 ##
yum install binutils gcc make patch libgomp glibc-headers glibc-devel kernel-headers kernel-PAE-devel dkms

Install VirtualBox 
## Fedora 25/24/23/22 ##
dnf install VirtualBox-5.1

## Fedora 21/20/19/18/17/16/15/14 and CentOS/RHEL 7/6/5 ##
yum install VirtualBox-5.1

Note: If you got kernel update or run older kernel than newest installed then reboot:
reboot

Note:
This command create automatically vboxusers group and VirtualBox user must be member of that group.
## Fedora 25/24/23/22/21/20/19 and CentOS/RHEL 7 ##
/usr/lib/virtualbox/vboxdrv.sh setup

## Fedora 18/17/16 and CentOS/RHEL 6/5 ##
/etc/init.d/vboxdrv setup
## OR ##
service vboxdrv setup

Add you userid to vboxusers Group

Replace userid  with your own user name or some another real user name.
usermod -a -G vboxusers userid

Start VirtualBox

Either use menu options to start VrtualBox or run the below command. 
VirtualBox






Comments