Oracle VirtualBox is a cross-platform virtualization application. It installs on your existing Intel or AMD-based computers, whether they are running Windows, Mac, Linux or Solaris operating systems. It extends the capabilities of your existing computer so that it can run multiple operating systems at the same time. Click here to read more about VirtualBox

Advertisement

Oracle has released its new major version VirtualBox 6.0.4 . In this release VirtualBox has improves stability and fixes regressions. To read more about this release read changelog. This article will help you to install Oracle VirtualBox 6.0 on CentOS and Redhat systems using Yum.

Step 1 – Add Required Yum Repositories

Firstly you are required to add VirtualBox yum repository in your system. Download repository file from its official site and place it under at /etc/yum.repos.d/virtualbox.repo .First navigate to /etc/yum.repos.d/ directory and use one of below commands as per your operating system.

cd /etc/yum.repos.d/
wget http://download.virtualbox.org/virtualbox/rpm/rhel/virtualbox.repo

The CentOS and RedHat users also required to add EPEL yum repository using one of the following commands.

### On CentOS/RHEL 7 ### 
rpm -Uvh http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

### On CentOS/RHEL 6 ### 
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

Step 2 – Install Required Packages

Before installing VirtualBox make sure to install all required packages to run VirtualBox like kernel-headers, kernel-devels etc. Use the following command to install the required packages.

yum install gcc make patch  dkms qt libgomp
yum install kernel-headers kernel-devel fontforge binutils glibc-headers glibc-devel

After installing latest kernel and kernel headers, let’s reboot your system and start with Latest kernel.

reboot

Step 3 – Setup Environment Variable

VirtualBox installation required kernel source code to install required modules, So we need to configure environment variable KERN_DIR to which VirtualBox get kernel source code. In my case latest kernel source is available in 2.6.32-504.3.3.el6.x86_64 directory under /usr/src/kernels/ . Make sure you are using correct source path.

export KERN_DIR=/usr/src/kernels/`uname -r`

Step 4 – Install Oracle VirtualBox and Setup

Use the following command to install VirtualBox using the yum command line tool. It will install the latest version of VirtualBox 5.2 on your system.

yum install VirtualBox-6.0

After installation, we need to rebuild kernel modules using the following command.

service vboxdrv setup

Step 5 – Launch VirtualBox

Use following command to start VirtualBox from X windows. You can switch to GUI mode using init 5 or startx commands from terminal.

virtualbox

Install Oracle VirtualBox

Share.

58 Comments

  1. Centos 7.6 (kernel 3.10.0-957.1.3.el7.x86_64)
    VirtualBox-5.2-5.2.24_128163_el7-1.x86_64

    Rather than
    sudo service vboxdrv setup
    which others have pointed out fails, use:
    sudo /usr/lib/virtualbox/vboxdrv.sh setup

  2. ]# vboxmanage -v
    WARNING: The vboxdrv kernel module is not loaded. Either there is no module
    available for the current kernel (3.10.0-693.11.6.el7.x86_64) or it failed to
    load. Please recompile the kernel module and install it by

    sudo /sbin/vboxconfig

    You will not be able to start VMs until this problem is fixed.
    5.2.6r120293
    Getting this error while installing on centos7. Any idea to fix this?

  3. hi i have a quetion for you:

    There were problems setting up VirtualBox. To re-start the set-up process, run
    /sbin/vboxconfig

    how to resolve this problem???

  4. Antonio Augusto on

    I have instaled at Cents 7 and found the message:
    Running transaction
    Instalando : VirtualBox-5.1-5.1.14_112924_el7-1.x86_64 1/1
    Creating group ‘vboxusers’. VM users must be member of that group!
    vboxdrv.sh: failed: Look at /var/log/vbox-install.log to find out what went wrong.
    There were problems setting up VirtualBox. To re-start the set-up process, run
    /sbin/vboxconfig as root.
    Verifying : VirtualBox-5.1-5.1.14_112924_el7-1.x86_64 1/1

    Instalados:
    VirtualBox-5.1.x86_64 0:5.1.14_112924_el7-1
    Concluído!

    Seeing the logs:
    Makefile:194: *** Error: KERN_DIR does not point to a directory. Pare.

  5. fedora server 23
    please help me,
    # service vboxdrv setup
    The service command supports only basic LSB actions (start, stop, restart, try-restart, reload, force-reload, status). For other actions, please try to use systemctl.

    #/usr/lib/virtualbox/vboxdrv.sh setup
    vboxdrv.sh: Building virtualbox kernel modules.
    vboxdrv.sh: Building virtualbox kernel services.
    vboxdrv.sh: Building virtualbox kernel modules.
    vboxdrv.sh: failed: modprobe vboxdrv failed. please use ‘dmesg’ to find out why

    (cann you help please ) how find the errors ..

  6. In step 4, I got the error reported by others:
    # service vboxdrv setup
    The service command supports only basic LSB actions (start, stop, restart, try-restart, reload, force-reload, status). For other actions, please try to use systemctl.

    Solution found in this link: http://unix.stackexchange.com/questions/233583/service-vboxdrv-setup-throwing-error-when-installing-virtualbox-on-centos-7

    # /usr/lib/virtualbox/vboxdrv.sh setup
    vboxdrv.sh: Building VirtualBox kernel modules.
    vboxdrv.sh: Starting VirtualBox services.

    # systemctl status vboxdrv
    ● vboxdrv.service – VirtualBox Linux kernel module
    Loaded: loaded (/usr/lib/virtualbox/vboxdrv.sh; enabled; vendor preset: disabled)
    Active: active (exited) since Tue 2016-09-27 17:19:16 AEST; 37min ago
    Process: 22375 ExecStart=/usr/lib/virtualbox/vboxdrv.sh start (code=exited, status=0/SUCCESS)

    Sep 27 17:19:15 hostname systemd[1]: Starting VirtualBox Linux kernel module…
    Sep 27 17:19:16 hostname vboxdrv.sh[22375]: vboxdrv.sh: Starting VirtualBox services.
    Sep 27 17:19:16 hostname systemd[1]: Started VirtualBox Linux kernel module.

  7. Why isn’t anyone mentioning that you should definitely add your user to the vboxusers group. Otherwise you cant use USB devices etc

  8. Daniel Gomes on

    Hi bro, please fix epel-release-7-7.noarch.rpm or people will get 404.
    I love your post, btw!
    Thanks!

  9. Thank you very much.

    I had an issue with Virtual Box on Fedora 23:

    ” The VirtualBox Linux kernel driver (vboxdrv) is either not loaded or there is a permission problem with /dev/vboxdrv. Please reinstall the kernel module by executing

    ‘/etc/init.d/vboxdrv setup’ ”

    I did not follow exactly all you steps to fix it. I just installed the required packages (and setup the environment variable just to be sure). I installed after that the AMD64 version of Virtual Box available on the website and it is working now! 🙂

  10. Yes very helpful except the ‘#service vboxdrv setup’ failed to run on my CentOS 7… any help? but I think the Virtualbox installation should still work right?

  11. Hello, I have the following error in the installation:
    /usr/lib/virtualbox/vboxdrv.sh setup
    Stopping VirtualBox kernel modules [ OK ]
    Uninstalling old VirtualBox DKMS kernel modules [ OK ]
    Trying to register the VirtualBox kernel modules using DKMS[ OK ]
    Starting VirtualBox kernel modules [FALHOU]
    (modprobe vboxdrv failed. Please use ‘dmesg’ to find out why)

  12. You are my savior, was planning to wipe-out OEL before I stumbled on this site. I spent a day to find a resolution to fix Vbox installation issue, mainly due to following errors.
    1) vboxdrv: disagrees about version of symbol module_layout
    2) virtualbox kernel driver not installed (rc=-1908)
    3) For Vmware : C header files matching your running kernel were not found. Refer to your distribution’s documentation for installation instructions.

    I had bad a setting for KERN_DIR grrrrrrr

    Solution:
    So, correct KERN_DIR settings in .bashrc and install right “kernel-devel” and kernel-headers”

  13. Searched for awhile before I stumbled on this gem of a post – exactly what I needed to get VB up and running – Thanks!

    The only thing I needed to do was to enable AMD-V Support in my BIOS to install a x64 version of windows, and after that, all is good!

  14. Hi, your post was almost perfect ! Unfortunately at step 4, i get this :

    [root@P-VIR-2 VirtualBoxVMS]# service vboxdrv setup
    The service command supports only basic LSB actions (start, stop, restart, try-restart, reload, force-reload, status). For other actions, please try to use systemctl.

    And

    [root@P-VIR-2 VirtualBoxVMS]# /etc/init.d/vboxdrv setup
    -bash: /etc/init.d/vboxdrv: Aucun fichier ou dossier de ce type

    Some hints ?

  15. When I try to pull up Virtual box I get the below error

    [root@yc15 init.d]# virtualbox &
    [1] 20252
    [root@yc15 init.d]# VirtualBox: supR3HardenedMainGetTrustedMain: dlopen(“/usr/lib/virtualbox/VirtualBox.so”,) failed: libGL.so.1: cannot open shared object file: No such file or directory

  16. hi folks,

    I was setting up virtual box and vagrant in an openstack instance .After working on Centos and RHEL 7 i found the same error and stuck in same point. Need your guide on further work out.
    Do you think I need to fall back to old version of Centos/Rhel ( like 6 or 5) or I need to try to setup in version 7. The below error is the point i was stuck whiling configuring kernel for virtual box.
    There is discrepancies in output of “uname –r” and # cat /usr/src/kernels/

    [cloud-user@ansible-test-tc kernels]$ ls -lrth
    total 8.0K
    drwxr-xr-x. 22 root root 4.0K Jul 30 21:28 3.10.0-123.20.1.el7.x86_64.debug
    drwxr-xr-x. 22 root root 4.0K Jul 30 21:29 3.10.0-123.20.1.el7.x86_64
    [cloud-user@ansible-test-tc kernels]$ uname -r
    3.10.0-229.4.2.el7.x86_64
    [cloud-user@ansible-test-tc kernels]$

    Error is as follows.

    [root@ansible-test-tc ~]# /etc/init.d/vboxdrv setup
    libkmod: kmod_config_parse: /etc/modprobe.d/ccatg-ipv6.conf line 1: ignoring bad line starting with ‘option’
    Stopping VirtualBox kernel modules [ OK ]
    Uninstalling old VirtualBox DKMS kernel modules [ OK ]
    Removing old VirtualBox pci kernel module [ OK ]
    Removing old VirtualBox netadp kernel module [ OK ]
    Removing old VirtualBox netflt kernel module [ OK ]
    Removing old VirtualBox kernel module [ OK ]
    Trying to register the VirtualBox kernel modules using DKMSError! echo
    Your kernel headers for kernel 3.10.0-229.4.2.el7.x86_64 cannot be found at
    /lib/modules/3.10.0-229.4.2.el7.x86_64/build or /lib/modules/3.10.0-229.4.2.el7.x86_64/source.
    [FAILED]
    (Failed, trying without DKMS)
    Recompiling VirtualBox kernel modules [ OK ]
    Starting VirtualBox kernel modules [FAILED]
    (modprobe vboxpci failed. Please use ‘dmesg’ to find out why)
    [root@ansible-test-tc ~]#
    [root@ansible-test-tc ~]# rpm -qa | grep kernel
    kernel-debug-devel-3.10.0-123.20.1.el7.x86_64
    kernel-tools-libs-3.10.0-229.4.2.el7.x86_64
    kernel-tools-3.10.0-229.4.2.el7.x86_64
    kernel-headers-3.10.0-123.20.1.el7.x86_64
    kernel-devel-3.10.0-123.20.1.el7.x86_64
    kernel-3.10.0-229.4.2.el7.x86_64

  17. I follow the process and getting modprobe error

    [root@ansible-test-tc ~]# pwd
    /root
    [root@ansible-test-tc ~]# /etc/init.d/vboxdrv setup
    Stopping VirtualBox kernel modules [ OK ]
    Uninstalling old VirtualBox DKMS kernel modules [ OK ]
    Trying to register the VirtualBox kernel modules using DKMSError! echo
    Your kernel headers for kernel 3.10.0-123.el7.x86_64 cannot be found at
    /lib/modules/3.10.0-123.el7.x86_64/build or /lib/modules/3.10.0-123.el7.x86_64/source.
    [FAILED]
    (Failed, trying without DKMS)
    Recompiling VirtualBox kernel modules [ OK ]
    Starting VirtualBox kernel modules [FAILED]
    (modprobe vboxpci failed. Please use ‘dmesg’ to find out why)

  18. These instructions were very helpful and I followed this line by line, however I still fail to build:

    # 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.28 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 anyone?

  19. David Bradbury on

    Hi Rahul
    Very helpful. The only other thing that I needed to do (and this took ages to find – this ticket https://www.virtualbox.org/ticket/12229 helped ) was to install a dependency needed but not automatically installed as we are using Oracle Unbreakable Linux (release 6.6)
    Yum install kernel-uek-devel
    the kernel source code environment variable on our server was then configured
    export KERN_DIR=/usr/src/kernels/3.8.13-55.1.2.el6uek.x86_64

    regards

  20. Downloading Packages:
    http://download.virtualbox.org/virtualbox/rpm/el/6/x86_64/VirtualBox-4.3-4.3.14_95030_el6-1.x86_64.rpm: [Errno 12] Timeout on http://download.virtualbox.org/virtualbox/rpm/el/6/x86_64/VirtualBox-4.3-4.3.14_95030_el6-1.x86_64.rpm: (28, ‘Operation too slow. Less than 1 bytes/sec transfered the last 30 seconds’)
    Trying other mirror.

    Error Downloading Packages:
    VirtualBox-4.3-4.3.14_95030_el6-1.x86_64: failure: VirtualBox-4.3-4.3.14_95030_el6-1.x86_64.rpm from virtualbox: [Errno 256] No more mirrors to try.

  21. Hello.

    Can you please tell how to setup virtual machine (with one HDD for example) and tell it to start automatically with system startup from command line (I don’t have a X windows)

  22. Dilip rathod on

    Please help to setup oracle Virtual Box 4.3
    I have installed of fedora 19 using yum Virtual-Box-4.3 using instruction given at if-not-true-then-false.com

    when i try to set up vm i get following error
    [root@localhost student]# service vboxdrv setup
    Stopping VirtualBox kernel modules [ OK ]
    Recompiling VirtualBox kernel modules [FAILED]
    (Look at /var/log/vbox-install.log to find out what went wrong)
    [root@localhost student]# cat /var/log/vbox-install.log
    Makefile:183: *** Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR= and run Make again. Stop.
    [root@localhost student]#

  23. David Bradbury on

    Exactly what I needed after assuming that just the virtualbox rpm file would install everything authomatically!
    Search term “oracle virtualbox installation steps centos”
    Only had to add –skip-broken to the end of the line “yum install kernel-headers …… ” as autotrace, fontforge and xdg-utils complained about dependancy problems.

    Virtual box runs well and imported the virtual server from one of our other hosts, no problems.

    Many thanks
    David

    • Hi,

      I tried to install the VirtualBox and I get this

      [root@vs3 ~]# service vboxdrv setup
      Stopping VirtualBox kernel modules [ OK ]
      Uninstalling old VirtualBox DKMS kernel modules [ OK ]
      Trying to register the VirtualBox kernel modules using DKMSError! echo
      Your kernel headers for kernel 2.6.32-042stab090.4 cannot be found at
      /lib/modules/2.6.32-042stab090.4/build or /lib/modules/2.6.32-042stab090.4/source.
      [FAILED]
      (Failed, trying without DKMS)
      Recompiling VirtualBox kernel modules [FAILED]
      (Look at /var/log/vbox-install.log to find out what went wrong)

      In var/log/vbox-install.log
      Uninstalling modules from DKMS
      removing old DKMS module vboxhost version 4.3.12

      ——————————
      Deleting module version: 4.3.12
      completely from the DKMS tree.
      ——————————
      Done.
      Attempting to install using DKMS

      Creating symlink /var/lib/dkms/vboxhost/4.3.12/source ->
      /usr/src/vboxhost-4.3.12

      DKMS: add completed.
      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.

      Output of rpm -qa | grep kernel
      [root@vs3 ~]# rpm -qa | grep kernel
      dracut-kernel-004-336.el6_5.2.noarch
      kernel-2.6.32-431.20.3.el6.x86_64
      kernel-firmware-2.6.32-431.20.3.el6.noarch
      kernel-devel-2.6.32-431.20.3.el6.x86_64
      kernel-headers-2.6.32-431.20.3.el6.x86_64

      Please help me with this how I can fix the error.

    • Hi Deemango,

      It looks you added repository few days back. Virtualbox has updated its packages revision. Try to clean yum cache and install it again.
      # yum clean all
      # yum install VirtualBox-4.3

  24. On step 4 you could replace the line:
    # export KERN_DIR=/usr/src/kernels/`uname -r`

    With the line:
    # export KERN_DIR=/usr/src/kernels/`ls /usr/src/kernels`

    This would prevent the error experienced by “bijay”.

  25. After running the following command I am getting error, Anyhelp will be highly apreciated.
    # /etc/init.d/vboxdrv setup
    Stopping VirtualBox kernel modules [ OK ]
    Uninstalling old VirtualBox DKMS kernel modules [ OK ]
    Trying to register the VirtualBox kernel modules using DKMSError! echo
    Your kernel headers for kernel 2.6.32-358.6.2.el6.x86_64 cannot be found at
    /lib/modules/2.6.32-358.6.2.el6.x86_64/build or /lib/modules/2.6.32-358.6.2.el6.x86_64/source.
    [FAILED]
    (Failed, trying without DKMS)
    Recompiling VirtualBox kernel modules [FAILED]
    (Look at /var/log/vbox-install.log to find out what went wrong)

    • Hi Bijay,

      Can you please paste the content of /var/log/vbox-install.log file.

      Also make sure you have installed kernel-headers, kernel-devel packages and configured KERN_DIR variable.

      • I have installed all the required packages and configured KERN_DIR variable also.

        Uninstalling modules from DKMS
        removing old DKMS module vboxhost version 4.2.16

        ——————————
        Deleting module version: 4.2.16
        completely from the DKMS tree.
        ——————————
        Done.
        Attempting to install using DKMS

        Creating symlink /var/lib/dkms/vboxhost/4.2.16/source ->
        /usr/src/vboxhost-4.2.16

        DKMS: add completed.
        Failed to install using DKMS, attempting to install without
        Makefile:190: *** Error: KERN_DIR does not point to a directory. Stop.
        ~

        And when I removed the ‘uname -r’ from the KERN_DIR variable and included another variable
        export KERN_INCL=/usr/src/kernels/
        I get the following errors in log file

        Uninstalling modules from DKMS
        removing old DKMS module vboxhost version 4.2.16

        ——————————
        Deleting module version: 4.2.16
        completely from the DKMS tree.
        ——————————
        Done.
        Attempting to install using DKMS

        Creating symlink /var/lib/dkms/vboxhost/4.2.16/source ->
        /usr/src/vboxhost-4.2.16

        DKMS: add completed.
        Failed to install using DKMS, attempting to install without
        make KBUILD_VERBOSE=1 SUBDIRS=/tmp/vbox.0 SRCROOT=/tmp/vbox.0 CONFIG_MODULE_SIG= -C /usr/src/kernels/ modules
        make[1]: *** No rule to make target `modules’. Stop.
        make: *** [vboxdrv] Error 2
        ~
        ~
        ~

        • I made a mistake on my previous reply.
          Here is the correnct set of steps:

          My solution to this problem was to do the following:
          1) Go to the followning folder to find out the environment name:
          [root@localhost ~]$ ls /usr/src/kernels
          2.6.32-431.5.1.el6.x86_64

          2) Open the root “.bashrc” file for editing with Nano.
          [root@localhost ~]$ nano .bashrc

          3) The output from the command for the 1st step was used to insert a line in the “.bashrc” file. Inside of the file I added the following line:
          export KERN_DIR=/usr/src/kernels/2.6.32-431.5.1.el6.x86_64

          4) After saving the file I executed the “.bashrc” lines.
          [root@localhost ~]$ source .bashrc

          5) Finally I ran the VirtualBox rebuilding script:
          [root@localhost ~]$ /etc/init.d/vboxdrv setup

Exit mobile version