Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: HOWTO: Prevent (blacklist) modules from loading

  1. #1
    Join Date
    Feb 2006
    Beans
    14

    HOWTO: Prevent (blacklist) modules from loading

    Introduction
    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:
    Code:
    # /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
    Code:
    user@ubuntu$ sudo modprobe -r pcspkr
    If you later decide you want to manually load a module, issue the command
    Code:
    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
    Code:
    user@ubuntu$ lsmod
    and to check if any modules with "spkr" in the name are loaded, use
    Code:
    user@ubuntu$ lsmod | grep spkr

  2. #2
    Join Date
    Jun 2005
    Location
    South Africa
    Beans
    259
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: HOWTO: Prevent (blacklist) modules from loading

    Thanx for the info, i am going to try and use this for my wireless card, rather use ndiswrapper instead. hopefully it works better.

  3. #3
    Join Date
    Jul 2008
    Beans
    4

    Re: HOWTO: Prevent (blacklist) modules from loading

    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.
    flow

  4. #4
    Join Date
    Dec 2008
    Beans
    1
    Distro
    Ubuntu 8.10 Intrepid Ibex

    Re: HOWTO: Prevent (blacklist) modules from loading

    Thanks to both eklitzke and flow_ca -- this is great information and helped me along a good bit.

  5. #5
    Join Date
    Feb 2008
    Beans
    11
    Distro
    Ubuntu 7.10 Gutsy Gibbon

    Re: HOWTO: Prevent (blacklist) modules from loading

    Thanks. Just tried it and worked.

  6. #6
    Join Date
    Feb 2007
    Location
    Tashkent, Uzbekistan
    Beans
    24
    Distro
    Ubuntu 7.10 Gutsy Gibbon

    Re: HOWTO: Prevent (blacklist) modules from loading

    thanks!

    and as for disabling the beep sound you also can use the command:
    Code:
    setterm -blength 0
    and put it in your .profile

  7. #7
    Join Date
    May 2007
    Beans
    4

    Re: HOWTO: Prevent (blacklist) modules from loading

    newer versions need the blacklist file to have the .conf extension.

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

  8. #8
    Join Date
    Mar 2009
    Beans
    23

    Re: HOWTO: Prevent (blacklist) modules from loading

    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?

  9. #9
    Join Date
    Dec 2008
    Location
    Woodland Park, NJ, USA
    Beans
    48
    Distro
    Ubuntu 8.10 Intrepid Ibex

    Re: HOWTO: Prevent (blacklist) modules from loading

    Anybody have any ideas for Gresley?

  10. #10
    Join Date
    Dec 2009
    Beans
    1

    Re: HOWTO: Prevent (blacklist) modules from loading

    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.

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •