Skip to main content
RunBook Academy

LinuxX · Kernel ManagementModules

Kernel modules — load, list, dependencies, blacklist

Intermediate⏱ ~12 minbashlsmodmodprobemodinfo

What you'll learn

  • List loaded modules and their dependencies
  • Load and unload modules with modprobe
  • Make a module load at every boot with /etc/modules-load.d
  • Blacklist a module to prevent it from loading
  • Disable a module on every load path with blacklist plus install
  • Investigate module load failures

Prerequisites

Verified against Ubuntu 24.04 LTS · Debian 12 (Bookworm) · RHEL 9.x · Rocky Linux 9.x · AlmaLinux 9.x · Linux kernel 6.1 LTS / 6.6 LTS · systemd 255+ · OpenSSH 8.7p1 (RHEL 9) / 9.6p1 (Ubuntu 24.04) · nftables 1.0.x · chrony 4.x · Pacemaker 2.1.x · Corosync 3.1.x · 2026-08-09

Not yet marked complete on this device.

The Linux kernel is modular. Most drivers and filesystems are loadable kernel modules (LKMs) that the kernel loads on demand. Managing modules — listing, loading, unloading, blacklisting — is a core sysadmin skill.

Listing modules

Read-only / Safelsmod
$ lsmod | head
Module                  Size  Used by
nls_iso8859_1           12288  1
dm_multipath           32768  0
dm_mod                131072  9 dm_multipath
...

Illustrative output

Read-only / Safe/proc/modules
$ cat /proc/modules | head
nls_iso8859_1 12288 1 - Live 0x0000000000000000
dm_multipath 32768 0 - Live 0x0000000000000000
...

Illustrative output

Module dependencies

Read-only / Safemodinfo
$ modinfo dm_multipath
filename:       /lib/modules/6.6.31-linuxkit/kernel/drivers/md/dm-multipath.ko
version:        1.14.0
license:        GPL
description:    device-mapper multipath
author:         ...
depends:        dm-mod
retpoline:      Y
vermagic:       6.6.31-linuxkit SMP preempt mod_unload aarch64

Illustrative output

Loading and unloading

Service impact possiblemodprobe
$ sudo modprobe br_netfilter; sudo modprobe -r br_netfilter; sudo modprobe -r --force br_netfilter 2>&1

Illustrative output

modprobe.d — module configuration

Read-only / Safemodprobe.d
$ ls /etc/modprobe.d/
aliases.conf
blacklist.conf
dccp.conf
firewalld-sysctls.conf
...

Illustrative output

Loading a module at every boot

modprobe at the shell is runtime-only. The module is loaded until the next reboot and then it is gone. Nothing in /etc/modprobe.d/ brings it back — that directory configures loads, it does not request them.

The persistent equivalent is /etc/modules-load.d/. At sysinit, systemd-modules-load.service reads every .conf file in it and modprobes each module named, one per line:

Configuration changemodules-load.d
$ printf 'br_netfilter\nnf_conntrack\n' | sudo tee /etc/modules-load.d/50-network.conf; sudo systemctl restart systemd-modules-load.service; systemctl status systemd-modules-load.service --no-pager; lsmod | grep br_netfilter
br_netfilter
nf_conntrack
● systemd-modules-load.service - Load Kernel Modules
     Loaded: loaded (/usr/lib/systemd/system/systemd-modules-load.service; static)
     Active: active (exited) since Sun 2026-08-09 11:02:14 UTC
br_netfilter           32768  0
bridge                307200  1 br_netfilter

Illustrative output

Blacklisting

Read-only / Safeblacklist
$ cat /etc/modprobe.d/blacklist-floppy.conf
# Some chassis hardcode the floppy driver into the BIOS,
# and it can interfere with detection of the SATA drive.
blacklist floppy

Illustrative output

blacklist is not a disable switch

man 5 modprobe.d is precise about the limit: the blacklist keyword applies only to alias-based autoloading. Three loads still succeed against a blacklisted module:

  • An explicit modprobe usb-storage by a user or a script.
  • A load triggered as another module’s dependency.
  • A load from the initramfs, before /etc/modprobe.d/ is read.

To close every path, pair the blacklist with an install line that replaces the module’s load command with a program that does nothing and fails:

# /etc/modprobe.d/99-disable-usb-storage.conf
# blacklist stops the ALIAS path; install stops every path
blacklist usb-storage
install usb-storage /bin/false

install tells modprobe to run the given command instead of inserting the module. /bin/false runs, exits non-zero, and the module is never inserted — whether the request came from an alias, a dependency, or an explicit modprobe.

Then rebuild the initramfs so the rule is in force during early boot as well, and reboot:

Configuration changerebuild initramfs
$ sudo update-initramfs -u   # Debian family; use 'sudo dracut -f' on RHEL family

Illustrative output

Configuration changeblacklist nouveau
$ printf 'blacklist nouveau
blacklist nvidia
' | sudo tee /etc/modprobe.d/blacklist-nouveau.conf; sudo update-initramfs -u; sudo reboot

Illustrative output

Investigating module load failures

Read-only / Safemodprobe -v
$ sudo modprobe -v some_module 2>&1; journalctl -k --since '1 minute ago' --no-pager | tail
...

Illustrative output

Common module load failures:

SymptomCauseFix
“Exec format error”Module built for a different kernelInstall the matching kernel-modules package
“Unknown symbol”Module references a symbol not in the kernelUpdate the module or downgrade the kernel
“No such file or directory”Module file missingInstall the package that provides it
“Device or resource busy”Module in useStop the dependent service first

Knowledge check

Knowledge check · 5 questions

  1. Q1. What does `blacklist <module>` in /etc/modprobe.d/ do?

  2. Q2. A module carries a vermagic string that must match the running kernel before the kernel will load it.

  3. Q3. Which of the following are correct module practices? Select all that apply.

  4. Q4. You run `modprobe br_netfilter` and add net.bridge.bridge-nf-call-iptables=1 to /etc/sysctl.d/99-k8s.conf. After the next reboot, container network policy is not enforced. Why?

  5. Q5. A CIS control requires usb-storage to be disabled. The host has `blacklist usb-storage` in /etc/modprobe.d/ and the module is not in lsmod. The audit still fails. What is the most likely cause?

Passing score: 75%. Answers are checked in this browser.