Kernel modules and drivers
How Linux loads drivers as modules on demand: lsmod, modinfo and modprobe, module options, why blacklisting is weaker than it sounds, and DKMS.
Kernel modules and drivers
The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.
Not started
What you'll learn
- Most drivers and many filesystems are built as loadable modules: .ko files under /lib/modules/$(uname -r)/ that the running kernel can load and unload without a reboot.
- lsmod lists what is loaded (it formats /proc/modules). modinfo shows a module's description, licence, parameters and the hardware IDs it claims.
- Use modprobe, not insmod. modprobe reads the dependency list depmod built and loads what a module needs first; insmod loads one file and fails on missing dependencies.
- Options go in /etc/modprobe.d/*.conf or on the kernel command line as module.option=value. A 'blacklist' line only stops automatic loading by alias; to block a module completely, add 'install <name> /bin/false'.
- Out-of-tree drivers (vendor NICs, GPU drivers, ZFS) are rebuilt for each new kernel by DKMS. Loading them taints the kernel, and under Secure Boot they must be signed with an enrolled key.
A kernel that fits every machine
A distribution ships one kernel build to millions of different machines. Each has a different network card, storage controller, GPU and set of USB gadgets. Compiling a driver for every possible device into the kernel image would make it enormous, and most of that code would never run on any given box.
So most drivers are built as loadable kernel modules: separate object files the running kernel can link into itself when needed and drop when not. A module runs in kernel space with full privilege, exactly like built-in code, which is why loading one is a root-only operation and why a bad one can crash the whole machine. The kernel space lesson explains that boundary.
Where modules live
Modules are .ko files under /lib/modules/$(uname -r)/, one tree per installed kernel, which is why a kernel and its modules must match. Next to them are index files that depmod generates: modules.dep (who depends on whom), modules.alias (which hardware IDs each module claims) and modules.builtin (drivers compiled into the image).
I looked at a real set inside Alpine 3.24’s netboot initramfs, unpacked on a Mac. It carries 347 modules for kernel 6.18.60-0-lts. Two lines from its modules.dep and modules.alias:
kernel/drivers/net/ethernet/intel/ixgbe/ixgbe.ko: kernel/drivers/net/ethernet/intel/libie/libie_fwlog.ko kernel/drivers/dca/dca.ko kernel/drivers/net/mdio.ko ...
alias pci:v00008086d000057BAsv*sd*bc*sc*i* e1000e
The first says the Intel 10-gigabit driver needs seven other modules loaded first. The second says the e1000e module handles PCI vendor 8086 (Intel), device 57BA. When the kernel discovers that device, udev asks modprobe for the alias and the right driver loads by itself. The udev lesson covers that event path.
Inspecting modules
lsmod lists loaded modules; its man page calls it “a trivial program which nicely formats the contents of the /proc/modules”. modinfo reads metadata stored in the module file itself, in an ELF section named .modinfo. I extracted that section from the initramfs’s e1000e.ko with a short Python ELF reader, which is the same data modinfo prints. Trimmed:
license=GPL v2
description=Intel(R) PRO/1000 Network Driver
parm=InterruptThrottleRate:Interrupt Throttling Rate
parm=IntMode:Interrupt Mode
depends=
intree=Y
name=e1000e
vermagic=6.18.60-0-lts SMP preempt mod_unload modversions
The parm lines are the knobs the driver accepts. vermagic is the kernel build it was compiled for, and the kernel refuses modules whose version information does not match. intree=Y means it is part of the official kernel source.
Loading and unloading
insmod inserts one file and nothing else. modprobe is what you use: it “looks in the module directory /lib/modules/$(uname -r)”, reads modules.dep.bin, and loads dependencies first. The man page adds that the real work “is done inside the kernel”, so when loading fails, the reason is in dmesg. These commands are from the man pages and were not run here:
lsmod | grep e1000e
modinfo e1000e
sudo modprobe e1000e InterruptThrottleRate=3000
sudo modprobe -r e1000e # remove it and unused dependencies
Making it permanent: modprobe.d
Configuration lives in /etc/modprobe.d/*.conf, read by modprobe on every load. The three directives you will use, from modprobe.d(5):
options e1000e InterruptThrottleRate=3000sets parameters “every time it is inserted into the kernel”.blacklist pcspkrmakes modprobe ignore the module’s built-in aliases.install pcspkr /bin/falseruns a command “instead of inserting the module”.
A common belief is that blacklist stops a module from loading. It does not quite. The man page is precise: it means “all of that particular module’s internal aliases are to be ignored”. The module will not auto-load for matching hardware, but an explicit modprobe pcspkr or another module depending on it still loads it. To block a module outright, for example a vulnerable filesystem or USB storage on a locked-down server, pair the blacklist with an install ... /bin/false line. For a module loaded from the initramfs, rebuild the initramfs too. For one-off boots, modprobe.blacklist=<name> works on the kernel command line.
Drivers built into the image ignore modprobe.d. Their options go on the kernel command line as module.option=value, as in the command line lesson.
Drivers from outside the kernel: DKMS and taint
Some drivers are not in the kernel tree: vendor NIC drivers, NVIDIA’s GPU driver, ZFS, VirtualBox’s modules. A module is compiled against one kernel version, so every kernel update would break them. DKMS keeps the module’s source, usually under /usr/src/<module>-<version>/ with a dkms.conf, and rebuilds it automatically when a new kernel is installed.
Such modules taint the kernel, a flag kernel developers check before looking at a bug report. The kernel’s tainted-kernels page lists P for “proprietary module was loaded”, O for an “externally-built (‘out-of-tree’) module” and E for an “unsigned module”. Under Secure Boot, the kernel may refuse unsigned modules entirely, so DKMS builds must be signed with a Machine Owner Key enrolled through shim, as described in the firmware lesson.
About the video
The embed is BlueMonkey 4n6’s “Loadable Kernel Modules - basic introduction and tutorial of module commands”, August 2023, 15 minutes, in full. It covers uname and /proc/version, lsmod and /proc/modules, modinfo, rmmod, insmod, modprobe, and a bonus section on parameters. It is part of a forensics-oriented series, at an intermediate level. It does not cover modprobe.d, blacklisting or DKMS, which this lesson adds. I judged it from its chapters and description, and English from the original English audio track. Two deeper videos fill the gaps: Ahmed Mansouri’s 2026 animated walkthrough includes blocking modules, and Chris Titus covers DKMS and firmware.
What was run: unpacking Alpine’s initramfs and reading modules.dep, modules.alias and the .modinfo sections with my own Python, on a Mac. Behaviour is quoted from modprobe(8), modprobe.d(5), lsmod(8) and the kernel’s tainted-kernels page, checked 2026-11-28.
Check yourself
You run insmod on a NIC driver and get 'Unknown symbol' errors. What should you have used and why?
modprobe. It looks up the module's dependencies in modules.dep and loads them first; insmod loads only the one file.
You add 'blacklist pcspkr' to a file in /etc/modprobe.d, yet the module still appears after something requests it by name. Why?
blacklist only makes modprobe ignore the module's built-in aliases, so it is not auto-loaded for matching hardware. An explicit modprobe or a dependency can still load it. 'install pcspkr /bin/false' blocks it.
How do you make an option for a module apply at every load?
Add 'options <module> <param>=<value>' to a .conf file in /etc/modprobe.d/, and rebuild the initramfs if the module is loaded there. For built-in drivers, use <module>.<param>=<value> on the kernel command line.
After a kernel update a vendor driver installed from source stops loading. What tool is meant to prevent this?
DKMS, which keeps the module's source and rebuilds it automatically for each newly installed kernel.
Go deeper
Notes
Notes are saved to your account.
Everything else on this page works without one — progress and bookmarks keep themselves in this browser and come with you when you sign in. Notes are the one thing worth not trusting to a browser you might clear.
Your notes could not be loaded.