On systems with UEFI Secure Boot enabled, recent Linux kernels will only load signed modules, so it's about time DKMS grew the capability to sign modules it's building.
These scripts are extended and scriptified variants of https://computerlinguist.org/make-dkms-sign-kernel-modules-for-secure-boot-on-ubuntu-1604.html and https://askubuntu.com/questions/760671/could-not-load-vboxdrv-after-upgrade-to-ubuntu-16-04-and-i-want-to-keep-secur/768310#768310 and add some error checking, a passphrase around your signing key, and support for compressed modules.
dkms-sign-module
is a wrapper for the more generic sign-modules
which can also be used outside of DKMS.
- Create a directory under
/root
, say/root/module-signing
, put the three scripts below in there and make them executable:chmod u+x one-time-setup sign-modules dkms-sign-module
- Run
one-time-setup
- Reboot your computer to deploy the MOK
- For each module you will want to sign via DKMS, create a file
/etc/dkms/<module_name>.conf
with the following content:
The awkward relative pathname is important since DKMS prepends its own path to it, so an absolute path will not work.POST_BUILD=../../../../../../root/module-signing/dkms-sign-module
Thanks Xu Zhen but above solution won't work as UEFI Secure Boot is disabled. Could anyone please assist me as not able to install VirtualBox 6.1 on Ubuntu 20.04 (Windows host)as getting error [ (i have changed the kernel version from default to 5.7.0-microsoft-standard but still no luck): Tried so many things but nothing works]:
Loading new virtualbox-6.1.6 DKMS files...
It is likely that 5.7.0-microsoft-standard belongs to a chroot's host
Building for 4.19.0-041900-generic, 5.4.0-39-generic, 5.4.0-40-generic and 5.6.0-1017-oem
Building initial module for 4.19.0-041900-generic
ERROR (dkms apport): kernel package linux-headers-4.19.0-041900-generic is not supported
Error! Bad return status for module build on kernel: 4.19.0-041900-generic (x86_64)
Consult /var/lib/dkms/virtualbox/6.1.6/build/make.log for more information.
dpkg: error processing package virtualbox-dkms (--configure):
installed virtualbox-dkms package post-installation script subprocess returned error exit status 10
Qt WARNING: could not connect to display
Qt FATAL: This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, xcb.
Aborted