Friday, February 27, 2009

Blacklisting kernels modules from command line

Sometimes the need to blacklist a module from the Linux kernel command line arise, though it's not very common, and it seems there's no a simple solution.

Well, most distributions support/etc/modprobe.d/blacklist kind of files stored in the filesystem, where you can list the modules to blacklist. But, what if this is not possible, mainly because you don't have a filesystem at all to change and reboot like happened to me while working in the new cult 3.1 thin client OS version ?

I'm listing te change here because it's very useful and can be used in other situations as well, like the one described here using Knoppix.

In the init file, while processing command line options, this snippet should be added

blacklist=*)
for m in $(echo ${x#blacklist=} | sed 's/+/ /g')
do
echo -e "# added by cult\nblacklist $m\n" >> \
/etc/modprobe.d/blacklist
done
;;
Here, the cult convention of separating multiple values in kernel command line options by '+' is used, but you can use ',' as well if you feel more comfortable.

Next time your kernel panics and you need to blacklist a module from the kernel command line you know.

No comments: