The Linux Kernel/Modules
A kernel module is a code that can be loaded into the kernel image at will, without requiring users to rebuild the kernel or reboot their computer. Modular design ensures that you do not have to make a monolithic kernel that contains all code necessary for hardware and situations.
Common kernel modules are device drivers, which directly access computer and peripheral hardware.
Kernel modules have a .ko extension.
⚲ API
- /proc/modules
- man 8 insmod – simple program to insert a module
- man 8 modprobe – searches and loads a module with dependencies
- /etc/modprobe.d/
- /lib/modules/$(uname -r)/modules.dep – module dependencies, is created by depmod -a
- man 8 lsmod – list loaded modules
- man 8 kmod – core program to manage Linux Kernel modules
- man 8 modinfo
- linux/init.h inc – initcalls
- linux/module.h inc – macros and functions for kernel module support
- module_init id – module initialization entry point
- module_exit id – module initialization exit point
- MODULE_LICENSE id – licence declaration
- linux/mod_devicetable.h inc – device ID tables for module device matching
- linux/export.h inc – macros for symbol export control to kernel modules.
- linux/kernel.h inc – miscellaneous stuff
⚙️ Internals
📖 References
📚 Further reading
- Loadable kernel module
- The Linux Kernel Module Programming Guide
- https://wiki.archlinux.org/title/Kernel_module
- Linux Driver Template
- http://lwn.net/images/pdf/LDD3/ch02.pdf
- http://www.xml.com/ldd/chapter/book/ch02.html
- Managing kernel modules, RHEL
- http://www.tldp.org/LDP/tlk/modules/modules.html