insmod rmmod modprobe usage and differences

Module loading (insmod/modprobe)

insmodand modprobeare both tools for loading Linux kernel modules, but they have some differences in usage and functionality.

  1. insmodOrder:

    • Function: insmodThe command is used to manually load the specified kernel module into the running kernel.
    • usage:insmod <module_name>
    • Example:insmod my_module.ko
  2. modprobeOrder:

    • Function: modprobeThe command is used to automatically load the specified kernel module and its related dependent modules.
    • usage:modprobe <module_name>
    • Example:modprobe my_module

Main differences:

  • insmodIt is only responsible for loading the specified kernel module and will not automatically resolve dependencies.
  • modprobeThe specified kernel module will be automatically loaded, and other modules it depends on will be parsed and loaded recursively.
  • modprobeIt 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 modprobecommands 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 insmodthe 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.

Guess you like

Origin blog.csdn.net/Ternence_zq/article/details/131068125