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.
This is a classic “reduce noisy behavior” sysadmin task. Unloading removes the module now, while blacklisting prevents future auto-load events.
Objective
- Confirm whether
pcspkris 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
lsmodand handle safely before forcing changes.
Walkthrough
pcspkr is loaded.
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
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.
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.
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
That means the module is not loaded right now. You can still blacklist it to prevent future loads, but there is nothing to unload.
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 prevents auto-load behavior. An administrator can still load a blacklisted module manually unless additional policy is in place.
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
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.
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 bymodprobe.tee: Writes stdin to a file (useful withsudofor protected paths).