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/.


# Custom VirtualBox OSE startup script; loads kernel modules

echo "Starting kernel module loading script";
for module in vboxdrv vboxnetflt
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."
echo "Module $module already installed; skipping"

No comments: