3

I am trying to create a UDEV rule to match/allow the use of USB devices. However, there is a twist. I want to be able to use only USB mass storage.

Is there a unique UDEV parameter that can be used to determine if a given USB device is a mass storage device? If so, what is it? How do I implement it?

1

You can use 'KERNEL=="sd*", SUBSYSTEMS=="scsi" ' with some ATTRS to filter USB storage devices. Notice all the USB storage devices thus also pendrives and memory cards are recognized as SCSI devices so they are assigned as /dev/sd*.

Here you have a very good tutorial on how to create UDEV rules:

  • Comment to editors: You have changed 'serial' to 'SCSI' in my answer what isn't correct. 'sd' was in fact an acronym of 'SCSI disk' historically but now is generally used for any serial devices. Pendrives, memory cards or SATA disks are not SCSI devices. – Sebastian Piech Oct 7 '14 at 9:05
  • I also think it's very bad habit to change original text of a question or answer even if something is technically incorrect. It should be corrected/explained by adding proper comment. – Sebastian Piech Oct 7 '14 at 9:14
0

Run udevadm info -a -n /dev/sdb where /dev/sdb is the device you want to identify to see what rules would match it. Pick one or more whose combination match only the devices you want to act on. This is a general strategy for coming up with udev rules; see Triggering an action when a specific volume is connected. In this case:

DRIVERS=="usb-storage"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.