Filters
How to search
  • Plain words find names, texts and examples.
  • "two words" finds the exact phrase.
  • --name or -x finds an option.
  • #word looks only inside commands.
  • @grep finds lessons and labs that use grep.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Put ! before a word to leave it out. OR between words means one of them.
  • ↑ ↓ to move · Enter to open · Esc to close · / to search

modprobe

Load or unload kernel modules, with their dependencies and the settings from /etc/modprobe.d/.

Level
RHCSA exam
Group
Kernel and hardware
Needs root
Yes
Package
kmod

What it does

modprobe NAME loads a module and everything it needs; modprobe -r NAME removes it and unused dependencies. Parameters can be given on the command line (modprobe loop max_part=8) or in /etc/modprobe.d/*.conf with options. In the same folder blacklist and install … /bin/false stop modules from loading.

Modules that must load at boot go in /etc/modules-load.d/*.conf.

How to write it

modprobe [OPTION]... MODULE [PARAMETER=VALUE]...
modprobe -r [OPTION]... MODULE...
modprobe -c

Options 20

Most used

-r, --remove
Unload the module (and unused dependencies).
-a, --all
Load all modules named on the command line.
-n, --dry-run, --show
Do everything except load/unload.
-v, --verbose
Show what is done.
-q, --quiet
No error if the module is not found.
-c, --showconfig
Show the full configuration (options, blacklists, aliases).
--show-depends
List the files that would be loaded.
-b, --use-blacklist
Also apply blacklists when loading by name.
-i, --ignore-install, --ignore-remove
Ignore install/remove commands from the config.
-f, --force
Ignore version checks (dangerous).
--force-vermagic, --force-modversion
Ignore one kind of version check.
--first-time
Fail if already loaded (or not loaded with -r).
-R, --resolve-alias
Print the module name of an alias.
-C, --config FILE
Use another config file or folder.
-d, --dirname DIR
Root folder for modules.
-S, --set-version VERSION
Use modules of another kernel version.
-w, --wait MS
With -r: wait for the module to be unused.
--dump-modversions
Show the version info of a module file.
-s, --syslog
Errors to syslog.
-V, --version
Show the version.

Examples 10

$ run as a normal user# run as root (or with sudo)

  1. 1Load a module

    modprobe vfat
    lsmod | grep vfat

    fat is loaded too (dependency).

  2. 2Unload it

    modprobe -r vfat

    Fails if it is in use.

  3. 3Load with a parameter

    modprobe loop max_part=8

    Only until the module is unloaded or reboot.

  4. 4Parameter for good

    echo "options loop max_part=8" > /etc/modprobe.d/loop.conf

    Used every time the module loads.

  5. 5Load at boot

    echo vfat > /etc/modules-load.d/vfat.conf

    systemd-modules-load reads this folder.

  6. 6Block a module (hardening)

    printf 'blacklist usb-storage\ninstall usb-storage /bin/false\n' > /etc/modprobe.d/no-usb-storage.conf

    blacklist stops auto-loading; install /bin/false stops modprobe too.

  7. 7Test what would happen

    modprobe -nv vfat
    insmod /lib/modules/…/fat.ko.xz
    insmod /lib/modules/…/vfat.ko.xz

    No change.

  8. 8Show the active configuration

    modprobe -c | grep -E '^(options|blacklist)'

    All options and blacklists from all files.

  9. 9Which module serves an alias

    modprobe -R pci:v00008086d000010D3sv*sd*bc*sc*i*

    Hardware ID to module name.

  10. 10Rebuild the initramfs after changes for early modules

    dracut -f

    Blacklists of storage drivers must be in the initramfs too.

Files

/etc/modprobe.d/*.conf
options, blacklist, install, alias lines.
/etc/modules-load.d/*.conf
Modules to load at boot.
/lib/modules/$(uname -r)/
The module files.

Exit codes

0 :: Done. 1 :: Error.