insmod module in the Linux

December 26, 2022

insmod is a simple and fast program to insert the modules inside the Linux kernel.

insmod is very close to program modprobe, insmod does not read its modules from a set location and automatically insert them and take care of any dependencies.
The surrounding variable MODULECONF can also be used to choose the contrasting configuration file from /default/etc/modules.conf


insmod examples:

# insmod ppp or # insmod /var/src/sound_driver.ko

Once you’ve inserted the module, use lsmod command to check that the module has been inserted strongly as you could see below:

# lsmod | grep ppp

What’s the difference between insmod and modprobe?

modprobe reads the modules from /lib/modules/$(uname -r)/modules.dep.bin

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

When you use insmod to insert the module, I may get there error “Invalid module format”.
In this scenario it may be:

– Your module was built for an earlier kernel
– Install the latest kernel version and reboot