Translation(s): English - Русский

Building Debian kernel modules with DKMS

Originally discussed: <1255800860.2488.616.camel@localhost>

ToDo: Please improve these notes. The instructions need to be tested and verified.


The dkms frameworks allows building kernel modules "on the fly" on the local system instead of building them centrally on the Debian infrastructure.

The "binary" Debian package contains only sources and depends on the dkms package. See ddcci-dkms as an example.

On systems that use SecureBoot, you will need a Machine Owner Key (MOK) to load DKMS modules. Generate it, enroll it, sign modules with it and then you will be able to load the signed modules.

Package Configuration

  1. Write a configuration file. This is documented in the dkms manual page and there are examples in /usr/share/doc/dkms/examples. A typical configuration file would be:

    MAKE[0]="make -C ${kernel_source_dir} M=${dkms_tree}/${PACKAGE_NAME}/${PACKAGE_VERSION}/build"
    CLEAN="make -C ${kernel_source_dir} M=${dkms_tree}/${PACKAGE_NAME}/${PACKAGE_VERSION}/build clean"

    Note: DEST_MODULE_LOCATION[0] is used only when the module replaces an in-tree module, so its value is not important for you, but you need to specify it anyway.

  2. Add to your postinst:

    dkms add -m <name> -v <version>
    dkms build -m <name> -v <version> && dkms install -m <name> -v <version> || true

    The configuration file is assumed to be installed as /usr/src/<name>-<version>/dkms.conf and the source is assumed to be installed under /usr/src/<name>-<version>. You must specify additional options to dkms add to override this.

  3. Add to your prerm:

    dkms remove -m <name> -v <version> --all || true

Help wanted