I want to differentiate an USB flash drive and a CD-ROM. My requirement is when I connect to a system only the CD-ROM should work, but not the USB key.

  • 1
    You need to write the udev rule. reactivated.net/writing_udev_rules.html
    – SHW
    Commented Jul 2, 2014 at 8:26
  • @SHW Thank you, here i am connecting cd rom externally via usb cable. so both are usb connected i.e. pendrive and external cd rom and also both are mass storage only. so now how to differentiate it in a udev rule.
    – subbarao
    Commented Jul 2, 2014 at 8:45
  • @SHW can you suggest me the udev rule accordingly.
    – subbarao
    Commented Jul 3, 2014 at 4:52
  • @subbarao Could you be more specific in the question? Where do you want do differentiate? Also it would be nice to have this USB connected CD-ROM drive on the question.
    – RSFalcon7
    Commented Apr 13, 2015 at 14:36
  • Could you define "should work" more specifically? Do you simply want to disable automounting or do you want something to secure your system against usb flash disks?
    – regdoug
    Commented Apr 18, 2015 at 1:42

1 Answer 1


If a USB flash device and USB cdrom is connected then only difference that I can find out is their kernel driver. Both uses the common usb and usb-storage kernel module but in addition to that CD-ROM uses sr module while USB uses the sd module.

Based on this info, you can write UDEV rule

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .