View Full Version : HOWTO: Prevent (blacklist) modules from loading

April 26th, 2006, 11:56 PM
It is sometimes useful to prevent a module from loading. This howto will show you how to do this, and should be applicable to most modern Linux distros. This is really easy to do, so if you want you can just skip to the end to see how to do it; if you are more interested in how this stuff actually works, read the full howto.

My motivation for doing this was to prevent the system bell from sounding. In other words, I didn't want my laptop to beep if I backspaced on an empty line in a virtual console, or put my laptop into sleep mode. The system bell (which is actually a buzzer not controlled by your speakers) is accessed via the pcspkr module.

In most modern Linux distributions (I think from kernel 2.2 onwards) the module settings are controlled by the file /etc/modprobe.conf and the files in the /etc/modprobe.d directory. In particular, if you are running udev on your system one of the things that udev does is check all of these files and load modules based on their contents. This is a good thing, because it means that you can create your own files in /etc/modprobe.d to fiddle with the files that come with the module-init-tools package.

Creating a blacklist file
Since you probably don't want to mess with any of the files that come with your system, you will want to create a new file to hold all of the rules that you write. I called mine blacklist-custom, but you can call yours anything that isn't already taken. This file goes in the /etc/modprobe.d directory. Once you have created the file, you can blacklist modules by adding a line of the form "blacklist name_of_module". Lines starting with a # are ignored. My file looks like this:

# /etc/modprobe.d/blacklist-custom
# Custom blacklist file so I don't mess with any of the files that come with
# the module-init-tools package.
blacklist pcspkr
The changes will take place next time you reboot (well, technically the next time you reload udev).

Manually loading/unloading and listing modules
If you want to unload the module without rebooting, you can use the command

user@ubuntu$ sudo modprobe -r pcspkr
If you later decide you want to manually load a module, issue the command

user@ubuntu$ sudo modprobe pcspkr
To check whether or not a module is running, use the lsmod command. Since you will probably get a pretty long list, you can check for a particular module by combining lsmod with grep. For example to list all loaded modules, use

user@ubuntu$ lsmod
and to check if any modules with "spkr" in the name are loaded, use

user@ubuntu$ lsmod | grep spkr

May 8th, 2006, 01:18 PM
Thanx for the info, i am going to try and use this for my wireless card, rather use ndiswrapper instead. hopefully it works better.

July 29th, 2008, 03:53 PM
thanks, your info was helpful.
only one thing: sometimes it's necessary to update the initramfs with
update-initramfs -u
so that the module really does not load.

December 2nd, 2008, 03:55 AM
Thanks to both eklitzke and flow_ca -- this is great information and helped me along a good bit.

December 7th, 2008, 01:24 PM
Thanks. Just tried it and worked.

February 10th, 2009, 02:32 PM

and as for disabling the beep sound you also can use the command:

setterm -blength 0

and put it in your .profile

April 22nd, 2009, 10:45 PM
newer versions need the blacklist file to have the .conf extension.

A wiki would be much better for such tutorials, don't you guys think?

November 18th, 2009, 03:10 PM
I've got a problem with Virtualbox since upgrading to 9.10. The modules kvm-intel and kvm are running and prevent virtualbox from starting a VM. I've added the lines

blacklist kvm_intel
blacklist kvm

to the blacklist.conf file, however after a reboot these modules still load.

every time I start virtualbox I need to preceed this with:

sudo rmmod kvm_intel kvm

Anyone got any ideas how to get rid of this nasty beastie thats making my Koala far from Kalm?

November 28th, 2009, 08:06 AM
Anybody have any ideas for Gresley?

December 9th, 2009, 03:58 PM
I had this same problem. It turns out the qemu manually loads the kvm kernel module. So if you run

sudo apt-get remove qemu-kvm qemu --purge

It should no longer load the kvm kernel modules.

December 11th, 2009, 09:47 PM
I had the same problem with a different module. Just adding it to the blacklist did nothing. I found the answer here:
From Temüjin's post:

After you blacklist it:

sudo update-initramfs -u
Do that to make the blacklist change stick.

July 31st, 2011, 01:14 AM
iam new in linux now using natty 11.04
my plymouth broken by
SP5100 TCO timer: mmio address 0xfec000f0 already in use

how to disable that module

August 13th, 2011, 10:20 AM
I've tried to blacklist firewire_ohci and firewire_core modules following this tutorial, but is not working.
I'm using the latest Ubuntu 11.04

Anyone know how to blacklist these 2 modules ?

August 13th, 2011, 10:31 AM
...have you tried adding them to
/etc/modprobe.d/blacklist.conf ?

November 14th, 2011, 05:45 PM
Oh thank you for that enough information!

October 25th, 2012, 05:55 AM
hi.. i'm completely new to ubuntu.
i have dual os (win7 and ubuntu 12.10) on sony vaio.
i think my problem is somewhere related with disabling device modules..
i want to turn off my wireless network as i never use it.
i've already tried disabling wireless network from windows.
in ubuntu it says "wireless is disabled by hardware switch" but the LED of wireless on my laptop is still turned on.(any function key is not provided in my laptop to turn off the wireless).
in windows "vaio smartnetwork" automatically turn off the wireless when the system boots but in ubuntu it never goes off.