Dynamic Kernel Module Support (DKMS) for Linux

Click on a heading to expand or collapse it, or use the menu bar on the left.

DKMS concepts

Dynamic Kernel Module Support (DKMS) is a program/framework that enables generating Linux kernel modules whose sources generally reside outside the kernel source tree. The concept is to have DKMS modules automatically rebuilt when a new kernel is installed.

Dynamic Kernel Modules are typically used for:

Secure Boot and DKMS

When you enable Secure Boot in the system BIOS for the first time, any DKMS kernel modules will by default be rejected because they are unsigned in the BIOS. As described in the DKMS project page, on an UEFI system with Secure Boot enabled, modules require signing before they can be loaded, and the firmware of the system must know the correct public certificate to verify the module signature.

The DKMS software installation executes the command dkms generate_mok to create a DKMS signing key /var/lib/dkms/mok.pub which can be imported into the UEFI/BIOS. The article OpenZFS work with secure boot explains how to check whether the DKMS key is actually enrolled and loaded in UEFI/BIOS:

mokutil --sb-state
mokutil --test-key /var/lib/dkms/mok.pub
sudo keyctl list %:.machine
sudo keyctl list %:.platform

You can list the enrolled certificate with the mokutil command:

mokutil --list-enrolled | grep DKMS
      Issuer: CN=DKMS module signing key
      Subject: CN=DKMS module signing key

You should see the DKMS module signing key in one of the two keyrings. If not, use mokutil to make a MOK key import request to the UEFI/BIOS:

sudo mokutil --import /var/lib/dkms/mok.pub

A (temporary) password for the key must be input, and it will be required for the MokManager screen below.

Reboot the server. You can enable Secure Boot in the BIOS at this point.

When the OS is booting, the BIOS will present a blue MokManager (shim UEFI key manager) screen to Enroll MOK for the DKMS module imported above, as documented in the DKMS project page.

Quickly press the Enroll MOK item, then press to enroll the DKMS key where you have to enter the above password. When the import is complete, MokManager requests a reboot of the server.

Notes:

  • MokManager is a UEFI utility launched by the Linux shim bootloader to manage Machine Owner Keys (MOK) and binary hashes when UEFI Secure Boot is enabled.

  • The MokManager tool has a timeout of 10 seconds, and if the timeout is exceeded the server boots normally. Then you must repeat the above MOK key import request process.

When the server has been booted, the DKMS kernel modules will be loaded correctly. You can use the above mokutil and keyctl commands to verify the keys.