Linux Kernel Modules Explained: What They Are and Why They Exist
Kernel modules let Linux load drivers and features on demand. Learn how loadable modules work, where they live, how dependencies resolve and why it matters.
Published November 27, 2026
Your Linux kernel supports thousands of devices and filesystems, yet the kernel image itself is only a few megabytes. The trick is loadable kernel modules: pieces of kernel code compiled separately and loaded into the running kernel only when needed. Understanding modules explains how hardware gets detected, why some drivers "need installing", and what happens when a GPU driver breaks after an update.
The concept
A kernel module is an object file with a .ko extension (kernel object). Once loaded, its code runs in kernel space with full privileges, exactly like code built into the kernel image. The difference is only timing: built-in code is always present from boot, while module code is linked into the running kernel on demand and can usually be removed again.
Modules exist for three reasons. First, size: a distribution kernel must support every possible laptop and server, and loading only the needed drivers keeps memory use low. Second, flexibility: you can add a driver (for example a vendor network card or ZFS) without rebuilding the kernel. Third, development speed: kernel developers can rebuild and reload one module instead of rebooting into a new kernel.
Modules are tied to an exact kernel build. Each module records the kernel version and configuration it was compiled against (its "vermagic"). That is why third-party modules like NVIDIA drivers or VirtualBox must be rebuilt after a kernel upgrade, usually automatically by DKMS.
Where modules sit
How modules load automatically
Where modules live
Modules are stored under /lib/modules/$(uname -r)/, organised by subsystem (kernel/drivers/net, kernel/fs and so on). The file modules.dep, generated by depmod, records which modules depend on which, so modprobe can load them in the right order. modules.alias maps hardware IDs to module names, which is how udev knows that a given PCI device needs a particular driver.
$ ls /lib/modules/$(uname -r)/
build kernel modules.alias modules.builtin modules.dep modules.order ...
$ grep -m1 e1000e /lib/modules/$(uname -r)/modules.dep
kernel/drivers/net/ethernet/intel/e1000e/e1000e.ko.zst:Built-in vs loadable
| Built-in (=y) | Module (=m) |
|---|---|
| Always in memory from boot | Loaded only when needed |
| Needed to mount the root filesystem (or put in initramfs) | Can be added later, even third-party |
| Cannot be unloaded | Usually can be unloaded with rmmod |
| Configured with CONFIG_FOO=y | Configured with CONFIG_FOO=m |
Practical examples
See what is loaded right now
lsmod reads /proc/modules; the last column shows which modules use each one.
lsmod | head
cat /proc/modules | wc -lInspect a module
modinfo shows the file, license, parameters, dependencies and supported hardware aliases.
modinfo e1000e | grep -E '^(filename|version|license|depends|parm)'Find the driver behind a device
lspci -k shows the driver in use and candidate modules for each PCI device.
lspci -k | grep -A3 -i ethernet
# 00:1f.6 Ethernet controller: Intel Corporation Ethernet Connection (7) I219-LM
# Kernel driver in use: e1000e
# Kernel modules: e1000eCommon mistakes
- Assuming modules are sandboxed. A buggy module can crash the whole kernel (kernel panic or oops).
- Copying a .ko file from another machine with a different kernel version; it will be rejected with "invalid module format".
- Forgetting to rebuild the initramfs after changing module options for storage drivers needed at boot.
- Disabling Secure Boot to load an unsigned module instead of signing it with a Machine Owner Key (MOK).
Key takeaways
- Kernel modules are .ko files loaded into the running kernel on demand.
- They run with full kernel privileges, so bugs can crash the system.
- udev and modprobe load drivers automatically using modules.alias.
- Modules must match the exact running kernel; DKMS rebuilds third-party modules on upgrades.
FAQ
What is the difference between a module and a driver?
A driver is code that controls a device. Most drivers are packaged as modules, but modules can also provide filesystems, network protocols, or features like KVM that are not device drivers.
What is DKMS?
Dynamic Kernel Module Support: a framework that automatically recompiles out-of-tree modules (NVIDIA, ZFS, VirtualBox) whenever a new kernel is installed.
What does "tainted kernel" mean?
The kernel marks itself tainted when a proprietary or unsigned out-of-tree module is loaded. It still works, but upstream developers may decline to debug crash reports from a tainted kernel.