Udev Rule-Blocking Usb Storage


Here comes a very interesting tip / hack on Linux.

Here is how we can block any (read any) USB storage device connecting to your Linux Box.

There are couple of ways to achieve the target.

1. You can use /boot/grub.conf and use “nousb” as the kernel parameter. You have learned about kernel boot parameters in your RHCE Training.

2. You can blacklist the module or driver using the /etc/modprobe.d/blacklist.conf

But, I personally think the best way to achieve the goal is to use udev rules. Udev gives you the flexibility of tuning your rule for a specific vendor ID or serial ID or size of usb. Though its not shown here, I encourage you to explore more on udev.

Here is a small tip from my machine. Here, I intended to block all usb storage on my machine which has only one HDD i.e. sda.

Learn, Love, Live Linux.


Blocking usb storage using udev

Blocking usb storage using udev