Skip to content

Linux Kernel Module Loading

How modules are located, loaded, configured, and debugged on an embedded Linux system.

This English edition keeps the original illustrations and reproducible command or configuration examples.

Reference diagram 1

Reference diagram 2

Reference diagram 3

Commands and configuration

insmod hello.ko
modprobe hello
modules.dep
modules.alias
modules.symbols
modules.builtin
modules.builtin.modinfo
vim  /lib/modules/6.1.1+g29549c7073bf/modules.dep
# 省略部分
# trusted 依赖后面的模块
kernel/security/keys/trusted-keys/trusted.ko: kernel/drivers/crypto/caam/caam_jr.ko kernel/drivers/crypto/caam/caamkeyblob_desc.ko kernel/drivers/...
# 省略部分
# 直接加载内核模块 假设内核模块名称:hywelstar.ko
insmod hywelstar.ko
# 卸载指定内核模块
rmmod hywelstar

# 加载模块,并自动处理依赖关系
modprobe hywelstar
# 卸载
modprobe -r module_name

# 列出当前所有加载的内核(内核加载的看不到的)
lsmod

# 显示内核模块的详细信息
modinfo hywelstar

# 显示相关联的模块依赖关系
modprobe --show-depends hywelstar

# 显示当前的模块配置,包括别名、选项和黑名单等。
modprobe -c

# 卸载模块
sudo modprobe -r hywelstar

# 验证模块已卸载
lsmod | grep hywelstar

Practical notes

Test each change on a recoverable target, keep logs from the boot or failure path, and record the exact kernel and userspace versions used in the result.