Saturday, December 24, 2011

How to Install VirtualBox on RedHat Enterprise Linux

How to Install VirtualBox on Red Hat Enterprise Linux

After finally performing many searches on the Internet for a solution to this problem, I have finally found the way to install VirtualBox correctly on RHEL.

The Problem: Once VirtualBox is installed, "Starting VirtualBox kernel modules" fails.
The Solution: Install updated Linux Kernel Headers.

If you have never installed VirtualBox on RHEL before, you may notice that a lot of websites will tell you to download the repository file to perform a simple yum install virtualbox query. While this is true, many of these online guides do not tell you to update your systems kernel headers (thus causing an error when starting VirtualBox for the first time). When I installed VirtualBox out of "the box" (no pun intended), I noticed that I would not be able to start the VirualBox Kernel Modules. If you are having problems setting VirtualBox up, try the following command to see if you experience what I did.

Open a new shell and execute the following command: /etc/init.d/vboxdrv start
You should see the following output:

Starting VirtualBox kernel modules [FAILED]
(modprobe vboxdrv failed. Please use 'dmesg' to find out why)

Then execute the following command: /etc/init.d/vboxdrv setup
You should see the following output:

Stopping VirtualBox kernel modules [OK]
Starting VirtualBox kernel modules [FAILED]

Every time I tried to start the vboxdrv modules it would fail. What I did was update the Linux Kernel Modules.

The Solution to the Problem:

In a new shell prompt, type: yum install kernel-devel

Once the kernel modules were updated, I executed the following command again: /etc/init.d/vboxdrv setup

The following output occurred:

Stopping VirtualBox kernel modules [OK]
Uninstalling old VirtualBox DKMS kernel modules [OK]
Trying to register the VirtualBox kernel modules using DKMS [FAILED]
(Failed, trying without DKMS)
Recompiling VirtualBox kernel modules [OK]
Starting VirtualBox kernel modules [OK]

Success! and just like that, I executed VirtualBox again and it finally worked properly! Hopefully this will help someone out there!

Good luck!

PS: I am running Red Hat Enterprise Linux Server 6, Version 2.6.32-220.2.1.e16.x86_64