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 blacklist file using CLI-only verification.

troubleshooting boot core

Scenario

Your system keeps beeping on every alert. You’ve 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.

What You’ll Practice

  • Checking loaded modules with lsmod and filtering with grep .
  • Unloading a module with rmmod .
  • Writing a persistent blacklist rule using tee .
  • Verifying configuration content with grep .

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

Reference

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