Dynamic Kernel Module Support
Dynamic Kernel Module Support (DKMS) is a framework for managing and dynamically building Linux kernel modules from source code located outside the main kernel source tree, enabling their compilation and installation for specific kernel versions without requiring a full kernel rebuild.[1][2] Developed primarily to address the challenges of updating individual drivers in bundled Linux distributions, DKMS automates the process of rebuilding external modules—such as those from hardware vendors—whenever the kernel is upgraded, ensuring compatibility and reducing manual intervention.[3][4] Originating from the Linux Engineering Team at Dell, DKMS was created in the early 2000s to streamline driver distribution and maintenance for enterprise customers, evolving from efforts presented at the Ottawa Linux Symposium in 2003 and formalized in a 2004 paper by Dell engineers Matt Domsch and Gary Lerhaupt.[3][1] The framework maintains a separate directory structure, typically under/usr/src/, where module sources and a configuration file (dkms.conf) are stored, allowing commands like dkms add, build, and install to handle version tracking, compilation, and deployment across multiple kernels.[2][5] This approach supports backporting features from upstream kernels and facilitates integration with package managers, such as generating RPMs or DEBs for distribution-specific installations.[1][4]
Key features of DKMS include support for multiple module versions simultaneously, automatic rebuilding hooks during kernel updates in compatible distributions, and compatibility with Secure Boot through module signing and Machine Owner Key (MOK) enrollment.[5][4] It also enables binary-only installations for scenarios without compilers or sources, using options like --force, and provides utilities for creating driver disks or tarballs for easy portability across systems.[5][2] While primarily used for third-party drivers like those for storage controllers or wireless hardware, DKMS has become a standard tool in major Linux distributions, enhancing system stability by decoupling module updates from core kernel changes.[1][3]
Overview
Definition and Purpose
Dynamic Kernel Module Support (DKMS) is a framework that enables the generation and management of Linux kernel modules from source code stored in the local filesystem, separate from the main kernel source tree. This approach allows modules to be built dynamically for specific kernel versions without requiring integration into the core kernel distribution.[2][6] The primary purpose of DKMS is to facilitate the automatic rebuilding and installation of third-party or out-of-tree kernel modules whenever the underlying kernel is updated, thereby preserving compatibility and reducing the need for manual recompilation. By handling these processes transparently, DKMS minimizes disruptions in system functionality, particularly for hardware-dependent modules that might otherwise break due to kernel changes. This automation is especially valuable for maintaining stable operations in environments with frequent kernel upgrades.[3][7] DKMS originated from efforts by Dell Linux Engineering to address distribution challenges for kernel modules supporting proprietary hardware, such as server components, ensuring these modules remain functional across kernel upgrades without extensive customer intervention. For instance, proprietary drivers like those for NVIDIA graphics cards leverage DKMS to automatically recompile and reinstall upon kernel updates, avoiding compatibility issues in dynamic Linux setups.[6][8]Key Features
One of the primary features of Dynamic Kernel Module Support (DKMS) is its automatic rebuilding capability, which integrates with kernel update processes to detect new kernel versions and trigger the recompilation of registered modules. This ensures that third-party modules remain compatible without manual intervention, using the kernel's build system to automate the process in dedicated subdirectories for each kernel version.[1][2] DKMS excels in version management by maintaining support for multiple kernel versions simultaneously, storing compiled modules in version-specific directories such as/var/lib/[dkms](/page/DKMS)/<module>/<module-version>/ to organize sources, builds, and binaries efficiently. Central to this is the dkms.conf configuration file, placed in the module source directory, which specifies essential details like the module source location, build parameters (e.g., via MAKE and CLEAN directives), and package information to guide automated handling.[5][2][1]
DKMS offers cross-distribution compatibility, functioning seamlessly on major Linux distributions including Ubuntu, Fedora, and Arch Linux through standardized installation mechanisms and distro-specific adaptations. Additionally, it includes support for module signing, generating self-signed certificates by default (stored in /var/lib/dkms) to comply with kernels enforcing module signing policies, such as those with Secure Boot enabled, and allowing custom certificates for enhanced security.[5][2]
History
Origins and Development
Dynamic Kernel Module Support (DKMS) originated in the early 2000s as a solution developed by engineers in Dell's Linux Engineering Team to address challenges in managing kernel modules for Linux-based servers in enterprise environments. The primary motivation was to enable the distribution and automatic rebuilding of kernel modules—particularly proprietary drivers—independently of kernel updates, preventing breakage when users upgraded their operating system kernels without rebuilding the entire kernel source tree. This was crucial for Dell's customer support, as frequent kernel updates often rendered vendor-specific modules incompatible, complicating maintenance for system administrators and hardware vendors.[3][1] The project was led by Gary Lerhaupt and Matt Domsch, software engineers at Dell, who initiated development around 2003 to streamline driver fixes and backporting from upstream kernel sources to stable releases. Lerhaupt, with a background in computer science, collaborated on the framework to reduce the complexity of module installation and testing, benefiting both Dell's internal tools and the broader Linux community. Early iterations focused on creating a duplicate module tree outside the kernel source, allowing modules to be rebuilt dynamically upon kernel changes.[3][1] DKMS saw its first public release in 2003, with initial deployment within Dell's support ecosystem before wider availability through open-source channels. It was integrated into Dell's driver distribution packages, such as those for Red Hat and SuSE, to facilitate controlled updates without disrupting certified kernel configurations. The framework's inception was further highlighted at the Ottawa Linux Symposium in 2004, where Domsch and Lerhaupt presented on its practical implementation, drawing from post-2003 user feedback to refine features like precompiled module support. Early contributions from the open-source community began emerging around this time, enhancing its utility beyond Dell's proprietary needs.[1][3]Evolution and Adoption
Dynamic Kernel Module Support (DKMS) achieved its first major milestone with inclusion in the Ubuntu repositories in the mid-2000s, enabling users of this popular distribution to automatically rebuild out-of-tree kernel modules during kernel upgrades.[9] This early adoption facilitated broader integration into Linux ecosystems, addressing the challenges of maintaining third-party modules amid frequent kernel updates. By the late 2000s, DKMS expanded to other key distributions: it was discussed for incorporation into Fedora around 2007, becoming a tool for managing out-of-tree modules, while Debian followed suit after community discussions in 2008, packaging it for dynamic module building across kernels.[10][11] Version 2.0 was released around 2005, introducing enhanced configuration capabilities and improved error handling to streamline module management and reduce build failures.[12] Maintained under the GNU General Public License version 2 (GPL-2.0), the project has benefited from ongoing community contributions, including patches for compatibility with evolving kernel architectures; these efforts ensured support for Linux kernel series 5.x and beyond starting in the 2020s, allowing seamless operation on contemporary systems. DKMS's adoption extends to hardware vendors, who leverage it for reliable driver distribution. NVIDIA utilizes DKMS in its Linux driver packages to automate recompilation for new kernels, ensuring consistent graphics performance across updates, while Broadcom employs it for the wl kernel modules in distributions like Debian, where the broadcom-sta-dkms package handles wireless driver builds.[13] In Arch Linux, DKMS is a standard component in the official repositories and powers numerous packages in the Arch User Repository (AUR), such as zfs-dkms and various wireless drivers, making it a go-to framework for custom module integration.[14] As of 2025, DKMS continues to be actively maintained by the community, with recent releases like version 3.2.2 (September 2025) incorporating features for Secure Boot compatibility, including automated module signing via Machine Owner Keys (MOK) to allow loading on UEFI systems without compromising security.[15][16] This evolution underscores DKMS's enduring role in simplifying kernel module lifecycle management amid advancing Linux security standards.Architecture
Core Components
The core components of Dynamic Kernel Module Support (DKMS) form a structured framework for managing kernel module sources and builds outside the main kernel tree. Central to this is the directory layout, which separates source code from compiled artifacts. Module sources are stored in/usr/src/<module>-<version>/, where <module> is the package name and <version> is the module version, containing the dkms.conf file and source files. Compiled objects, configurations, and build logs reside in /var/lib/dkms/<module>/<version>/<kernel-version>/, enabling per-kernel versioning of binaries while preserving originals in subdirectories like original_module for conflict resolution. As of DKMS 3.0 (2023 onward), certain legacy features like CLEAN and mkdeb have been deprecated or removed.[17][1][18]
The dkms.conf configuration file, placed in the source directory root, defines build parameters using shell-like variable assignments in all uppercase. Required fields include PACKAGE_NAME (e.g., PACKAGE_NAME="megaraid2") and PACKAGE_VERSION (e.g., PACKAGE_VERSION="2.10.3"), which identify the module. Build instructions are specified via MAKE[#] arrays for commands like MAKE[0]="make -C ${kernel_source_dir} SUBDIRS=${dkms_tree}/${PACKAGE_NAME}/${PACKAGE_VERSION}/build modules", while the CLEAN directive is deprecated; for compatibility, it can be set to "true" to suppress warnings. Optional hooks such as POST_BUILD execute scripts after compilation (e.g., POST_BUILD="post-build-script.sh"), and BUILT_MODULE_NAME[#] and DEST_MODULE_LOCATION[#] arrays map output modules to installation paths like /kernel/drivers/[scsi](/page/SCSI). For autoloading, MODULES_CONF[#] generates snippets for /etc/modprobe.d/ or legacy /etc/modprobe.conf, such as MODULES_CONF[0]="alias char-major-116 snd" to associate devices with modules.[17][1]
DKMS relies on kernel headers installed in /lib/modules/$kernel_version/build for compilation, along with standard tools including make for building and gcc for cross-compilation if needed. These dependencies ensure modules are compiled against the target kernel's ABI without modifying the kernel source.[17]
Integration with package managers occurs through hooks that automate module handling during kernel updates. In Debian-based systems, the dh_dkms debhelper tool embeds DKMS commands into package postinst and postrm scripts, triggering builds and installations when kernel packages are added or removed. This setup ensures seamless rebuilding for new kernels without manual intervention.[19]
Build and Management Process
The build process for Dynamic Kernel Module Support (DKMS) begins with registering the module source using thedkms add command, which places the source code in the standard directory /usr/src/<[module](/page/Module)>-<version>/ and requires a dkms.conf configuration file to define build parameters such as the make command and clean steps.[2] Once added, the dkms build command compiles the module for a specific kernel version and architecture, typically the running kernel if unspecified, generating object files in /var/lib/dkms/<[module](/page/Module)>/<version>/<kernel-version>/build/.[2] The process concludes with dkms install, which loads the compiled module into the kernel's module directory (e.g., /lib/[modules](/page/Module)/<kernel-version>/) and updates the module dependencies via depmod.[2]
Management of DKMS modules involves several commands to monitor and maintain their state across kernel versions. The dkms status command lists all registered modules, indicating whether they are added, built, or installed for each kernel version.[2] For removal, dkms remove uninstalls the module from a specific kernel version and optionally cleans the build artifacts, with the --all flag targeting all instances of a module-version pair.[2]
DKMS addresses kernel Application Binary Interface (ABI) changes by rebuilding modules only when compatibility issues arise, leveraging kernel version tags to track and associate builds with specific kernel releases, thus avoiding unnecessary recompilations for unchanged ABIs.[2] This selective rebuilding ensures modules remain functional without manual intervention in most cases.
The full lifecycle of a DKMS module starts with source addition via dkms add and proceeds through building and installation, after which the system monitors kernel updates. Automatic triggers during kernel upgrades are handled by distro-specific mechanisms, such as the dkms.service in systemd-based systems, when AUTOINSTALL="yes" is set in dkms.conf, which detect new kernel installations and invoke dkms install to rebuild and load affected modules.[2][17]
For instance, when updating from Linux kernel 6.1 to 6.5, DKMS would automatically rebuild a VirtualBox guest module if its ABI compatibility is broken, ensuring seamless operation post-upgrade without user action.[5]
Usage
Installation
Dynamic Kernel Module Support (DKMS) is typically installed via the package manager of the target Linux distribution, ensuring compatibility with the system's kernel and build environment.[4] On Debian-based systems such as Ubuntu, users can install it usingsudo apt install dkms, which pulls in necessary dependencies including kernel headers and build tools.[9] For Fedora, the command is sudo dnf install dkms. For Red Hat Enterprise Linux and its derivatives, the command is sudo dnf install dkms (or sudo yum install dkms on older versions), which requires enabling the EPEL repository.[20] On Arch Linux, installation is achieved with sudo pacman -S dkms, alongside the corresponding kernel headers package like linux-headers.[21]
Before installation, ensure prerequisites are met to avoid build failures: kernel headers matching the running kernel (e.g., linux-headers-$(uname -r) on Debian/Ubuntu or kernel-devel-$(uname -r) on Fedora) and build essentials such as GCC and Make, which are usually installed automatically but may require explicit addition via sudo apt install build-essential on Debian-based systems.[4][21] The DKMS binary is commonly located at /usr/sbin/dkms post-installation.[2]
After installation, verify the setup by running dkms --version, which should display the installed version, confirming operational status.[2] For initial configuration to enable automatic module rebuilds upon kernel updates, edit /etc/dkms/framework.conf to adjust settings like MAKE="make" or enable hooks if not already distro-configured; most distributions integrate DKMS hooks into their kernel update processes for seamless operation.[22][21]
A common issue during or after installation is errors related to missing kernel headers, often manifesting as "No kernel headers found for this kernel" when attempting to build modules. To resolve this, install the appropriate headers package for the current kernel version, such as sudo apt install linux-headers-$(uname -r) on Ubuntu, then retry the operation.[4] This ensures DKMS can compile modules against the system's kernel without interruption.
Module Operations
To add a module to the DKMS framework, users execute thedkms add command, which registers the module's source directory—containing a required dkms.conf configuration file—with the DKMS tree.[2] The source code must reside in /usr/src/<module>-<version>/, and the command syntax is dkms add <module>/<version> or equivalently dkms add -m <module> -v <version>.[2] This step prepares the module for automated handling across kernel updates without modifying the core kernel source.[5]
Building the module involves the dkms build command, which compiles the source code for a specific kernel and architecture.[2] The syntax is dkms build <module>/<version> -k <kernel-version>, where the -k option specifies the target kernel (defaulting to the running kernel if omitted); the build occurs in /var/lib/dkms/<module>/<version>/build/.[2] Following a successful build, installation is performed via dkms install <module>/<version> -k <kernel-version>, which places the compiled module files into the appropriate kernel module directory, such as /lib/modules/<kernel-version>/.[2] If the module is not yet added or built, the install command will attempt those steps automatically.[2]
DKMS also supports tarball sources for streamlined vendor distributions, allowing modules to be packaged as compressed archives containing the source, dkms.conf, and optionally pre-built binaries.[2] Tarballs are loaded using dkms ldtarball /path/to/tarball.tar [--force], which extracts and adds the contents to the DKMS tree while preserving any built state; subsequent installation with dkms install completes the process.[2] Three tarball types are supported: source-only with dkms.conf (type 1), source plus binaries (type 2), and binaries-only (type 3, useful on systems lacking compilers).[5]
For maintenance, the dkms status command provides an overview of all managed modules, displaying their versions, build status, and installation state across kernels (e.g., "added," "built," or "installed").[2] To remove a module, dkms remove <module>/<version> --all uninstalls it from all kernels and cleans up associated files, optionally targeting specific kernels with -k <kernel-version>.[2] DKMS inherently manages multiple kernels by tracking and rebuilding modules per kernel version during updates, ensuring compatibility without manual intervention for each one.[2]
A representative example is NDISwrapper, a module that enables Linux to use Windows NDIS network drivers.[23] To integrate it with DKMS, first add the source: dkms add ndiswrapper/<version>.[2] Then build: dkms build ndiswrapper/<version> -k <kernel-version>, followed by installation: dkms install ndiswrapper/<version> -k <kernel-version>.[2] This setup automatically recompiles NDISwrapper for new kernels, maintaining wireless driver functionality.[23]
Benefits and Challenges
Advantages
Dynamic Kernel Module Support (DKMS) simplifies the maintenance of external kernel modules by automating their recompilation whenever a new kernel version is installed, thereby minimizing administrative overhead and reducing system downtime associated with manual rebuilds.[5][4] This automation ensures that modules remain compatible with kernel updates without requiring users to track and manually intervene in the process, which is particularly beneficial in environments with frequent kernel upgrades.[7] DKMS promotes vendor independence by enabling the distribution of kernel modules in source form, independent of specific kernel releases or modifications to the core kernel source tree.[3] This approach allows hardware vendors and third-party developers to provide updates and fixes without being constrained by the kernel development cycle, facilitating broader compatibility across diverse Linux distributions.[7] In enterprise setups, DKMS enhances reliability by streamlining the delivery of hardware drivers for servers, as originally developed by Dell to support their Linux customers without necessitating full kernel replacements.[24] For instance, Dell utilized DKMS to distribute updated drivers for server hardware on distributions like Red Hat Enterprise Linux and Ubuntu, ensuring seamless integration and reducing support issues during kernel updates.[24] DKMS offers flexibility through support for custom build scripts defined in its configuration files, allowing developers to incorporate specialized compilation steps tailored to particular modules.[5] Additionally, it integrates seamlessly with packaging systems such as RPM and DEB, enabling the creation of distributable packages that handle module installation and rebuilding automatically during system updates.[5][25] A practical example of DKMS's benefits is its application to proprietary Wi-Fi drivers, such as those from Broadcom or Realtek, which often break after kernel updates; DKMS automatically rebuilds these modules using the latest kernel headers, restoring functionality without manual reconfiguration.[4] A recent example illustrating these benefits is the bcachefs copy-on-write filesystem, which transitioned to DKMS in 2025 after its removal from the Linux kernel mainline in version 6.18, allowing support for kernels 6.16 and later with faster independent updates.[26]Limitations
Dynamic Kernel Module Support (DKMS) introduces overhead in terms of compilation time and disk space usage, as it requires rebuilding modules from source code for each new kernel version installed on the system.[7] This process involves tools such as a compiler (e.g., GCC), a linker, and kernel headers, which can extend build durations significantly compared to precompiled modules, particularly on resource-constrained systems.[7] Additionally, DKMS maintains a separate tree for module sources and binaries outside the kernel source tree, leading to increased disk space consumption for storing multiple versions across kernel updates.[3] A key dependency of DKMS is the availability of matching kernel headers, which must correspond precisely to the running kernel version; mismatches can result in build failures during module compilation.[27] For instance, if the installed kernel headers package does not align with the active kernel—common after upgrades or in custom setups—DKMS attempts to build modules will fail, requiring manual intervention to install or update the correct headers.[28] Compatibility challenges arise with very old kernels or non-standard builds, where DKMS may encounter ABI changes or unsupported configurations that prevent successful module rebuilding.[29] Furthermore, potential conflicts occur with signed modules in environments enforcing Secure Boot or kernel lockdown, as DKMS-built modules often fail to load without proper signing, such as using Machine Owner Keys (MOK).[21] Maintenance of DKMS imposes a burden on users, who must regularly update thedkms.conf configuration file to accommodate changes in module sources or kernel interfaces, ensuring proper build parameters and dependencies are specified.[5] Failure to maintain this file can lead to incomplete or erroneous module installations across kernel versions.
In containerized environments like Docker, DKMS faces significant challenges due to limited access to the host kernel and build tools, often resulting in failed module builds when attempting to compile within isolated containers.[30]