• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

What is the difference between insmod and modprobe

by admin

During development, you usually use insmod to load a module and it should be given the path of the module to load:

$ insmod filename [module-options]

It is low-level form of module loading, that forms the base of other module loading methods, and is the one we will use in this book. On the other hand, there is modprobe, mostly used by sysadmins or in a production system. modprobe is a clever command that parses the modules.dep file in order to load dependencies first, prior to loading the given module. It automatically handles module dependencies, as a package manager does:

$ modprobe module-name
insmod modprobe
Loads the module given as ‘insmod /path/to/module.ko’ Loads the module only in /lib/modules/$(uname -r). ‘modprobe /home/test/hello.ko’ will not work
Dependencies if present are not loaded modprobe calculates dependencies, loads the dependencies and then the main module

How modprobe calculates dependencies?

Modprobe depends on depmod tool to calculate dependencies. depmod calculates dependencies of all the modules present in /lib/modules/$(uname -r) folder, and places the dependency information in /lib/modules/$(uname -r)/modules.dep file

E.g. kernel/drivers/net/wireless/admtek/adm8211.ko: kernel/net/mac80211/mac80211.ko kernel/net/wireless/cfg80211.ko kernel/drivers/misc/eeprom/eeprom_93cx6.ko

In this case, eeprom_93cx6.ko, cfg80211.ko is loaded first and then adm8211.ko

Modules are loaded right to left and removed left to right. So while removing adm8211.ko is removed, then cfg80211.ko and finally eeprom_93cx6.ko. We can re-load the modules.dep file by running “depmod -a” command

Summary

insmod is a system administration command to load the module filename into the kernel. Simpler but less flexible than the modprobe command. Error messages from insmod may be vague, because the kernel performs module operations internally and therefore sends error information to the kernel log instead of standard output; see dmesg.

The information in the module.* files is used by the command modprobe to locate a module by name rather than the full path. modprobe has many other features which are described in the manual.

The module dependency information is also used by device managers, udev in particular. When new hardware is detected, for example a new USB device, the udevd daemon is alerted and passed the vendor, and product IDs are read from the hardware. udevd scans the module dependency files looking for a module that has registered those IDs. If one is found, it is loaded using modprobe.

Filed Under: Linux

Some more articles you might also be interested in …

  1. CentOS / RHEL : How to rotate /var/log/wtmp and /var/log/btmp file using logrotate
  2. “git force-clone” Command Examples
  3. Insert into search_tmp… queries never ends
  4. gunzip Command Examples in Linux
  5. rdesktop: command not found
  6. ddev: Container based local development tool for PHP environments
  7. What happens in the Background when you execute the “useradd” command under Linux
  8. mkfs.ntfs: command not found
  9. sysctl: command not found
  10. maestral Command Examples

You May Also Like

Primary Sidebar

Recent Posts

  • Vanilla OS 2 Released: A New Era for Linux Enthusiasts
  • mk Command Examples
  • mixxx Command Examples
  • mix Command Examples

© 2025 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright