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?
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.
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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With