Monday, June 21, 2010

VirtualBox kernel module loading script

When starting VirtualBox (on Ubuntu Lucid), i have to load the kernel modules vboxdrv and vboxnetflt. I created a script to do this automatically. Call it virtualbox and place it somewhere on your $PATH, for example in ~/bin/, so the application launcher in the menu will use the script instead of the binary in /usr/bin/.


#!/bin/bash

# Custom VirtualBox OSE startup script; loads kernel modules

echo "Starting kernel module loading script";
for module in vboxdrv vboxnetflt
do
echo "Testing kernel module $module";
if [ `lsmod | grep $module | wc -l` == '0' ]; then
echo "Module $module not yet installed, installing... "
gksudo modprobe $module
echo "done."
else
echo "Module $module already installed; skipping"
fi
done
/usr/bin/virtualbox

No comments: