Install Virtualbox 4.2 on CentOS 6.2 using YUM

Install Virtualbox 4.2 on CentOS 6.2 using YUM

This tutorial will show you how to Install Virtualbox 4.2 on CentOS 6.2 using YUM. Installing Virtualbox using YUM or official repository is much better than installing from an RPM package. We can get future update of Virtualbox easily. 

Steps to Install Virtualbox 4.2 on CentOS 6.2 using YUM

Open Terminal and type this command
su
cd /etc/yum.repos.d
wget http://download.virtualbox.org/virtualbox/rpm/rhel/virtualbox.repo
It is recommended to update your system to make sure you have latest packages installed including the Linux Kernel.
yum update
Now check if you are running the latest Kernel. Execute these two commands and make sure it returns the same version number.
rpm -qa kernel |sort |tail -n 1
uname -r
For example I got the following version for both commands
[root@localhost yum.repos.d]# rpm -qa kernel |sort |tail -n 1
kernel-2.6.32-279.9.1.el6.i686
[root@localhost yum.repos.d]# uname -r
2.6.32-279.9.1.el6.i686
If you are running older version, simply reboot after you execute command yum update above. Your system will install the most recent Kernel version.
Now install Virtualbox 4.2 using command
yum install VirtualBox-4.2
If you got dependency error, you must enable EPEL repository on CentOS first and install the following dependency files:
yum install binutils gcc make patch libgomp glibc-headers glibc-devel kernel-headers kernel-devel dkms
Now we must rebuild kernel module
/etc/init.d/vboxdrv setup
Add VirtualBos users to virtualbox group if needed
usermod -a -G vboxusers user_name
Congratulations, virtualbox is installed and you can start using it to create and power up your Virtual machines.