What is the difference between insmod and modprobe?
Short answer: insmod file.ko loads exactly the module file you give it and fails if the modules it depends on are not already loaded. modprobe name finds the module by name under /lib/modules/$(uname -r), reads the dependency list in modules.dep (generated by depmod) and loads dependencies first, applies options and aliases from /etc/modprobe.d/, and is what udev uses to auto-load drivers.
| insmod | modprobe | |
|---|---|---|
| Argument | path to a .ko |
module name or alias |
| Dependencies | not handled | loaded automatically |
| Config files | ignored | /etc/modprobe.d/*.conf (options, blacklist, aliases) |
| Removal | rmmod |
modprobe -r (also removes unused dependencies) |
How auto-loading works
- A driver declares the devices it supports with
MODULE_DEVICE_TABLE(of|pci|usb|i2c, ...). depmodturns those tables into aliases inmodules.alias.- When the kernel creates a device, it sends a uevent with a
MODALIAS(e.g.of:NtempT(null)Cti,tmp102). - udev runs
modprobe <modalias>, which finds and loads the matching module.
Useful commands: modinfo -F depends mymod, cat /sys/module/mymod/parameters/*, modprobe --show-depends mymod, and blacklist mymod in a modprobe config file to prevent auto-loading.