43

Are there any differences between insmod and modprobe?

6 Answers 6

46

modprobe reads the modules from /lib/modules/$(uname -r)/modules.dep.bin (or without the .bin suffix if the other file is not available). From the same file, dependencies are loaded.

modprobe accepts the name of a .ko file in /lib/modules/$(uname -r) (e.g. nvidia-current for the file dkms/nvidia-current.ko) and aliases (modules.alias.bin). Builtins (modules.alias.bin) are recognized as well, but since these modules are loaded by default, there is not point in modprobing this kind of modules.

insmod on the other hand accepts paths to files. The module does not have to reside in /lib/modules/$(uname -r), but dependencies are not automatically loaded. This is the lower program used by modprobe to load modules.

Other programs related to modules are rmmod and modinfo.

rmmod removes a kernel name based on the name from /proc/modules. This name does not necessarily have to be the same as the one passed to modprobe (for the nvidia-current file, this is nvidia for example).

modinfo accepts a filename, or the filename without .ko suffix in /lib/modules/$(uname -r).

36

Per man insmod:

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

1
  • 2
    ah sorry, missed that line.
    – NES
    Jan 4, 2011 at 20:52
5

modprobe is an intelligent command, it 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 if insmod is used, 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

The modprobe utility is worth a quick mention. modprobe, like insmod, loads a mod- ule into the kernel. It differs in that it will look at the module to be loaded to see whether it references any symbols that are not currently defined in the kernel. If any such references are found, modprobe looks for other modules in the current module search path that define the relevant symbols. When modprobe finds those modules (which are needed by the module being loaded), it loads them into the kernel as well. If you use insmod in this situation instead, the command fails with an “unresolved symbols” message left in the system logfile

0

The modprobe command offers more features than the more basic insmod and rmmod utilities. modprobe intelligently adds or removes a module from the Linux kernel. Note that for convenience, there is no difference between _ and - in module names (automatic underscore conversion is performed). modprobe looks in the module directory /lib/modules/uname -r for all the modules and other files, except for the optional configuration files in the /etc/modprobe.d directory (some distributions use the /etc/modprobe.conf file instead).

know more

0

As described above insmod takes an explicit path of the "mymodule".ko files, while modprobe "mymodule" search in the /lib/modules/'uname -r' path for the module name and does not process explicit file names. I wanted to use modprobe and it did not find the .ko file in the path. Even if insmod can load it.

It turned out that I had to refresh the dependencies of modules with

sudo depmod

so that modprobe actually finds the modules that you newly place in the /lib/modules/'uname -r' path

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.