Persist kernel module behavior across reboots by blacklisting an
unwanted module and setting module options under
/etc/modprobe.d
. Validate that configuration is applied and rebuild initramfs so
early boot honors the policy.
A workstation fleet is loading an unnecessary legacy module that creates noise during troubleshooting. You will enforce a persistent blacklist for an unwanted module and define persistent options for a safe practice module, then validate the policy using standard tooling.
Persistent module policy should be documented and reviewed. A blacklist can disable hardware functionality, and options can change system behavior in ways that are not obvious during incident response.
/etc/modprobe.d
.
modprobe
.
lsmod
and a test load operation.
/etc/modprobe.d/*.conf
changes module behavior system-wide.
modprobe -c
is the best validation view.
pcspkr
.
echo 'blacklist pcspkr' | sudo tee /etc/modprobe.d/blacklist-pcspkr.conf
Files under
/etc/modprobe.d
are read by the module loader. Blacklisting prevents automatic
loads and commonly blocks manual loads via
modprobe
.
blacklist pcspkr
grep -R '^blacklist pcspkr' /etc/modprobe.d
This confirms the policy is written to disk in the correct location and helps you spot duplicates or conflicting entries.
/etc/modprobe.d/blacklist-pcspkr.conf:blacklist pcspkr
sudo modprobe pcspkr
This is a quick functional check. If the module is already loaded, blacklisting does not remove it from the running kernel.
modprobe: ERROR: Module pcspkr is blacklisted.
loop
.
echo 'options loop max_loop=16' | sudo tee /etc/modprobe.d/loop.conf
Module option files define default parameters applied when the module is loaded. This is a common tuning pattern that avoids editing bootloader configuration.
options loop max_loop=16
modprobe -c | grep -E '^options\s+loop\b'
modprobe -c
prints the resolved configuration after reading all relevant
config files. This is the clearest way to confirm your option
line is being picked up.
options loop max_loop=16
modinfo -p loop
modinfo -p
lists supported parameters. It does not confirm your configured
value, but it confirms the parameter exists and is valid.
Use the initramfs tool that matches your distribution. Do not run all of them.
# Debian or Ubuntu
sudo update-initramfs -u
# RHEL or Fedora
sudo dracut -f
# Arch
sudo mkinitcpio -P
If a module is loaded from initramfs during early boot, your policy must exist in that image. Rebuilding initramfs helps ensure consistent boot-time behavior.
# Example output:
update-initramfs: Generating /boot/initrd.img-...
pcspkr
is not loaded, then load
loop
.
lsmod | grep -E '^pcspkr(\s|$)'
Blacklisting prevents loads but does not automatically remove a module that is already loaded. This confirms current runtime state.
# No output means pcspkr is not loaded.
sudo modprobe loop
Loading the module confirms it is available and that policy is not preventing normal module operations.
lsmod | grep -E '^loop(\s|$)'
loop 45056 0
Your distro may allow manual loading even when blacklisted,
or the module may already be loaded. Validate the config with
modprobe -c
and confirm current state with
lsmod
.
The policy may not be present in initramfs or the module may be built in. Rebuild initramfs with the correct tool and verify the module type and load path.
Multiple config files can define options for the same module.
Locate duplicates under
/etc/modprobe.d
and ensure your intended file name and content are correct.
If this is a shared system or you want to reset lab state, remove the policy files you created and rebuild initramfs again with your distro’s tool.
sudo rm -f /etc/modprobe.d/blacklist-pcspkr.conf /etc/modprobe.d/loop.conf
modprobe -c | grep -E '^(blacklist\s+pcspkr|options\s+loop\b)' || true
If you remove policy and need early boot to reflect it, rebuild initramfs again using the correct distro tool.
/etc/modprobe.d/*.conf
: Persistent module loader configuration (blacklists and default options).
modprobe when resolving module load behavior.
modprobe
: Loads and unloads kernel modules with dependency awareness.
-c
: Prints the resolved configuration after reading all config files.
modinfo
: Displays module metadata and supported parameters.
-p
: Lists parameters the module supports.
lsmod
: Lists currently loaded kernel modules.
update-initramfs
: Rebuilds initramfs (Debian or Ubuntu).
-u
: Updates the existing initramfs image for the current kernel.
dracut
: Rebuilds initramfs (RHEL or Fedora).
-f
: Forces regeneration of the initramfs image.
mkinitcpio
: Rebuilds initramfs (Arch).
-P
: Rebuilds initramfs for all presets.
tee
: Writes stdin to a file (useful with sudo for root-owned paths).
-a
: Appends instead of overwriting.
grep
: Searches text using patterns.
-R
: Recursively searches a directory.
-E
: Uses extended regular expressions.
blacklist
: modprobe.d directive that prevents module auto-loading.
options
: modprobe.d directive that sets default module parameters at load time.
options <module> param=value.