Dynamic Kernel Module Support: Difference between revisions

From ArchWiki
(→‎Installation: Add emphasis on important statement : even though the linux-headers are in the optdepends of the package because there are 4 to choose from in the array, installing at least one of them is a requirement for DKMS to work)
m (Add spanish article link)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
[[Category:Kernel]]
[[Category:Kernel]]
[[es:Dynamic Kernel Module Support]]
[[fr:Dynamic Kernel Module Support]]
[[fr:Dynamic Kernel Module Support]]
[[ja:Dynamic Kernel Module Support]]
[[ja:Dynamic Kernel Module Support]]
Line 74: Line 75:


See [[DKMS package guidelines]].
See [[DKMS package guidelines]].
== Initial ramdisk ==
In case you have got any kernel modules installed via DKMS that are used in [[Wikipedia:Initial ramdisk|initial ramdisk]], e.g. {{AUR|zfs-dkms}}, you may want to write a [[pacman]] hook to automate the process of regenerating initramfs image(s).
For example, when using {{Pkg|linux}} and [[mkinitcpio]], to update [[ZFS]] module after each {{AUR|zfs-dkms}} upgrade,
{{hc|1=/etc/pacman.d/hooks/90-mkinitcpio-dkms-linux.hook|2=[Trigger]
Operation=Install
Operation=Upgrade
Operation=Remove
Type=Package
Target=zfs-dkms
Target=linux
[Action]
Description=Update dkms modules in Linux initcpio
Depends=mkinitcpio
When=PostTransaction
NeedsTargets
Exec=/bin/sh -c 'while read -r trg; do case $trg in linux) exit 0; esac; done; /usr/bin/mkinitcpio -p linux'}}
You may add more targets to the hook and make additional copies of the hook if you have installed other kernels. Note the {{ic|90-}} prefix is necessary to make sure it runs after the DKMS hooks.


== See also ==
== See also ==


* [https://www.linuxjournal.com/article/6896 Linux Journal: Exploring Dynamic Kernel Module Support]
* [https://www.linuxjournal.com/article/6896 Linux Journal: Exploring Dynamic Kernel Module Support]

Latest revision as of 21:48, 1 March 2024

From Wikipedia:

Dynamic Kernel Module Support (DKMS) is a program/framework that enables generating Linux kernel modules whose sources generally reside outside the kernel source tree. The concept is to have DKMS modules automatically rebuilt when a new kernel is installed.

This means that a user does not have to wait for a company, project, or package maintainer to release a new version of the module. Since the introduction of pacman hooks, the rebuild of the modules is handled automatically when a kernel is upgraded.

Installation

Install the dkms package and the headers for the target kernel/kernels. For example, for the default linux kernel this would be linux-headers. Other kernels have their own respective headers packages.

A good number of modules that lie outside the kernel source tree have a DKMS variant; a few are hosted in the official repositories, most are found in the AUR.

Upgrades

Though the rebuild of the DKMS modules is usually seamless during a kernel upgrade, it may still happen that the rebuild fails. You should pay extra attention to the pacman output. This applies in particular if the system relies on the DKMS module to boot successfully and/or if you use DKMS with a custom kernel not in the official repositories.

To deal with changes in the kernel, fix bugs, or add necessary features consider upgrading the DKMS package before rebooting.

Usage

Usage for invoking DKMS manually.

Tab-completion is available by doing:

# source /usr/share/bash-completion/completions/dkms

List modules

To list the current status of modules, versions and kernels within the tree:

# dkms status

Rebuild modules

Rebuild all modules for the currently running kernel:

# dkms autoinstall

or for a specific kernel:

# dkms autoinstall -k 3.16.4-1-ARCH

To build a specific module for the currently running kernel:

# dkms install -m nvidia -v 334.21

or simply:

# dkms install nvidia/334.21

To build a module for all kernels:

# dkms install nvidia/334.21 --all

Remove modules

To remove a module (old ones are not automatically removed):

# dkms remove -m nvidia -v 331.49 --all

or simply:

# dkms remove nvidia/331.49 --all

If the package dkms is removed the information regarding previous module build files is lost. If this is the case, go through /usr/lib/modules/kernel_release and /var/lib/dkms/package_name and delete all files and directories no longer in use.

DKMS package creation

See DKMS package guidelines.

See also