Linux, Windows, Virtualization, OpenSource & Blogging

Install VirtualBox 5 on CentOS 7 / RHEL 7


Using VirtualBox, you can create and run guest operating systems (“virtual machines”) such as Linux and Windows under a host operating system. There are two ways of installing VirtualBox; from pre-compiled binaries and the sources code. This tutorial shows you how to set up VirtualBox 5.1 from the pre-compiled binaries.

From the version 2.0 VirtualBox supports 32 and 64bit host and guest operating systems (if you want to install 64bit guests your processor must support hardware virtualization and, of course, the host operating system must be 64bit as well).

This tutorial shows how to install VirtualBox 5.1 on CentOS 7 / RHEL 7 via yum repository.

Step 1: Please setup EPEL repository for RHEL 7 / CentOS 7.

rpm -Uvh

Step 2: Install header and development tools.

yum install kernel-devel kernel-headers dkms 
yum groupinstall "Development Tools"
yum update

Step 3: Download Oracle public key.


Step 4: Import Oracle public key.

rpm --import oracle_vbox.asc

Step 5: Download VirtualBox repo file for CentOS 7 / RHEL 7 and move it into /etc/yum.repos.d directory.

 wget -O /etc/yum.repos.d/virtualbox.repo


Create /etc/yum.repos.d/virtualbox.repo file and use the following repo information.

name=Oracle Linux / RHEL / CentOS-$releasever / $basearch - VirtualBox

Step 6: Install VirtualBox 5.

yum install VirtualBox-5.1

Step 7: Rebuild the kernel.

service vboxdrv setup

Step 7: Add your user name in to vboxuser group.

usermod -a -G vboxusers raj

Step 8: Start VirtualBox using following command.


Now you can start adding VM’s on VirtualBox.

Install VirtualBox 5 on CentOS 7
Install VirtualBox 5 on CentOS 7

That’s All!. You have successfully installed VirtualBox on CentOS 7.


You might also like
  • Mr P

    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/ Permission denied
    ldconfig exited ungracefully
    ldconfig: Can’t create temporary cache file /etc/ 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/ Permission denied
    ldconfig exited ungracefully
    ldconfig: Can’t create temporary cache file /etc/ Permission denied
    ldconfig exited ungracefully
    [ OK ]
    Starting VirtualBox kernel modules [FAILED]
    (modprobe vboxdrv failed. Please use ‘dmesg’ to find out why)

    Any ideas?

    • Raj

      Dear P,

      Disable SELinux, that will solve your problems

      • Peter

        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?

        • watzmann

          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

          • B

            Or do:

            setenforce Permissive
            service vboxdrv setup
            setenforce Enforcing

  • Johnny


    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

  • fourat

    Hi !!

    I’m trying to follow the steps but I get this error : [Errno 14] HTTP Error 404 – Not Found

    Can you hel me please ?

    • Raj

      Hi Fourat,

      There is some issue in repo file,
      kindly add the following in virtualbox.repo

      name=Oracle Linux / RHEL / CentOS-$releasever / $basearch – VirtualBox

  • George

    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

  • lucas

    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.

    • Raj

      Dear Lucas,

      Reboot the machine as the yum update contains the latest kernel.
      You must run the
      service vboxdrv setup
      after rebooting.

  • jhon

    Starting VirtualBox kernel modules [FAILED]
    (Running VirtualBox in a Xen environment is not supported)

    HI I received the above error

    • Raj

      Dear John,

      Kindly use non xen kernel and re run setup

  • Eddy de Boer

    Thank you so much, worked like a charm!

  • Cesar Silence

    Thanks, work for me

Install VirtualBox 5 on CentOS 7 / RHEL 7