Skip to content

Instantly share code, notes, and snippets.

@rtgibbons
Forked from timdream/VBoxReloadKext.sh
Created March 12, 2012 19:51
Show Gist options
  • Save rtgibbons/2024307 to your computer and use it in GitHub Desktop.
Save rtgibbons/2024307 to your computer and use it in GitHub Desktop.
Script: reload VirtualBox kernel extension in Mac OS X
#!/bin/bash
unload() {
kextstat | grep "org.virtualbox.kext.VBoxUSB" > /dev/null 2>&1 && sudo kextunload -b org.virtualbox.kext.VBoxUSB
kextstat | grep "org.virtualbox.kext.VBoxNetFlt" > /dev/null 2>&1 && sudo kextunload -b org.virtualbox.kext.VBoxNetFlt
kextstat | grep "org.virtualbox.kext.VBoxNetAdp" > /dev/null 2>&1 && sudo kextunload -b org.virtualbox.kext.VBoxNetAdp
kextstat | grep "org.virtualbox.kext.VBoxDrv" > /dev/null 2>&1 && sudo kextunload -b org.virtualbox.kext.VBoxDrv
}
load() {
sudo kextload /Library/Extensions/VBoxDrv.kext -r /Library/Extensions/
sudo kextload /Library/Extensions/VBoxNetFlt.kext -r /Library/Extensions/
sudo kextload /Library/Extensions/VBoxNetAdp.kext -r /Library/Extensions/
sudo kextload /Library/Extensions/VBoxUSB.kext -r /Library/Extensions/
}
case "$1" in
unload|remove)
unload
;;
load)
load
;;
*|reload)
unload
load
;;
esac
@Blizzke
Copy link

Blizzke commented Dec 4, 2013

Cool. Note that the kexts have been moved for the last versions of VirtualBox (or perhaps because of Mavericks, dunno). In any case, they are now under "/Library/Application Support/VirtualBox/"

@juliovedovatto
Copy link

Updated script for the latest versions of VirtualBox on OSX

#!/bin/bash

unload() {
        kextstat | grep "org.virtualbox.kext.VBoxUSB" > /dev/null 2>&1 && sudo kextunload -b org.virtualbox.kext.VBoxUSB
        kextstat | grep "org.virtualbox.kext.VBoxNetFlt" > /dev/null 2>&1 && sudo kextunload -b org.virtualbox.kext.VBoxNetFlt
        kextstat | grep "org.virtualbox.kext.VBoxNetAdp" > /dev/null 2>&1 && sudo kextunload -b org.virtualbox.kext.VBoxNetAdp
        kextstat | grep "org.virtualbox.kext.VBoxDrv" > /dev/null 2>&1 && sudo kextunload -b org.virtualbox.kext.VBoxDrv
}

load() {
        sudo kextload "/Library/Application Support/VirtualBox/VBoxDrv.kext" -r "/Library/Application Support/VirtualBox/"
        sudo kextload "/Library/Application Support/VirtualBox/VBoxNetFlt.kext" -r "/Library/Application Support/VirtualBox/"
        sudo kextload "/Library/Application Support/VirtualBox/VBoxNetAdp.kext" -r "/Library/Application Support/VirtualBox/"
        sudo kextload "/Library/Application Support/VirtualBox/VBoxUSB.kext" -r "/Library/Application Support/VirtualBox/"
}

case "$1" in
        unload|remove)
                unload
                ;;
        load)
                load
                ;;
        *|reload)
                unload
                load
                ;;
esac

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment