-2

I need a udev rule so that it should detect the vendor of the USB pendrive, and allow only specific vendors, rejecting all others.

  1. How to write such a rule ?

  2. Where should the rules be placed /etc/udev/rules.d or /lib/udev/rules.d/

  3. What is the command to get effect of the udev rule.

urgent plz

subbarao
  • 107
  • 1
  • 3

1 Answers1

0

I recommend looking at the output from dmesg or the files in /sys to detect the right vendor and model of your device. After you have those, writing a udev rule for the device is trivial. For example, this is the rule I use for my Apple iPod (written to /etc/udev/rules.d/60-ipod.rules):

ATTRS{serial}=="0000000000000000", ATTRS{manufacturer}=="Apple Inc.", ATTRS{product}=="iPod", KERNEL=="sd?1", SYMLINK+="ipod", GROUP="plugdev", MODE="0660"

This creates a /dev/ipod symlink to the first partition of a SCSI disk device with the defined serial number, from the manufacturer "Apple Inc.", with the model name "iPod".

Executing something like udevadm control --reload-rules and then udevadm trigger (depending on your platform) should rediscover and apply new rules to your device.

jmkeyes
  • 3,751
  • 17
  • 20