What's the difference between insmod and modprobe?

前端 未结 4 1468
栀梦
栀梦 2021-02-19 21:20

I know insmod and modprobe are used to insert module into the kernel. But, what\'s the difference between them?

And, why is it dangerous to ins

相关标签:
4条回答
  • 2021-02-19 21:28

    modprobe is looks for dependencies while loading a module. Suppose, if I loaded a module, which has symbols defined in some other module (this module path is given inside the main module). So, modprobe loads the main module and the dependent module.

    But in case if you are using insmod to loading , it won't load the dependency, and hence it will give compilation errors like Unresolved symbols. In this case, we have to manually look for dependent module and need to load them in order to resolve the errors.

    0 讨论(0)
  • 2021-02-19 21:36

    insmod: Used to load a module
    modprobe: Much same way as insmod, but also loads any other modules that are required by the module that you want to load.
    Although you’ll still need insmod when loading your own modules from the current directory, because modprobe looks only in the standard installed module directories.
    Reference:https://lwn.net/Kernel/LDD3/

    0 讨论(0)
  • 2021-02-19 21:41

    modprobe is the intelligent version of insmod. insmod simply adds a module where modprobe looks for any dependency (if that particular module is dependent on any other module) and loads them.

    Regarding --force option, here is the quote from the man page:

       Try to strip any versioning information from the module which might otherwise
       stop it from loading: this is the same as using both --force-vermagic and
       --force-modversion. Naturally, these checks are there for your protection,
       so using this option is dangerous unless you know what you are doing.
    

    Which indicates it's been used to skip the kernel module version checking. Shouldn't be any problem if you do your own kernel module or from any trusted party. But you should know what you are doing.

    0 讨论(0)
  • 2021-02-19 21:41

    If you trust the Linux man pages isnmod.

    Most users will want to use modprobe instead, which is more clever and can handle module dependencies.

    0 讨论(0)
提交回复
热议问题