Loading...

Lab 6: Blacklisting a Problematic Kernel Module

Identify whether the pcspkr kernel module is loaded, unload it to stop immediate beeping, and blacklist it so it cannot be loaded again automatically. Validate the change using CLI-only checks.

troubleshooting boot core

Scenario

Your system keeps beeping on every alert. You have been asked to identify and disable the pcspkr kernel module. Your goal is to stop the beeping immediately and prevent the module from loading again in the future.

Operator context

This is a classic “reduce noisy behavior” sysadmin task. Unloading removes the module now, while blacklisting prevents future auto-load events.

Objective

  • Confirm whether pcspkr is currently loaded.
  • Unload the module to stop the immediate beeping.
  • Create a modprobe blacklist file under /etc/modprobe.d.
  • Verify the blacklist entry is present in the config.

Concepts

  • Unloading a module affects the current running kernel. It is the fastest way to stop behavior immediately.
  • Blacklisting controls future load behavior via modprobe. It prevents automatic loads triggered by hardware detection or dependency resolution.
  • If the module is in use, removal can fail. Validate state with lsmod and handle safely before forcing changes.

Walkthrough

Step 1: Check if pcspkr is loaded.
Command
lsmod | grep pcspkr

This confirms whether the pcspkr module is currently loaded. If it appears in output, the kernel has it active and it can trigger PC speaker beeps.

pcspkr                 20480  0
Step 2: Unload the module to stop beeping now.
Command
sudo rmmod pcspkr

Unloading removes the module from the running kernel immediately. If something depends on it (rare in practice), removal may fail, but for pcspkr it typically succeeds.

Step 3: Create a blacklist config to prevent future loads.
Command
echo 'blacklist pcspkr' | sudo tee /etc/modprobe.d/nobeep.conf

Blacklisting tells modprobe not to load this module automatically. Placing it in /etc/modprobe.d makes it persistent across reboots.

Step 4: Verify the blacklist entry is present.
Command
grep pcspkr /etc/modprobe.d/nobeep.conf

This confirms your configuration file contains the blacklist rule. If the line is present, the persistent configuration is in place.

blacklist pcspkr

Common breakpoints

No output from lsmod | grep pcspkr

That means the module is not loaded right now. You can still blacklist it to prevent future loads, but there is nothing to unload.

rmmod fails with “Module is in use”

Something has an active dependency. Confirm with lsmod | grep pcspkr and check related input/beep packages or drivers. In most environments, pcspkr is not required, but avoid forcing removal on a production host.

Blacklisting does not stop manual loads

Blacklisting prevents auto-load behavior. An administrator can still load a blacklisted module manually unless additional policy is in place.

Module still loads after reboot

Confirm the file exists under /etc/modprobe.d and the line is correct. Also search for other files that reference the module name: grep -R pcspkr /etc/modprobe.d.

Cleanup checklist

Optional revert

If you need to undo the blacklist for testing, remove the file and re-check: sudo rm -f /etc/modprobe.d/nobeep.conf and confirm with grep -R pcspkr /etc/modprobe.d.

Success signal

pcspkr no longer appears in lsmod after removal, and your blacklist file contains the expected line.

Reference

  • lsmod: Lists currently loaded kernel modules.
  • grep: Filters output by matching patterns.
  • rmmod <module>: Unloads a kernel module from the running system.
  • /etc/modprobe.d/*.conf: Persistent configuration for module load behavior.
  • blacklist <module>: Prevents automatic loading of a module by modprobe.
  • tee: Writes stdin to a file (useful with sudo for protected paths).