参考:5 UNIX / Linux modprobe Command Examples
简介
modprobe用于向Linux Kernel添加 或 移除 kernel modules。 kernel modules以.ko作为扩展名。 'modprobe'足够智能,可以先加载kernel module(如果有)的依赖模块,然后加载实际的kernel module。
kernel modules
kernel modules是一段代码,可以扩展操作系统Kernel的功能,而无需重新启动。 加载后,modules驻留在内存中,可以多次实例化,可以把他想像成类似于设备驱动程序的东西。
modprobe使用depmod生成的依赖关系列表 和 硬件映射 来智能地将modules加载到kernel 或 从内核移除。 加载和移除分别使用较低级别的insmod和rmmod命令。虽然可以手动调用insmod和rmmod,但建议使用depmod加载和卸载模块,以确保在进行更改之前考虑任何模块间依赖关系。
modprobe工作原理
modprobe搜寻modules目录
# ls /lib/modules/`uname -r` -F
build@ modules.alias.bin modules.dep.bin modules.symbols
initrd/ modules.builtin modules.devname modules.symbols.bin
kernel/ modules.builtin.bin modules.order vdso/
modules.alias modules.dep modules.softdep
对于所有模modules和其他文件,除了/etc/modprobe.d目录中的可选配置文件。 modprobe还将使用内核命令行中指定的模块选项,形式如下:
<module>.<option>
blacklists形式如下
modprobe.blacklist=<module>
现代版本的modprobe(内核版本2.4.x后)不会自行修改modules。 解析符号和理解参数的工作是在kernel中完成的。 因此,模块故障有时伴随着内核消息。modprobe需要一个最新的modules.dep.bin文件(或fallback human readable的modules.dep文件),由depmod实用程序生成。 此文件列出了每个模块需要的其他模块(如果有),modprobe使用它来自动添加或删除这些依赖项。如果在modulename之后给出了任何参数,它们将被传递给内核。