Linux Kernel

What is DKMS in Linux

DKMS or Dynamic Kernel Module Support is a system that allows discrete kernel modules to update without the need to modify the entire kernel. It is free software under GPL v2 and written by Dell’s Linux Engineering Team. DKMS was initially developed for Dell Computer Corporation to distribute software patches to their customers in a well-defined manner.

DKMS has many benefits for the Linux service provider communities, e.g.:

  1. From the driver developer’s point of view, it aids in adding drivers that are not already in the base kernel. Also, the driver developers who are required to make available updated device drivers for testing and common use on a large variety of kernels also benefit. Another advantage of DKMS is that the developers can test run their driver’s code on different machines. In fact, this speeds up the driver development process.
  2. From a system administrator standpoint, DKMS simplifies the process of installing device driver updates to the active kernel without adding any changes to it. Hence they do not need to wait for the arrival of a new kernel.
  3. Selected bug fixes or patches can be rolled out in between large-size updates.
  4. New hardware which requires modification in a single module can be easily integrated. Again this can be achieved without entirely testing the new kernels.

What will we cover?

This guide will discuss various kernel-related terminologies and specifically what is DKMS.

A Quick review of Terminologies

What is the Linux kernel?

It is the core part of a Linux OS. It is the main interface between the processes running on the OS and its hardware. It manages major functions like memory management, process management, CPU management, device driver management, and System calls and security management.

Kernel Space
The kernel is actually hidden from the user and works in its own area called Kernel Space. The user interacts with the kernel using the user applications like files browser, web browser, etc. These interactions use a specific programming construct called System Call.

Kernel Source Tree
It has all the source code for kernel and device drivers. It consists of many directories and subdirectories like arch, block, crypto, include, init, lib, usr, etc.

Linux kernel modules
Linux kernel modules are basically chunks of code. These can be added and removed from the kernel as per requirement. They can be built-in or loadable. The kernel module increases the functions of the kernel without requiring a system reboot. Unlike microkernels, where adding new components into the kernel requires configuring and building a new kernel, we can load and unload components or modules of the OS at runtime. These modules are device drivers, file systems, etc.

After a module is loaded, it is just like a piece of kernel code. It has the same privileges and duties as a normal kernel code.

Definition of DKMS

Here is an excerpt of the DKMS definition I found here:

“DKMS is a framework where device driver source can reside outside the kernel source tree so that it is very easy to rebuild modules as you upgrade kernels.”

Let us elaborate on the above. The DKMS system is a tree out of the base kernel tree on the ground. It contains the module source and compiled module binaries. As a result of this replication, modules are not coupled to the kernel. (Although modules are not entirely decoupled).

I myself first encountered the DKMS concept when I bought an HP laptop and installed Ubuntu 18.04 on it. Everything was working fine except for my wifi. My laptop was not able to locate any wifi adapter. In the Settings, the wifi menu displayed a message “No WiFi Adapter Found”. I started searching forums on the internet and discovered many people were experiencing the same issue. I found many solutions suggesting installing header files, drivers, and other packages.

I just blindly followed those guides without actually knowing what they actually wanted to convey. Anyway, those guides helped me out, and I got working wifi somehow. But the problem was that whenever I updated my Ubuntu system, the same problem arose, and I had to repeat the same steps of recompiling the downloaded drivers. Also, I have to fix the low signal problem every time after installing the driver. I even installed Windows OS, and to my surprise, the Wifi was actually working flawlessly. But I have to use Ubuntu for my work anyway. So I decided to live with the temporary patch I got earlier.

DKMS comes to the rescue

A recent solution that I just came across that I did not care about in the past used the DKMS way. Instead of using the make or make install command, DKMS performs three operations on the source code: add, build and install.

Using DKMS

For DKMS to work, the module source should be present on the system where we are building the module, and the location path should be like ‘/usr/src/<module>-<module-version>/’ and remember this is the very first requirement of DKMS. Another requirement is a file called ‘dkms.conf’, which will guide how to build and install a module. And just to mention, DKMS should already be installed on the system. Once everything is in place, we can add a module to the DKMS tree.

Let us see these steps by installing a demo module ‘demo-v0.1.tar.gz’ with DKMS. We are doing this sample is only for the purpose of understanding how DKMS works. After extracting the file, we need to ‘cd’ inside it:

# cd demo-v0.1/

Now create a dkms.conf file that contains the following lines:

MAKE="make -C src/ KERNELDIR=/lib/modules/${kernelver}/build"
CLEAN="make -C ${kernel_source_dir} M=${dkms_tree}/${PACKAGE_NAME}/${PACKAGE_VERSION}/build clean"

Now that our dkms.conf file is ready, we can add our demo module as:

# dkms add -m demo -v 0.1

The beauty of the DKMS is that we can specify the kernel version against which we want to build or module as shown here:

# dkms build -m demo -v 0.1 -k 5.13.0-27

If we do not specify the kernel, DKMS will build the module with the current kernel version.

If everything goes well, we can now install the module using:

# dkms install -m demo -v 0.1

If we upgrade our kernel or change the hardware architecture, a module must be manually rebuilt again. With the help of DKMS, this procedure becomes redundant as the DKMS dynamically builds these kernel modules for each kernel present on the system.


Tools like DKMS have greatly helped administrators, driver developers, and others reduce the kernel management task. While the end-users do not care about how the underlying system is working until their goals are met, DKMS lets developers and administrators focus on their work.

About the author

Ali Imran Nagori

Ali imran is a technical writer and Linux enthusiast who loves to write about Linux system administration and related technologies. You can connect with him on LinkedIn