Monday, 2 March 2015

Install and configure VirtualBox on CentOS/ RedHat

Install and configure VirtualBox on CentOS/ RedHat

Here's a quick, easy to follow guide for installing and configuring VirtualBox to run on a CentOS/ RedHat machine.

This tutorial was tested on a CentOS 6.5 64 Bit machine.

To get started, first off install the correct EPEL repo. You can find the exact EPEL repo link suited for your machines here:

Since Im using a CentOS 6.5 machine, my EPEL repo command is as follows:

# rpm -Uvh

Once the EPEL repo is installed, create a new .repo file for downloading the VirtualBox RPM pacakge:

# vi /etc/yum.repo.d/virtualbox.repo

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

Save the file and exit the editor.

Run a repolist to verify and list the newly added repos.

# yum repolist

Install few additional packages before we install VirtualBox. 

# yum install gcc make patch dkms qt libgomp

Install the development libraries and kernel headers as well

# yum install kernel-headers hernel-devel fontforge binutils glibc-headers glibc-devel

Configure the correct value for the KERN_DIR environment variable. In my case, the Kernel Source files were present at /usr/src directory. 

# export KERN_DIR=/usr/src/kernels/2.6.32-504.8.1.el6.x86_64/

Once all done, simply install VirtualBox using the following command:

# yum install VirtualBox-4.3

After installation finishes, rebuild the kernel modules using following command:

# service vboxdrv setup

Once done, you are now ready to start using VirtualBox on your CentOS/ RedHat machine. For the CentOS desktop, select Applications -> System Tools -> Oracle VM VirtualBox

Alternatively, you can also run VirtualBox from the terminal using the following command:

# virtualbox &