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.
lsmodlists the loaded ones,modinfodescribes one,modprobeloads one with what it depends on.- Module options and blacklists go in a
.conffile 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
$ 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
- Modules are built for one kernel version. After a kernel update, modules from outside the kernel (NVIDIA, VirtualBox) must be rebuilt: DKMS does it for you.
- A "tainted" kernel isn't broken: it runs code its developers can't debug, such as a proprietary module. Kernel developers usually ignore bug reports from tainted kernels.
blacklistonly stops automatic loading: the module can still load by hand or as a dependency.install NAME /bin/falseblocks it completely.- With Secure Boot on, the kernel refuses unsigned modules (see 20.1).
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".