Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between insmod and modprobe?

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 insert modules with force option in modprobe?

like image 907
Sagar Jain Avatar asked Apr 06 '14 08:04

Sagar Jain


People also ask

What is the most important practical difference between insmod and modprobe?

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.

What is modprobe command used for?

Use the modprobe command to add or remove modules on Linux. The command works intelligently and adds any dependent modules automatically. The kernel uses modprobe to request modules. The modprobe command searches through the standard installed module directories to find the necessary drivers.

What does insmod command do?

The insmod command is used to insert modules into the kernel. Kernel modules are usually used to add support for new hardware (as device drivers) and/or filesystems, or for adding system calls. This command inserts the kernel object file (. ko) into the kernel.

What do insmod and rmmod do?

The insmod command runs when CS Linux is started and the rmmod command runs when Linux is shut down or CS Linux updates are applied. Use the lsmod command to see what kernel modules are currently loaded. This is a list of the kernel module drivers which are currently loaded, as produced by the lsmod command.


2 Answers

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.

like image 70
rakib_ Avatar answered Oct 01 '22 06:10

rakib_


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.

like image 45
kpopovbg Avatar answered Oct 01 '22 08:10

kpopovbg