wiki/notebook/linux.modules-with-dkms.org
Gabriel Arazas 549f476c4c Update the notebook
The topics I've covered so far for Linux, package managers, archiving,
and learning.

I also updated some formatting for other notes especially with the
command line references.
2021-07-29 23:26:51 +08:00

1.8 KiB

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.

  • Download the source code of the kernel module.
  • Check if the Linux headers are available otherwise the kernel module cannot be built.
  • Place the kernel module source into the kernel source tree (e.g., /usr/src).
  • Create dkms.conf to tell where the module is to be built.
  • Install the module with dkms.

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.