devutils/ATFQ/book ATFQ git

Part II · Your system

21.2 Kernel modules

alsomodulesmodulekernel modulelsmodmodprobemodinfodriverdriverstainteddkmsblacklist

TL;DR

  • Most drivers are modules: pieces of the kernel loaded when the hardware that needs them shows up.
  • lsmod lists the loaded ones, modinfo describes one, modprobe loads one with what it depends on.
  • Module options and blacklists go in a .conf file in /etc/modprobe.d/.
lsmod | sort -k2 -n | tail
modinfo snd_hda_intel | head
echo 'blacklist pcspkr' | sudo tee /etc/modprobe.d/nobeep.conf

On your machine

alice@laptopexample
$ atfq 21.2
  Loaded    4 modules; biggest: nvidia 53.7 MiB, nvidia_modeset 1.5 MiB,
            iwlwifi 476.0 KiB, snd_hda_intel 60.0 KiB
  Tainted   P: proprietary module loaded
            O: out-of-tree module loaded

An example: Alice's laptop, one of the test machines. In your terminal, this block shows your own machine, read live.

Pitfalls

Deep dive 2 questions

Who loads modules?

When a device appears, the kernel announces it with a "modalias", a string that describes the hardware. udev hands it to modprobe, which loads the module that claims it. Modules that have no hardware to wait for can be listed in /etc/modules-load.d/ to load at every boot.

What do the taint letters mean?

/proc/sys/kernel/tainted is a set of flags; 0 means clean. The common ones: P a proprietary module, O a module built outside the kernel tree, E an unsigned module, W the kernel issued a warning, D the kernel hit a fatal error (an "oops"). The full list is in the kernel documentation, under "tainted kernels".

Commands
lsmod modinfo modprobe
Paths
/proc/modules /etc/modprobe.d/ /etc/modules-load.d/
See also
20.1 From firmware to init
21.3 dmesg and the kernel log