How to use the command 'dkms' (with examples)

How to use the command 'dkms' (with examples)

Dynamic Kernel Module Support (DKMS) is an open-source framework developed by Dell, which allows kernel modules to be dynamically built, installed, and removed across kernel upgrades, without requiring manual user intervention. This is particularly useful for maintaining out-of-tree kernel drivers or modules that are not included in the distribution’s main kernel package. DKMS ensures that these third-party modules are automatically rebuilt and installed whenever the kernel is updated, providing seamless integration for system administrators and users alike.

Use case 1: List currently installed modules

Code:

dkms status

Motivation:
In system administration, it’s often essential to have a clear inventory of the currently installed kernel modules, especially when troubleshooting issues or simply confirming installation details. By using this command, administrators can quickly verify which modules and versions are present on the system, ensuring that everything is up-to-date and consistent.

Explanation:
The dkms status command is a simple request for information from the DKMS system. It doesn’t require any additional arguments because its primary purpose is to return a comprehensive list of all the modules that have been registered with DKMS, along with their version numbers and current statuses.

Example output:

acpi_call, 1.2.1, 5.11.0-37-generic, installed
nvidia, 470.57.02, 5.11.0-37-generic, installed

Use case 2: Rebuild all modules for the currently running kernel

Code:

dkms autoinstall

Motivation:
Kernel upgrades are routine for Linux users to gain the latest features, security patches, and stability improvements. However, these updates can sometimes break compatibility with existing kernel modules. The dkms autoinstall command ensures that all DKMS-managed modules are appropriately rebuilt and reinstalled, preserving system functionality after a kernel update.

Explanation:
The dkms autoinstall command automatically detects the currently running kernel and efficiently rebuilds any registered DKMS modules that are relevant for this kernel version. This process involves no additional arguments since the command is designed to execute a sweeping update of all modules under DKMS management.

Example output:

Module acpi_call/1.2.1 already installed for kernel 5.11.0-37-generic
Building module:
cleaning build area...
make -j4 KERNELRELEASE=5.11.0-37-generic -C /lib/modules/5.11.0-37-generic/build M=/var/lib/dkms/nvidia/470.57.02/build...
cleaning build area...

Use case 3: Install version 1.2.1 of the acpi_call module for the currently running kernel

Code:

dkms install -m acpi_call -v 1.2.1

Motivation:
System administrators may need to install a specific version of a kernel module to ensure compatibility with other system components or software dependencies. This command facilitates the installation of a precise version of the acpi_call module, ensuring that the correct driver is applied to the running system.

Explanation:

  • install: This argument specifies that the user desires to install a kernel module using DKMS.
  • -m acpi_call: The -m flag indicates the name of the module to be installed. In this case, it’s acpi_call.
  • -v 1.2.1: The -v flag designates the specific version of the module version desired for installation, here being version 1.2.1.

Example output:

Adding module version:
acpi_call/1.2.1
Kernel preparation unnecessary for this kernel. Skipping...

Building module:
cleaning build area...
make -j4 KERNELRELEASE=5.11.0-37-generic -C /lib/modules/5.11.0-37-generic/build M=/var/lib/dkms/acpi_call/1.2.1/build...
cleaning build area...

acpi_call.ko:
Running module version sanity check.
- Original module
- Installation
- Checking for any problems with the new module

install completed.

Use case 4: Remove version 1.2.1 of the acpi_call module from all kernels

Code:

dkms remove -m acpi_call -v 1.2.1 --all

Motivation:
There are scenarios where a particular module version may become obsolete or incompatible, thus necessitating its removal. This command enables the removal of a specified module version across all kernel installations, cleaning up the system and preventing potential conflicts.

Explanation:

  • remove: This specifies that the DKMS user wants to uninstall a module.
  • -m acpi_call: The -m flag signifies the module targeted for removal, acpi_call.
  • -v 1.2.1: The -v flag allows you to define which version of the module to remove, in this case, version 1.2.1.
  • --all: By adding the --all option, the command instructs DKMS to remove this particular module version from every kernel where it’s installed, ensuring a complete system-wide removal.

Example output:

Module acpi_call/1.2.1 is currently installed on kernel:
5.11.0-37-generic/x86_64
5.4.0-26-generic/x86_64

Deleting from:
5.11.0-37-generic/x86_64
5.4.0-26-generic/x86_64

Completed uninstall command.

Conclusion

DKMS is a crucial tool for anyone managing Linux systems with third-party kernel modules. It simplifies the otherwise cumbersome processes of building, installing, and removing modules, providing system stability and reliability even through frequent kernel updates. With this framework, administrators can ensure a smoother system operation, reducing the risks of module incompatibility and system downtimes.

Tags :

Related Posts

How to Use the Command `pgmkernel` (with Examples)

How to Use the Command `pgmkernel` (with Examples)

pgmkernel is a command-line utility that generates a convolution kernel, often used in image processing tasks.

Read More
How to use the command 'abrt-action-analyze-c' (with examples)

How to use the command 'abrt-action-analyze-c' (with examples)

abrt-action-analyze-c is a command-line utility used primarily for problem determination in the context of software core dumps on Linux systems.

Read More
How to Use the Command 'gitstats' (with Examples)

How to Use the Command 'gitstats' (with Examples)

Gitstats is a powerful tool designed to provide detailed statistics about Git repositories.

Read More