System and processes

The modprobe command

Loads a kernel module with its dependencies, or unloads it with -r.

Syntax

modprobe [-r] <modulo>Try it in the terminal →

Most useful options

-r, --removeUnloads the module instead of loading it. If nothing else uses its dependencies, it tries to unload them too
-n, --dry-runDoes everything except inserting or removing the module: useful to see what would happen. With -v it helps debugging
-v, --verbosePrints what it is doing. Normally it only prints something when it fails
-q, --quietShows no error if the module does not exist, though the exit status is still an error
-c, --show-configPrints the effective configuration from the modprobe.d files and exits
--show-dependsLists the module files it depends on, including itself, without loading them
--first-timeMakes it fail if it did nothing, for example when the module was already loaded. Meant for scripts
-w, --wait <milisegundos>With -r, keeps retrying to remove the module while it is busy, up to that maximum time. Only since kmod 30

Copy-ready examples

$ modprobe --show-depends btrfslists the files that would be loaded, each on a line that starts with insmod. It loads nothing.
$ modprobe -n -v btrfssays what would happen without loading anything. The safe way to check first.
$ sudo modprobe btrfsloads the btrfs module and any dependencies it is missing.
$ sudo modprobe -r vboxdrvunloads the module and the dependencies nobody else uses. Warning: if something active is using it, the unload fails and forcing it is not advisable.

You can try them in the browser terminal: it does not touch your computer.

Common errors

MessageCauseFix
modprobe: FATAL: Module foo not found in directory /lib/modules/<versión del kernel>There is no module with that name for the running kernel: misspelled name, or the package is not installed. Dashes and underscores are interchangeable.Check the version with uname -r and look for the file inside /lib/modules/ with that version.
modprobe: ERROR: missing parameters. See -h.It was run without a module name.Add the name: modprobe name. Parameters go after the name.

Typical mistakes

  • Modules are looked up in /lib/modules/ for the running kernel version. After installing a new kernel, boot into it, or modprobe will not find the module.
  • If loading fails inside the kernel, modprobe sometimes gives little detail: the reason is in dmesg.
  • What you load by hand is lost on reboot. To load it at every boot, add it to a file in /etc/modules-load.d/.

Differences from similar commands

  • insmod: inserts one specific .ko file without resolving dependencies. modprobe finds the module by name and resolves what it lacks.
  • rmmod: unloads one module without touching its dependencies. modprobe -r also tries to remove the ones nobody else uses.
  • lsmod: only lists the loaded modules. modprobe loads or unloads them.

Related commands

FAQ

How do I check what modprobe would do without loading anything?

With -n and -v: modprobe -n -v name prints each step without inserting or removing anything. With --show-depends you see only the dependency files.

Why does modprobe do nothing when the module is already loaded?

That is expected: by default it succeeds and does nothing. Only with --first-time does it fail in that case, so a script can tell the difference.

How do I remove a module and its dependencies?

With sudo modprobe -r name. Dependencies still used by other modules are kept; lsmod shows who uses them.

More System and processes commands

Learn to actually use it

The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.

Start the free course