Tuesday, July 17, 2012

Tip: Blacklisting kernel modules on CentOS 6.3

While trying the kernel-ml from the ELRepo repository I noticed that it ships with the pcspkr.ko kernel module which is in my opinion pretty annoying. 

To unload a kernel module, for instances pcspkr.ko, simply issue the rmmod command with the kernel module as argument. However this will only take place for the current session, the next time you reboot the machine hte kernel module will load. To prevent this we need to blacklist it by adding it to /etc/modprobe.d/blacklist.conf.

Putting everything together:

  1. $ su
  2. # rmmod -v pcspkr
  3. # echo "blacklist pcspkr" >> /etc/modprobe.d/blacklist.conf

On step 1 we've changed to superuser, on step 2 the kernel module (pcspkr was selected as an example) was removed from the current session and on step 3 we've prevented it from loading at boot.

As a side note, to list the currently loaded kernel modules run lsmod.

No comments: