On Linux operating systems, the modprobe command adds and removes modules from the Linux kernel.

Description

Modules are pieces of code which extend the functionality of the operating system kernel without the need to reboot. Once loaded, modules reside in memory, and can be instantiated multiple times; they can be thought of as analogous to a device driver.

  • Description
  • Syntax
  • Examples
  • Related commands
  • Linux commands help

modprobe uses the dependency lists and hardware maps generated by depmod to intelligently load or unload modules into the kernel. It performs the actual insertion and removal using the lower-level programs insmod and rmmod, respectively.

While it’s possible to call insmod and rmmod manually, we recommend to load and unload modules using depmod to ensure that any inter-module dependencies are considered before changes are made.

Technical description

modprobe searches the module directory,

/lib/modules/uname -r

for all the modules and other files, except for the optional configuration files in the /etc/modprobe.d directory. modprobe also uses module options specified on the kernel command line in the form of:

.

…and blacklists in the form of:

modprobe.blacklist=

Modern versions of Linux modprobe (post-kernel version 2.4.x) do not modify modules themselves. The work of resolving symbols and understanding parameters is done inside the kernel. Module failure is therefore sometimes accompanied by a kernel message — see dmesg for more information about viewing them.

modprobe expects an up-to-date modules.dep.bin file (or fallback human readable modules.dep file), as generated by the depmod utility. This file lists what other modules each module needs (if any), and modprobe uses this to add or remove these dependencies automatically.

If any arguments are given after the modulename, they are passed to the kernel (in addition to any options listed in the configuration file).

Syntax

modprobe [-v] [-V] [-C config-file] [-n] [-i] [-q] [-b] [modulename] [module parameters…]

modprobe [-r] [-v] [-n] [-i] [modulename…]

modprobe [-c]

modprobe [–dump-modversions] [filename]

Options

Examples

The following series of commands illustrate a common way to use modprobe. Each command is prefixed with sudo, as they require root permissions:

sudo ln -s /path/to/your-kernel-module.ko /lib/modules/uname -r

sudo depmod -a

sudo modprobe your-kernel-module

These commands perform the following operations:

  • In the first command, we use ln to create a symbolic link to our module file in the directory /lib/modules/kernel-release. The command uname -r, enclosed in back quotes, is executed by the shell and translates to the appropriate string representing our kernel release version.
  • In the second command, an updated dependency list is generated by depmod -a to make sure the module we’re installing is aware of all existing modules and dependencies. This dependency list is used by modprobe when installing the module in the third command.
  • modprobe installs the kernel module.

depmod — Generate a list of kernel module dependences and associated map files.insmod — Insert a module into the Linux kernel.lsmod — Show the status of Linux kernel modules.modinfo — Show information about a Linux kernel module.rmmod — Remove a module from the Linux kernel.uname — Print information about the current system.