DKMS Builds a Driver Against the Running Kernel, So Missing Headers or Secure Boot Leave It Unloaded
Out-of-tree drivers such as NVIDIA's proprietary one aren't shipped prebuilt for every Debian kernel. DKMS (Dynamic Kernel Module Support) compiles them on the machine itself, against the headers of the installed kernel, and rebuilds them after each kernel update. The package installation can therefore succeed while the driver doesn't exist: the build failed, or it succeeded but the kernel refuses to load the result.
Two Ways the Driver Never Loads
- The build has nothing to build against. Compiling a module needs the C headers of that exact kernel. Without
linux-headers-<version>, DKMS only registers the source.dkms statusthen reports the module asadded, notinstalled, and there is no.koto load. - The kernel rejects the module. With Secure Boot on, the kernel only loads modules signed by a trusted key. A locally built module has no such signature, so it is built and installed, and then refused at boot.
Making It Survive Kernel Updates
On Debian, install the metapackage linux-headers-amd64 rather than the headers for the current kernel version. It pulls in the headers matching each new kernel, so DKMS can rebuild the module at the next update. Without it, the machine works until the first kernel upgrade, then boots without its driver.
For Secure Boot, there are two options: disable it in the firmware, or enrol a Machine Owner Key (MOK) with mokutil so that DKMS can sign what it builds. The second keeps the protection, at the cost of one manual step at the console during enrolment.
References
- Linux Administration MOC - hub for Linux notes.
- Debian Wiki: NvidiaGraphicsDrivers - headers, DKMS and the driver packages.
- Debian Wiki: SecureBoot - module signing and MOK enrolment.
Review cards
Flashcard Why does the driver not load if `linux-headers-<version>` is missing?
Without the C headers of the exact kernel version, DKMS cannot compile the module, leaving it in an 'added' state without a .ko file to load.
Flashcard Why does Secure Boot stop a DKMS-built driver from loading, and what are the two fixes?
The kernel only loads modules signed by a trusted key, and a locally built module isn't signed. Disable Secure Boot, or enrol a Machine Owner Key so that DKMS signs what it builds.
Quiz Which of the following is a correct way to ensure a DKMS driver survives kernel updates on Debian?
- Install
linux-headers-<version>for the current kernel. - Install the metapackage
linux-headers-amd64. - Disable Secure Boot in the firmware.
- Enrol a Machine Owner Key (MOK) with
mokutil.
The metapackage linux-headers-amd64 ensures that the headers are available for DKMS to rebuild the module after each kernel update.