Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Reconfigure Ubuntu's virtualbox-DKMS after a kernel upgrade
# Description: Everytime the Kernel is upgraded (which is quite often), virtualbox stops working and throws the following error:
# The provider 'virtualbox' that was requested to back the machine
# 'default' is reporting that it isn't usable on this system. The
# reason is shown below:
# VirtualBox is complaining that the installation is incomplete. Please
# run `VBoxManage --version` to see the error message which should contain
# instructions on how to fix this error.
# This script upgrades and signs the virtualbox DKMS modules that cause this error
# The script assumes you already have a X.509 Key Pair (iamlocal_MOK.priv and iamlocal_MOK.der) in /home/username/Keys. If you do
# not, start here to create them:
# I recommend adding this script to your PATH so that whenever the error arises, you just run it
latestVersion=`ls /usr/src/| grep linux-headers- | sed 's/linux-headers-//g; s/-generic//g' | sort -rn| head -1`
#Sign the modules
for f in $(dirname $(modinfo -n vboxdrv))/*.ko
echo "Signing $f"; sudo /usr/src/linux-headers-"$latestVersion"-generic/scripts/sign-file sha256 $KEYHOMEDIR/iamlocal_MOK.priv $KEYHOMEDIR/iamlocal_MOK.der $f
#Reconfigure virtualbox
sudo dpkg-reconfigure virtualbox-dkms
sudo dpkg-reconfigure virtualbox
sudo modprobe vboxdrv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.