VirtualBox 4.2.12 on Fedora 18/17, CentOS/Red Hat (RHEL) 6.4/5.9

Oracle VirtualBox is a powerful x86 and AMD64/Intel64 virtualization product for enterprise as well as home use. VirtualBox is a general-purpose full virtualizer for x86 hardware. Targeted at server, desktop and embedded use, it is now the only professional-quality virtualization solution that is also Open Source Software.

VirtualBox supports a large number of guest operating systems:

  • Windows 3.x
  • Windows NT 4.0
  • Windows 2000
  • Windows XP
  • Windows Server 2003
  • Windows Vista
  • Windows 7
  • DOS
  • Linux (2.4, 2.6, 3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7)
  • Solaris
  • OpenSolaris
  • OpenBSD

This guide shows howto install VirtualBox 4.2 (currently 4.2.12) on Fedora 18/17/16/15, CentOS 6.4/6.3/5.9, Red Hat (RHEL) 6.4/6.3/6.2/6.1/6/5.9. This guide uses Virtual Box own yum repositories.

Note: Fedora 14 users can install VirtualBox 4.1, Fedora 13 users can install VirtualBox 4.0 and Fedora 12 users can install VirtualBox 3.2.

1. Change to root User

su -
## OR ##
sudo -i

2. Install Fedora or RHEL Repo Files

cd /etc/yum.repos.d/
 
## Fedora 18/17/16/15/14/13/12 users
wget http://download.virtualbox.org/virtualbox/rpm/fedora/virtualbox.repo
 
## CentOS 6.4/6.3/6.2/6.1/6/5.9 and Red Hat (RHEL) 6.4/6.3/6.2/6.1/6/5.9 users
wget http://download.virtualbox.org/virtualbox/rpm/rhel/virtualbox.repo

3. Update latest packages and check your kernel version

Update packages

yum update

Check that that you are running latest installed kernel version
Output of following commands version numbers should match:

rpm -qa kernel |sort |tail -n 1
 
uname -r

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

reboot

4. Install following dependency packages

CentOS 6/5 and Red Hat (RHEL) 6/5 needs EPEL repository, install it with following command:

## CentOS 6 and RHEL 6 ##
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
 
## CentOS 5 and RHEL 5 ##
rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
yum install binutils gcc make patch libgomp glibc-headers glibc-devel kernel-headers kernel-devel dkms
 
## PAE kernel users install ##
yum install binutils gcc make patch libgomp glibc-headers glibc-devel kernel-headers kernel-PAE-devel dkms

5. Install VirtualBox Latest Version 4.2 (currently 4.2.12)

yum install VirtualBox-4.2

Note:
This command create automatically vboxusers group and VirtualBox user must be member of that group.
This command also build needed kernel modules.

Rebuild kernel modules with following command:

/etc/init.d/vboxdrv setup
## OR ##
service vboxdrv setup

6. Add VirtualBox User(s) to vboxusers Group

Replace user_name with your own user name or some another real user name.

usermod -a -G vboxusers user_name

7. Start VirtualBox

Use launcher from menu or simply run:

VirtualBox

Troubleshooting

If you have problems with KERN_DIR parameter or your kernel directory is not automatically detected then set KERN_DIR environment variable manually, using following method:

## Current running kernel on Fedora ##
KERN_DIR=/usr/src/kernels/`uname -r`
 
## Current running kernel on CentOS and Red Hat (RHEL) ##
KERN_DIR=/usr/src/kernels/`uname -r`-`uname -m`
 
## Fedora example ##
KERN_DIR=/usr/src/kernels/2.6.33.5-124.fc13.i686
 
## CentOS and Red Hat (RHEL) example ##
KERN_DIR=/usr/src/kernels/2.6.18-194.11.1.el5-x86_64
 
## Export KERN_DIR ##
export KERN_DIR

Check also:

Install VirtualBox Guest Additions on Fedora, CentOS, Red Hat (RHEL)

Follow If Not True Then False Updates!

332 Comments

  1. thanks

  2. Does this work on Secure Boot enabled hardware?
    (VirtualBox in Fedora18)

    • Hi Philip,

      I’m not totally sure what you mean? Do you have Fedora 18 installed on your computer?

  3. Thanks for the walk through. I have setup 3 hosts and 30+ virtual machines using your initial setup.

  4. to solve problems related to KERN_DIR:

    yum install binutils gcc make patch libgomp glibc-headers glibc-devel

    yum install kernel-headers-$(uname -r) kernel-devel-(uname -r) dkms

    Usually happens when there is a difference between kernel versions installed and downloaded headers.

  5. I got this errror message at the end of the installation.
    Installation error:
    Makefile:181: *** Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR= and run Make again. Stop.

    So I followed these directions – looks like the kernel source is missing.
    $ KERN_DIR=/usr/src/kernels/`uname -r`-`uname -m`
    $ echo $KERN_DIR
    /usr/src/kernels/2.6.32-279.19.1.el6.x86_64-x86_64
    $ ls -l /usr/src/kernels/2.6.32-279.19.1.el6.x86_64-x86_64
    ls: cannot access /usr/src/kernels/2.6.32-279.19.1.el6.x86_64-x86_64: No such file or directory
    $ ls -l /usr/src/kernels
    total 0

    $ sudo /etc/init.d/vboxdrv setup
    [sudo] password for sfalcon:
    Stopping VirtualBox kernel modules [ OK ]
    Recompiling VirtualBox kernel modules [FAILED]
    (Look at /var/log/vbox-install.log to find out what went wrong)

    Installed Packages
    Name : VirtualBox-4.2
    Arch : x86_64
    Version : 4.2.10_84104_el6
    Release : 1
    Size : 139 M
    Repo : installed
    From repo : virtualbox
    Summary : Oracle VM VirtualBox
    URL : http://www.virtualbox.org/
    License : GPLv2
    Description : VirtualBox is a powerful PC virtualization solution allowing
    : you to run a wide range of PC operating systems on your Linux
    : system. This includes Windows, Linux, FreeBSD, DOS, OpenBSD
    : and others. VirtualBox comes with a broad feature set and
    : excellent performance, making it the premier virtualization
    : software solution on the market.
    $ VirtualBox-4.2
    Command not found. ^C
    $ VirtualBox
    WARNING: The vboxdrv kernel module is not loaded. Either there is no module
    available for the current kernel (2.6.32-279.19.1.el6.x86_64) or it failed to
    load. Please recompile the kernel module and install it by

    sudo /etc/init.d/vboxdrv setup

    You will not be able to start VMs until this problem is fixed.

  6. I resolved the installation issue by installing:
    sudo yum install kernel-devel
    Add/Remove Software for:
    VirtualBox-OSE kernel modules
    gcc-4.4.6.4.el6 (with prereqs)

    • Hi Sharon,

      Actually you should have kernel-devel installed after step 4.

  7. hi guys
    i can’t resolve the problem:

    virtualbox
    WARNING: The vboxdrv kernel module is not loaded. Either there is no module
    available for the current kernel (3.8.3-103.fc17.x86_64) or it failed to
    load. Please recompile the kernel module and install it by

    sudo /etc/init.d/vboxdrv setup

    You will not be able to start VMs until this problem is fixed.
    -if i use the command:
    /etc/init.d/vboxdrv setup this is the output

    [roberto@roberto /]$ /etc/init.d/vboxdrv setup
    Stopping VirtualBox kernel modules [ OK ]
    Uninstalling old VirtualBox DKMS kernel modules/etc/init.d/vboxdrv: line 304: /var/log/vbox-install.log: Permesso negato
    [ OK ]
    Trying to register the VirtualBox kernel modules using DKMS/etc/init.d/vboxdrv: line 329: /var/log/vbox-install.log: Permesso negato
    [FALLITO]
    (Failed, trying without DKMS)
    Recompiling VirtualBox kernel modules/etc/init.d/vboxdrv: line 337: /var/log/vbox-install.log: Permesso negato
    [FALLITO]
    (Look at /var/log/vbox-install.log to find out what went wrong)

    ——————-
    [roberto@roberto /]$ rpm -qa kernel |sort -nr
    kernel-3.8.3-103.fc17.x86_64
    kernel-3.7.9-104.fc17.x86_64
    kernel-3.7.6-102.fc17.x86_64
    Help me please

    Roberto

    • Hi robb,

      You have to install it as root user. Is it working then?

      • Hi,
        thanks for your reply.
        So this is the report:
        I don’t Know How and When…but i resolve the problem on my dekstop pc with Fedora17.
        This one is Fedora 17 64bit..and now it works.

        -so i tried to install VM (with root user)on my laptop with Fedora17 i386,and here it doesn’t works.

        i try different ways with and without DKMS modules

        i think that the real problem is Here->

        [root@roberto ~]# rpm -qa kernel |sort -nr
        [root@roberto ~]#

        no outputs -_-”

        and in /var/log/vbox-install.log
        Makefile:190: *** Error: KERN_DIR does not point to a directory. Stop.

        [root@roberto ~]# /etc/init.d/vboxdrv setup
        Stopping VirtualBox kernel modules [ OK ]
        Recompiling VirtualBox kernel modules [FALLITO]
        (Look at /var/log/vbox-install.log to find out what went wrong)
        ———————————————————————-

        [root@roberto ~]# uname -a
        Linux roberto 3.8.3-103.fc17.i686.PAE #1 SMP Mon Mar 18 15:52:06 UTC 2013 i686 i686 i386 GNU/Linux
        ———————————————————————-
        [root@roberto ~]# echo $KERN_DIR
        /usr/src/kernels/3.8.3-103.fc17.i686.PAE
        ———————————————————————-

        I put the KERN_DIR in root .bash_profile

        [root@roberto ~]# cat .bash_profile
        # .bash_profile

        # Get the aliases and functions
        if [ -f ~/.bashrc ]; then
        . ~/.bashrc
        fi

        # User specific environment and startup programs

        PATH=$PATH:$HOME/bin

        export PATH

        KERN_DIR=/usr/src/kernels/3.8.3-103.fc17.i686.PAE

        export KERN_DIR
        ———————————————————–

        I hope i give u all the informations :)

        • and…..

          [root@roberto kernels]# pwd
          /usr/src/kernels
          [root@roberto kernels]# ls

          this is empty -_-”

          why ???

          • Hi again robb,

            Could you post again output of following command:

            rpm -qa kernel\* |sort
  8. Hi JR

    interesting…we have an output

    [root@roberto ~]# rpm -qa kernel\* |sort
    kernel-PAE-3.7.6-102.fc17.i686
    kernel-PAE-3.7.9-104.fc17.i686
    kernel-PAE-3.8.3-103.fc17.i686

    • Hi robb,

      This is step 1.-4. in shorter…

      Do following:

      yum update
       
      reboot

      Make sure that you have following packages installed:
      binutils
      gcc
      make
      patch
      libgomp
      glibc-headers
      glibc-devel
      kernel-headers
      kernel-PAE-devel
      dkms

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

      And your running kernel have to match to kernel-headers and kernel-PAE-devel versions.

      Then follow this guide from step 5.

      Is it working then?

  9. Ok Now it works!!! =)

    some of these packages were not installed like

    glibc-headers
    glibc-devel
    kernel-headers
    kernel-PAE-devel

    now the directory is not empty =)

    [root@roberto /]# cd /usr/src/kernels
    [root@roberto kernels]# ls
    3.8.3-103.fc17.i686.PAE
    [root@roberto kernels]# cd 3.8.3-103.fc17.i686.PAE
    [root@roberto 3.8.3-103.fc17.i686.PAE]# ls
    arch crypto firmware include ipc kernel Makefile Module.symvers samples security System.map usr vmlinux.id
    block drivers fs init Kconfig lib mm net scripts sound tools virt
    [root@roberto 3.8.3-103.fc17.i686.PAE]#

    thank you so much JR

    you resolve all my problmes =)

    • Excellent to hear robb, that you got it working. :)

  10. Thnks.

  11. HI JR, I followed all the steps mentioned above, but I do not see matching results when I issue the commands:
    rpm -qa kernel |sort |tail -n 1

    uname -r

    Please give some hint as where I might have gone wrong, yhanks.

    • Try with rpm -qa|grep kernel

  12. I’m not new to linux, but always get in trouble and having hard time, even days to solve some simple issues.
    I’m running a server I5 with Centos 6.4 and wanted badly to install virtualbox.
    Problem:

    $ 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-358.6.1.el6.x86_64 cannot be found at
    /lib/modules/2.6.32-358.6.1.el6.x86_64/build or /lib/modules/2.6.32-358.6.1.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)

    I tried all the solutions, even troubleshot, but still didn’t helped. I though I’m the dumbest person in the world :)

    I tried with:
    KERN_DIR=/usr/src/kernels/`uname -r`-`uname -m`

    export KERN_DIR

    After manually browsing through /usr/src/kernels/ I found out that they are not the same directories as stated in `uname -r`-`uname -m`

    I’ve had 2 directories:
    3.8.10-3.8.y.20130430.ol6.x86_64
    2.6.32-358.6.1.el6.centos.plus.x86_64

    Not sure if its normal to have 2, but I have typed:

    KERN_DIR=/usr/src/kernels/2.6.32-358.6.1.el6.centos.plus.x86_64

    export KERN_DIR

    and VOILA !
    IT WORKED !

    With 3.8.10-3.8.y.20130430.ol6.x86_64 didn’t work

    This site was very helpful, you should place a donate button, anyway I have donated through ads :)

Leave a Comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackbacks/Pingbacks

  1. Howto Install VirtualBox (with yum) on Fedora 12, CentOS 5.4, Red … | Just linux! - [...] Go here to read the rest:  Howto Install VirtualBox (with yum) on Fedora 12, CentOS 5.4, Red … [...]
  2. Upgrade to Fedora 13 from Fedora 12 with Preupgrade | if not true then false - [...] 10 on Fedora 13Install Sun Java (JDK, JRE) on Fedora 13Install Adobe AIR 1.5 and 2 on Fedora 13Install ...
  3. Fedora NetInstall (Net Install) with gPXE and BFO (boot.fedoraproject.org) | if not true then false - [...] on Fedora 13Install Adobe AIR 1.5 and 2 on Fedora 13Install Adobe (Acrobat PDF) Reader on Fedora 13Install VirtualBox ...
  4. Install VirtualBox Guest Additions on Fedora 13, CentOS 5.5, Red Hat (RHEL) 6 | If Not True Then False - [...] 6. Reboot guest systemrebootThen VirtualBox Guest Additions install is ready.Check also:Install VirtualBox (with yum) on Fedora, CentOS, Red Hat ...
  5. CentOS 5.5 Netinstall – Network Installation | If Not True Then False - [...] 5.5Install Sun/Oracle Java (JDK, JRE) 6 on CentOS 5.5Install Adobe AIR 1.5 and 2 on CentOS 5.5Install VirtualBox (with ...
  6. Como instalar o VirtualBox no Fedora « tiagopassos.com - [...] if !1 0 Compartilhe: fedora, linux, máquina virtual, virtualbox, [...]
  7. Delicious Bookmarks for March 22nd through March 23rd « Lâmôlabs - [...] Install VirtualBox 4.0.4 on Fedora 14/13, CentOS/Red Hat (RHEL) 5.5/6 – March 22nd ( tags: virtualbox fedora centos ...
  8. Install VirtualBox 4.0.4 on Fedora 14/13, CentOS/Red Hat (RHEL) 5.5/6 « Записки Миханика. - [...] Install VirtualBox 4.0.4 on Fedora 14/13, CentOS/Red Hat (RHEL) 5.5/6. Рубрика: C других сайтов, Linux, Новости ...
  9. How To Install VirtualBox In Fedora | JF Agno Freelance Web Consultant and Web Developer in Davao Philippines - [...] Thats it simple right here is the original source click here [...]
  10. Installing VirtualBox on our Linux Clients » CS SysAdmin - [...] Reference:  http://www.if-not-true-then-false.com/2010/install-virtualbox-with-yum-on-fedora-centos-red-hat-rhel... [...]