lsmod, modprobe, insmod and rmmod: Managing Linux Kernel Modules

The complete guide to Linux module commands: list with lsmod, load with modprobe vs insmod, remove with rmmod, pass parameters and debug load failures.

Published November 27, 2026

Linux has two generations of module tools. The low-level ones (insmod, rmmod) operate on a single file and know nothing about dependencies. The high-level one (modprobe) understands dependencies, aliases, blacklists and configuration files. Knowing when to use which saves a lot of confusing "Unknown symbol" errors.

The concept

insmod takes a path to a .ko file and asks the kernel to load it. If that module needs symbols exported by another module that is not loaded yet, the load fails with "Unknown symbol in module". rmmod removes a module by name and refuses if anything is still using it.

modprobe takes a module name (or alias), looks it up in modules.dep, loads every dependency first, applies options from /etc/modprobe.d/, and honours blacklists. modprobe -r removes a module and any dependencies that are no longer needed. In practice you should use modprobe for everything except loading a module you just compiled from your own directory.

The tools at a glance

CommandInputResolves dependencies?Use it for
lsmod--List loaded modules with size and users
modinfoname or file-Show metadata, parameters, aliases
modprobename/aliasYesLoading modules normally
modprobe -rnameYesRemoving modules and unused deps
insmodpath to .koNoTesting a module you just built
rmmodnameNoRemoving a single module
depmod-Builds the mapRegenerating modules.dep after installing modules

What modprobe does that insmod does not

readfirstthenmodprobe kvm_intelrequestmodules.deplookupload kvm.kodependencyload kvm_intel.kotarget
modprobe loads dependencies first, insmod does not.

The dependency problem in action

sudo insmod /lib/modules/$(uname -r)/kernel/arch/x86/kvm/kvm-intel.ko.zst
insmod: ERROR: could not insert module: Unknown symbol in module
sudo dmesg | tail -1
kvm_intel: Unknown symbol kvm_vcpu_halt (err -2)
sudo modprobe kvm_intel
lsmod | grep kvm
kvm_intel 409600 0
kvm 1380352 1 kvm_intel
insmod fails on a missing dependency; modprobe loads kvm first and succeeds.

Module parameters

Many modules accept parameters that change their behaviour, listed by modinfo as parm lines. You can pass them at load time, set them persistently in /etc/modprobe.d/, or (for built-in drivers) on the kernel command line as module.param=value. Current values of loaded modules appear under /sys/module/NAME/parameters/.

modinfo -p kvm_intel | head -3
sudo modprobe -r kvm_intel && sudo modprobe kvm_intel nested=1
cat /sys/module/kvm_intel/parameters/nested     # Y
echo "options kvm_intel nested=1" | sudo tee /etc/modprobe.d/kvm.conf

Practical examples

Remove a module that is in use

Find who is holding it, stop that, then remove.

lsmod | grep ^kvm_intel        # "Used by" column shows count/users
sudo virsh list --all          # stop running VMs first
sudo modprobe -r kvm_intel

Dry run

See what modprobe would load without loading anything.

modprobe --show-depends nvme
modprobe -n -v nvme

After installing a custom module

Copy it into the tree, rebuild the dependency map, then modprobe by name.

sudo install -D -m 644 hello.ko /lib/modules/$(uname -r)/extra/hello.ko
sudo depmod -a
sudo modprobe hello

Common mistakes

  • Using insmod for system modules and hitting unknown symbol errors.
  • Forcing removal with rmmod -f, which can crash the kernel if code is still in use.
  • Forgetting depmod after copying a module into /lib/modules, so modprobe cannot find it.
  • Ignoring dmesg. The real reason for most load failures (bad parameters, missing firmware, signature errors) is printed there.

Key takeaways

  • Use modprobe and modprobe -r for normal work; they handle dependencies and config.
  • insmod and rmmod are low-level tools for single files.
  • Parameters go on the modprobe command line, in /etc/modprobe.d, or on the kernel command line.
  • Always check dmesg when a module fails to load.

FAQ

Why does modprobe say "Module not found"?

The name is wrong, the module is built in (check modules.builtin), it was compiled for another kernel, or depmod has not been run after installing it.

Can I unload a built-in driver?

No. Built-in code cannot be removed; you can only disable it via kernel parameters, such as modprobe.blacklist (which does not work for built-ins) or driver-specific options.

What does "Required key not available" mean?

Secure Boot is enforcing module signatures and the module is unsigned or signed with an untrusted key.

More Linux articles