modprobe
Add or remove kernel modules
TLDR
Pretend to load a module into the kernel, but don't actually do it
Load a module into the kernel
Remove a module from the kernel
Remove a module and those that depend on it from the kernel
Show a kernel module's dependencies
SYNOPSIS
modprobe [options] modulename
modprobe [options] -r modulename
PARAMETERS
-r, --remove
Remove a module. modprobe will also remove dependent modules if they are no longer in use.
-v, --verbose
Print messages about the actions being taken, useful for debugging.
-f, --force
Force loading or unloading, ignoring version mismatches or if a module is in use. Use with extreme caution as it can destabilize the system.
-n, --dry-run
Don't actually insert or remove the module, just print what would happen.
-D, --show-depends
Show the dependencies of a module without actually loading it.
-a, --all
Load all modules matching the module name specified. Useful for loading multiple aliases.
DESCRIPTION
modprobe is a Linux command-line utility used for intelligently adding and removing modules from the Linux kernel. Unlike the lower-level insmod and rmmod commands, modprobe understands module dependencies. When asked to load a module, it automatically loads all necessary prerequisite modules first. Similarly, when removing a module, it ensures that dependent modules are also unloaded if they are no longer in use by other parts of the system.
modprobe consults configuration files located in /etc/modprobe.d/ and the module dependency database generated by depmod (typically in /lib/modules/<kernel-version>/modules.dep.bin). This intelligent dependency resolution makes modprobe the preferred tool for managing kernel modules, simplifying the process for administrators and scripts. Additionally, it supports module blacklisting, aliasing, and passing kernel module parameters, offering a comprehensive solution for dynamic kernel configuration.
CAVEATS
- Requires root privileges to execute.
- Using --force can lead to system instability or crashes.
- Relies on an up-to-date module dependency file (generated by depmod); outdated files can cause incorrect behavior.
- Module changes made by modprobe are typically not persistent across reboots unless configured via system-level configuration files.
CONFIGURATION FILES
modprobe utilizes configuration files located primarily in /etc/modprobe.d/ (and /lib/modprobe.d/). These files allow administrators to define module aliases, specify options to be passed to modules at load time, blacklist modules to prevent them from loading, and set up pre/post-install/remove commands. This mechanism provides granular control over module behavior and system-wide module policies.
MODULE SEARCH PATH AND DATABASE
By default, modprobe searches for modules within /lib/modules/$(uname -r)/kernel/, corresponding to the currently running kernel version. It heavily relies on the modules.dep.bin file, which is a binary representation of module dependencies generated by depmod, to intelligently resolve and load all necessary modules in the correct order.
HISTORY
modprobe is part of the kmod tools suite, which succeeded the older module-init-tools package. It has evolved to provide more robust and secure kernel module management, particularly in handling dependencies and aliases. Its design aims to automate and simplify the complex task of dynamically configuring the Linux kernel through module loading and unloading, integrating seamlessly with modern Linux distributions.