LKM
Platform Ops Glossary Kernel Modules
Fundamentals, Kernel & Shell · Term #89

Kernel Modules

Loadable pieces of kernel code (drivers, filesystems) added or removed without a reboot.

Category
Fundamentals, Kernel & Shell
Complexity
Intermediate
Glossary Entry
#89 of 190
Linux Kernel/proc/sysLinux Kernel/proc/sys
What Is It

The Short Answer

Rather than compiling every possible device driver into one enormous kernel image, Linux lets most drivers and optional subsystems live as separate loadable kernel modules (files ending in .ko) that get inserted into the running kernel on demand — often automatically, the moment matching hardware is detected.

This is what lets a single kernel image support wildly different hardware: a laptop and a server can run the exact same kernel version, loading only the modules relevant to their own hardware.

How It Works

Under The Hood

modprobe is the tool that actually matters day to day — unlike the lower-level insmod, it resolves a module's dependencies automatically (loading anything the requested module needs first) by consulting /lib/modules/$(uname -r)/modules.dep.

Removing a module that's still in use (a mounted filesystem's driver, a NIC still carrying traffic) will fail safely with an error rather than crash the kernel — the kernel tracks a reference count per module specifically to prevent that.

In Practice

Example Commands

work with modules
lsmod | grep nvidia
# list currently loaded modules
modprobe -r nvidia
# unload, fails cleanly if still in use
modinfo e1000e
# description, params, and dependencies for a module
Watch Out For

Common Mistakes

⚠️Force-unloading a module with rmmod -f to bypass a "module in use" error — this can crash the kernel or corrupt state; find and stop whatever's using it instead.
⚠️Blacklisting a module in the wrong config file location for your distro, so it still loads at boot despite the blacklist entry.
VA
Vishal Abhinav
Platform Ops Engineer · Linux & Unix Glossary