411 REFERENCE · Wikibooks
The Linux Kernel/Modules
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
== 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
8 insmod – simple program to insert a module
8 modprobe – searches and loads a module with dependencies
/etc/modprobe.d/, /lib/modprobe.d/, /run/modprobe.d/
/lib/modules/$(uname -r)/modules.dep – module dependencies, is created by depmod -a
8 lsmod – list loaded modules
8 kmod – core program to manage Linux Kernel modules
8 modinfo
/sys/module/$name/parameters/ – current module parameter values
/sys/module/$name/initstate – module initialization state (live, coming, going)
dkms – Dynamic Kernel Module Support, automatically rebuilds out-of-tree modules on kernel upgrades
dkms status – list installed DKMS modules and their build state
2 init_module, 2 finit_module – load a kernel module
2 delete_module – unload a kernel module
linux/init.h – initcalls
linux/module.h – macros and functions for kernel module support
module_init – module initialization entry point
module_exit – module cleanup exit point
MODULE_LICENSE – licence declaration
linux/mod_devicetable.h – device ID tables for module device matching
linux/moduleparam.h – module parameter declaration (module_param)
linux/export.h – macros for symbol export control to kernel modules.
linux/kernel.h – miscellaneous stuff
⚙️ Internals
kernel/module – loadable module support
📖 References
Building External Modules kbuild/modules.html
📚 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