Inspect loaded kernel modules, read module metadata, and load and unload a safe module using standard tooling. Verify module state using direct module listings and kernel-exposed sources.
Your team needs a repeatable workflow for validating kernel module state during troubleshooting. You will list loaded modules, inspect module metadata, load and unload a safe module, and verify state changes using standard tools.
Treat module operations as a controlled change. Unloading the wrong module can impact storage, networking, graphics, or security controls.
modinfo
.
modprobe
.
lsmod
and
/proc/modules
.
lsmod
output (name, size, use count).
modinfo
(filename, description, license, parameters, aliases).
modprobe
and
modprobe -r
.
/proc/modules
for alternate validation and scripting.
lsmod | head -n 10
lsmod
shows what is loaded right now. The
Used by
count helps you estimate whether a module is likely to unload
cleanly and what else may depend on it.
Module Size Used by
xfs 999424 1
e1000 155648 0
loop
module.
modinfo loop
modinfo
answers “what is this module,” “where is it on disk,” and
“what options does it accept.” Use this to confirm you are
operating on the correct module before loading it or
debugging why it will not load.
# Example fields to confirm:
filename: /lib/modules/.../kernel/drivers/block/loop.ko
description: Loopback block device
license: GPL
parm: max_loop:int
loop
module into the kernel.
sudo modprobe loop
modprobe
loads the module and resolves dependencies automatically. If
the module is already loaded or built into the kernel, you
may see no output.
# No output is normal on success.
loop
is loaded.
lsmod | grep -E '^loop(\s|$)'
Filtering
lsmod
output is the fastest way to prove the module is present. If
it does not appear, confirm whether the module is built-in
or inspect errors from the load attempt.
loop 45056 0
grep -E '^loop ' /proc/modules
/proc/modules
is a kernel-exported view of module state and can be used as
an alternate verification source.
Parameters apply at load time. If the module is already loaded, the new value may not take effect until the module is unloaded and loaded again.
sudo modprobe loop max_loop=8
This demonstrates the parameter syntax. Use
modinfo
output to confirm supported parameter names and expected
types before applying them.
# If you need to apply a parameter reliably:
sudo modprobe -r loop && sudo modprobe loop max_loop=8
loop
module and confirm removal.
A module may refuse to unload if it is in use. That failure is a safety feature. Confirm dependencies before retrying removal.
sudo modprobe -r loop
modprobe -r
removes the module with dependency awareness. If the module
is still needed, the command may fail with an “in use”
message.
# Verify removal:
lsmod | grep -E '^loop(\s|$)'
sudo rmmod loop
rmmod
removes a module directly and does not resolve dependencies.
Prefer
modprobe -r
for normal operations.
The module is not available for the running kernel. Confirm your kernel version and module path, then verify that module packages are installed for that kernel.
A dependency or active consumer is preventing removal. Identify what is using the module, stop the dependent service or workload, then retry. Do not force removal without understanding impact.
The module may be built into the kernel or the load failed.
Re-check
modinfo
and validate state via
/proc/modules
. If needed, inspect recent kernel messages for load errors.
Parameters are applied at load time. If the module was already loaded, unload it and reload with the parameter to ensure the new value is applied.
This lab changes kernel state only if you loaded the module. Your cleanup is ensuring the module is removed (if you loaded it) and that module state looks normal afterward.
lsmod | grep -E '^loop(\s|$)'
grep -E '^loop ' /proc/modules || true
You can prove module load state, inspect supported parameters, and perform a safe load/unload workflow without guessing.
lsmod
: Lists currently loaded kernel modules.
modinfo <module>
: Displays metadata for a kernel module.
filename
,
description
,
license
, and
parm
entries for parameters.
modprobe <module> [param=value]
: Loads a module and resolves dependencies.
modprobe -r <module>
: Unloads a module (if not in use).
-r
: Removes (unloads) the module.
rmmod <module>
: Removes a module directly without dependency resolution.
/proc/modules
: Kernel-exported view of loaded modules (name, size, use
count).
grep -E <regex> <file>
: Filters lines that match a regex.
-E
: Enables extended regular expressions.