Module loading (insmod/modprobe)
insmod
and modprobe
are both tools for loading Linux kernel modules, but they have some differences in usage and functionality.
-
insmod
Order:- Function:
insmod
The command is used to manually load the specified kernel module into the running kernel. - usage:
insmod <module_name>
- Example:
insmod my_module.ko
- Function:
-
modprobe
Order:- Function:
modprobe
The command is used to automatically load the specified kernel module and its related dependent modules. - usage:
modprobe <module_name>
- Example:
modprobe my_module
- Function:
Main differences:
insmod
It is only responsible for loading the specified kernel module and will not automatically resolve dependencies.modprobe
The specified kernel module will be automatically loaded, and other modules it depends on will be parsed and loaded recursively.modprobe
It also provides more options and functions, such as automatic processing of module parameters, automatic loading of symbol tables, etc.
In general, it is recommended to use modprobe
commands to load kernel modules, because it can automatically resolve dependencies between modules and provide more convenient functions. But in some specific cases, if you need to load a specific module manually without caring about dependencies, you can use insmod
the command.
Module uninstall (rmmod)
rmmod command:
Meaning: The rmmod command is used to uninstall the specified kernel module from the running kernel.
Usage: rmmod <module_name>
Example: rmmod my_module
Description: The rmmod command is used to uninstall kernel modules that are no longer needed. It will remove the corresponding modules from the kernel and release related resources.
the difference
insmod and rmmod are lower-level commands that require manually specifying the module file name to be loaded or unloaded.
modprobe is a more advanced command that can automatically handle module dependencies and automatically load related modules based on module names.
modprobe also provides more options and functions to make module management more convenient and flexible.
In general, it is recommended to use the modprobe command to load and unload kernel modules, because it can automatically resolve dependencies between modules and provide more convenient functions. The insmod and rmmod commands are more suitable for manually loading and unloading modules under specific circumstances.