Reconfigure Ubuntu's virtualbox-DKMS after a kernel upgrade
#!/bin/bash | |
# 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: http://gorka.eguileor.com/vbox-vmware-in-secureboot-linux-2016-update/ | |
# 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` | |
KEYHOMEDIR=/home/username/Keys | |
#Sign the modules | |
for f in $(dirname $(modinfo -n vboxdrv))/*.ko | |
do | |
echo "Signing $f"; sudo /usr/src/linux-headers-"$latestVersion"-generic/scripts/sign-file sha256 $KEYHOMEDIR/iamlocal_MOK.priv $KEYHOMEDIR/iamlocal_MOK.der $f | |
done | |
#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