Monday, June 20, 2011

VirtualBox Linux Kernel Driver Problems

Recently wiped all windows installs at work so I'm using OS X on a MacMini, and Fedora 15 on a dell workstation.  I still have a number of windows images I need to connect to so that means I need some kind of Virtual Machine setup for windows programs.  Cue the free VirtualBox program.  (Free is always a good price!)  I could setup Wine, but I have some specific uses for XP images so that's why I'm sticking the VM route.

Anyway, the first time I attempted to start up the VirtualBox instance, I received an error, "Kernel Driver not installed".  On a newly installed Linux image, this isn't a problem and you can follow the steps listed.  I  had one special case for my box though...

Solution:
Anything following a hashtag, #, is just a comment and can be ignored.  It's simply there as a note.
1. As root, login and install the DKMS (Dynamic Kernel Module).

su -
yum -y install dkms



# -y defaults to yes, or don't prompt me, just install it

This simple goes out into the Fedora repositories and proceeds to pull down and install the "dkms" module.  Simply, this will allow VirtualBox to reconfigure and install itself as a module into the kernel, even when the kernel version changes.  Very handy instead of having to redo by hand anytime you update the kernel. 

2. As root, rerun the VirtualBox setup.

/etc/init.d/vboxdrv setup


Here VirtualBox will attempt to stop the kernel modules, uninstall any previous versions, reregister using DKMS (from step 1), then start the modules.

Here is where you can get some errors.  You will need to first install the kernel headers and development files for your Linux kernel.  Anytime you want to work with your kernel, you're going to need these files, so it's a good idea to get them on your system.  Here is where I found my specific error - my kernel version, and the header/development files were not the same version!  You are going to want to update your system first, so you get the latest  kernel version, that way everything matches.  This can be difficult to tell sometimes since kernel versions can be long and hard to read sometimes.

So, if you still got errors from Solution:2,

3. As root, update the system then install the header and development files.

su -
yum -y update  # update everything, including the kernel
yum -y install gcc make kernel-headers kernel-devel  # gcc and make are needed to link program files


4. Reboot and rerun step Solution:2

shutdown -r now
# Wait for reboot to finish, then log back in as root user
su -
/etc/init.d/vboxdrv setup


Finally, I now have a workable VM that does not complain.

What did we learn?
When working with kernel modules, you must have two things,
1. Installed headers and development packages
2. Matching version number for kernel and it's headers/development files.

Now, back to work!