How to Install VirtualBox 5.1 on CentOS 7 / RHEL 7 / Fedora 26

VirtualBox is a free and open-source virtualization software for x86 hardware. It is available for both Windows and Linux like operating system, it is one the most popular virtualization software used at Desktop level. VirtualBox provides a Graphical User interface (GUI) through which we can create and manage virtual machines, apart from this we can also create Snapshots of VMs, Cloning of the VMs and can create our own customize network for the VMs.

In this article we will discuss how to install latest version of VirtualBox (VirtualBox-5.1.26) on CentOS 7 / RHEL7 and Fedora 26.

Installation Steps of VirtualBox-5.1 on CentOS 7 / RHEL 7

Virtualbox rpm package and its dependencies are not available in the default CentOS 7 and RHEL 7 yum repositories, so we have to set virtualbox repository using the beneath command.

[[email protected] ~]# wget -P /etc/yum.repos.d/

Before start installing virtualbox, first we should install all dependencies of virtualbox, some of the dependencies are available in EPEL repository. So let’s first enable epel repository and install the virtualbox dependencies.

Enable EPEL repository and Install all Virtualbox dependencies

[[email protected] ~]# yum install epel-release -y
[[email protected] ~]# yum update -y && reboot
[[email protected] ~]# yum install gcc make patch  dkms qt libgomp kernel-headers kernel-devel fontforge binutils glibc-headers glibc-devel  -y

Now Install VirtualBox-5.1 with yum Command

[[email protected] ~]# yum install VirtualBox-5.1 -y

Once the VirtualBox package is installed then rebuild the kernel modules using the following command.

[[email protected] ~]# /usr/lib/virtualbox/ setup Stopping VirtualBox services. Building VirtualBox kernel modules. Starting VirtualBox services.
[[email protected] ~]#

Above command will automatically create a group with name “vboxusers“. If any local user wants to use virtualbox then he/she has to be part of vboxusers group. Let’s assume ‘linuxtechi’ wants to use virtualbox

[[email protected] ~]# usermod -a -G vboxusers linuxtechi
[[email protected] ~]#

Now try accessing VirtualBox



Note: If you get an error related to ‘KERN_DIR’ while installing and rebuilding kernel module then set the following variable manually and again try to install and rebuild kernel module for VirtualBox.

[[email protected] ~]# export KERN_DIR=/usr/src/kernels/$(uname -r)

Installation steps of VirtualBox-5.1 on Fedora 26

Installation steps of VirtualBox-5.1 on Fedora 26 are similar to CentOS 7 or RHEL 7.  Let’s first set VirtualBox repository using the following wget command.

[[email protected] ~]$ sudo wget -P /etc/yum.repos.d/

Update the repository list using the beneath dnf command.

[[email protected] ~]$ sudo dnf repolist


Update your system and reboot

[[email protected] ~]$ sudo dnf update -y
[[email protected] ~]$ reboot

After Reboot our system will boot with latest kernel.

Install Virtualbox dependencies with below dnf command

[[email protected] ~]$ sudo dnf install binutils make gcc patch libgomp glibc-headers glibc-devel kernel-headers kernel-devel dkms -y

Now Install VirtualBox 5.1 via dnf command

[[email protected] ~]$ sudo dnf install VirtualBox-5.1 -y

Note: We may get errors while building Kernel modules. After resolving the errors, run the beneath command to rebuild kernel modules for VirtualBox.

[[email protected] ~]$ sudo /usr/lib/virtualbox/ setup

Access VirtualBox


Click on Oracle VM VirtualBox Icon


This concludes that VirtualBox 5.1 has been installed successfully. Now start creating your machines and manage your virtual environment from virtualbox GUI.

1 thought on “How to Install VirtualBox 5.1 on CentOS 7 / RHEL 7 / Fedora 26”

Leave a Comment