Installing Linux kernel modules with DKMS

Dynamic kernel module support (DKMS) is a feature that allows installation of kernel modules while reinstalling the kernel. This is preferable if you don't want to build and install kernel modules every kernel update.

Oftentimes to build the kernel module, it is required to install Linux-related headers.

Here's an example scenario where I want to install Veikk tablet driver that is not available out-of-the-box. The following list is the summarized version of what should happen.

The most difficult out of the steps is configuring with dkms.conf. You can see the format and the available options from dkms.8 manual page. For now, let's see the example configuration.

PACKAGE_NAME="input-veikk"
PACKAGE_VERSION="git"
BUILT_MODULE_NAME[0]="veikk" # (ref:module-name)
DEST_MODULE_LOCATION[0]="/extra/"
AUTOINSTALL="yes"

This tells dkms to install the Veikk driver, packaged as input-veikk with version git, in extra/ (e.g., /lib/modules/@LINUX_KERNEL_VERSION@/extra). When installed, you should see a module named veikk — e.g., see the module list with lsmod.

With the setup complete, run dkms install -m input-veikk -v git and it should be effective immediately.