Also known as: LKM, loadable kernel module
A kernel module (or LKM, loadable kernel module) is a piece of object code that extends the running Linux kernel without rebooting. Drivers for specific devices, filesystem implementations, and networking protocols are commonly distributed as modules, so that a generic kernel can support diverse hardware by loading only the modules required. Modules run with full kernel privileges—there is no isolation from the rest of the kernel—so a buggy module can crash the system.
The relevant commands are:
lsmod # list currently loaded modules
modinfo nvidia # show metadata for a module
modprobe nvidia # load a module and its dependencies
modprobe -r nvidia # unload a module
insmod foo.ko # low-level load (rarely used directly)
rmmod foo # low-level unload
Modules are stored under /lib/modules/$(uname -r)/ and configured by files in /etc/modprobe.d/. The kernel automatically loads modules as needed through udev and systemd-modules-load.service. Out-of-tree modules (such as NVIDIA's proprietary driver) are commonly built against the running kernel with DKMS, which rebuilds them automatically when the kernel is updated. Modules make Linux usable across the wildly diverse world of consumer and server hardware.
Related terms: Kernel, Monolithic Kernel
Discussed in:
- Chapter 3: The Linux Kernel — Kernel Versions
Also defined in: Textbook of Linux