[root tip] [How To] Kernel - Headers - DKMS

What you will learn

You will learn why AUR packages tend to create issues when they depend on DKMS and thus specific kernel headers.

You will also learn what DKMS is and how to mitigate build issues with DKMS package and other packages depending on the kernel headers.

Finally you will learn why the kernel headers is not present by default.

What is DKMS

DKMS is an acronym for Dynamic Kernel Module Service and is a set of scripts which can update your custom build drivers upon updating your kernel.

The common usecase is using AUR to build drivers for various wireless cards which lacks the kernel module to work and edge cases like using you phone as webcam.

A sure sign of a buildscript depending on DKMS is the -dkms phrase in the name of the buildscript.

DKMS requires the kernel headers packge to be installed on your system - but not any package - it must be the package matching your current running kernel and any other kernel you have installed - that is of course - it can be omitted if you don’t intend to use the specific script on other kernels.

AUR build scripts

AUR packages are created for Arch Linux - it should be obvious from the name.

AUR scripts are very useful - suffice you understand how to use them - but remember this

:warning: AUR is unsupported (read the disclaimer on AUR and Manjaro) so you must have the required knowledge or wish to learn how to use AUR scripts.

Kernel headers

Manjaro supports running multiple kernels - Arch always runs on the latest mainline kernel linux.

This means Manjaro has multiple headers packages and they use a different name schema - yet providing the required dependency to dkms linux-headers and remember this name is Arch naming because AUR is Arch.

On Manjaro this kernel dependency must be resolved manually - and you need to know which kernel you are using - otherwise pacman defaults to the first header package listed linux414-headers which of course won’t work unless you actually are using 4.14 as the primary kernel.

Manjaro builds upon Arch where the philosophy is K.I.S.S and therefore kernel and kernel headers are split packages.

Only a subset of users wil ever require the linuxXYY-headers package and therefore it is not installed by default and those needed the headers are required to know why and for which kernel.

Adding the linuxXYY-headers package to the default ISO will usually trigger the word bloat with the majority user base and add another item to the FUD machine targeting Manjaro.

Installing headers

Before you build any AUR script you should verify the build script - best practise and all - to verify if it depends on linux-headers or dkms.

If you find this to be true - list your installed kernels with mhwd

mhwd-kernel -li

Depending on you system you will get a response like

 $ mhwd-kernel -li
Currently running: 6.7.5-1-MANJARO (linux67)
The following kernels are installed in your system:
   * linux66
   * linux67

If you have more than one - consider removing unused kernels - usually you only need headers for currently active kernel.

Using the above example - we use pacman to install the headers - don’t ever just install the headers - always run a full system sync

sudo pacman -Syu linux67-headers

Now you are ready to run makepkg or pamac build or yay -S

If the package is a repo package depending on the kernel headers - pacman will display a numbered list of packages supplying the headers and you will have to tell pacman which one you need.

Be warned that the default selection is always number 1 and this is most likely not the package you want. Carefully examine the list and identify which header package contains the version of your running kernel.

Using the example from above you would look for the number identifying (x) linux515-headers - then feed that number to pacman.

Conclusion

The Manjaro slogan Enjoy the simplicity is not referring to package maintenance but how you get a fully functional system by using a Manjaro ISO to install your system.

Running a Linux system as a padawan - close to bleeding edge - requires persistence and willingness to learn. Issues and problems are important tutors in that regard.

DKMS packages are invaluable helpers - but remember - the usage is your responsibility and yours alone.

Feel free to ask - but don’t complain …

9 Likes

notes and extras

I think this is a very handy command to have ready when dealing with kernel headers:

pamac install $(pamac list --installed --quiet | grep "^linux" | grep "^linux[0-9]*[-rt]*$" | awk '{print $1"-headers"}' ORS=' ')

This will install the headers for all currently, still supported installed kernels.