How to stop a kernel module from being loaded

If you need to stop a particular kernel module from loaded automatically or by a user then you can use modprobe's configuration directory.

The example below stops USB mass storage devices from being used.

First create a file with the following contents in the /etc/modprobe.d directory:

$ cat /etc/modprobe.d/disable_usb_storage
install usb_storage /bin/echo "USB storage devices not permitted"

When that module is used the following message will be displayed:

$ modprobe usb_storage
USB storage devices not permitted

Last updated: 12/06/2008