How to blacklist specific vendor USB CDROM and flash drive

Asked by Andres Attemann

I do have USB EVDO modem (CMOTECH CNU-680) that is a composite device. The only thing I use is the modem part (serial port, e.g. /dev/ttyACM0).

Problem is, device also includes (emulated) USB CDROM and flash drive that are filling syslog with error messages and are not generally usable or useful.

Question is: how to disable specific USB flash and USB CDROM in Ubuntu with known USB Vendor ID?

udev rule with OPTIONS+="ignore_device" is not working. Flash drive and CDROM are still found at /dev/sdb and /dev/sr1

System is Xubuntu 11.10 oneiric

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu linux Edit question
Assignee:
No assignee Edit question
Solved by:
Andres Attemann
Solved:
Last query:
Last reply:
Revision history for this message
Andres Attemann (attemann) said :
#1

following udev rule is not working, devices are still attached to /dev/sr1 and /dev/sdb:
andres@aa-dv6:/etc/udev/rules.d$ head -3 86-kou.rules
#Ignore CMOTECH mass storage devices
SUBSYSTEM=="block" SYSFS{idVendor}=="16d8", ENV{UDISKS_DISABLE_POLLING}="1", ENV{UDISKS_PRESENTATION_NOPOLICY}="1", OPTIONS+="ignore_device"

Here's the device insertion:
andres@aa-dv6:/etc/udev/rules.d$ tail -f /var/log/syslog
Dec 11 14:10:51 aa-dv6 kernel: [ 1177.065705] usb 1-1.1: new full speed USB device number 8 using ehci_hcd
Dec 11 14:10:51 aa-dv6 mtp-probe: checking bus 1, device 8: "/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1"
Dec 11 14:10:51 aa-dv6 kernel: [ 1177.162812] scsi14 : usb-storage 1-1.1:1.3
Dec 11 14:10:51 aa-dv6 kernel: [ 1177.163308] scsi15 : usb-storage 1-1.1:1.4
Dec 11 14:10:51 aa-dv6 mtp-probe: bus: 1, device: 8 was not an MTP device
Dec 11 14:10:51 aa-dv6 laptop-mode: Laptop mode
Dec 11 14:10:51 aa-dv6 laptop-mode: enabled, active
Dec 11 14:10:51 aa-dv6 laptop-mode: Laptop mode
Dec 11 14:10:51 aa-dv6 laptop-mode: enabled, active
Dec 11 14:10:52 aa-dv6 kernel: [ 1178.161783] scsi 14:0:0:0: CD-ROM CMOTECH Mass Storage 2.31 PQ: 0 ANSI: 0 CCS
Dec 11 14:10:52 aa-dv6 kernel: [ 1178.161804] scsi 15:0:0:0: Direct-Access CMOTECH Mass Storage 2.31 PQ: 0 ANSI: 6
Dec 11 14:10:53 aa-dv6 kernel: [ 1178.578994] sd 15:0:0:0: Attached scsi generic sg2 type 0
Dec 11 14:10:53 aa-dv6 kernel: [ 1178.581357] sd 15:0:0:0: [sdb] 102401 512-byte logical blocks: (52.4 MB/50.0 MiB)
Dec 11 14:10:53 aa-dv6 kernel: [ 1178.582267] sr1: scsi3-mmc drive: 0x/0x caddy
Dec 11 14:10:53 aa-dv6 kernel: [ 1178.582680] sr 14:0:0:0: Attached scsi CD-ROM sr1
Dec 11 14:10:53 aa-dv6 kernel: [ 1178.582830] sr 14:0:0:0: Attached scsi generic sg3 type 5
Dec 11 14:10:53 aa-dv6 kernel: [ 1178.583343] sd 15:0:0:0: [sdb] Write Protect is off
Dec 11 14:10:53 aa-dv6 kernel: [ 1178.583352] sd 15:0:0:0: [sdb] Mode Sense: 0b 00 00 08
Dec 11 14:10:53 aa-dv6 kernel: [ 1178.584718] sd 15:0:0:0: [sdb] No Caching mode page present
Dec 11 14:10:53 aa-dv6 kernel: [ 1178.584726] sd 15:0:0:0: [sdb] Assuming drive cache: write through
Dec 11 14:10:53 aa-dv6 kernel: [ 1178.591576] sd 15:0:0:0: [sdb] No Caching mode page present
Dec 11 14:10:53 aa-dv6 kernel: [ 1178.591583] sd 15:0:0:0: [sdb] Assuming drive cache: write through
Dec 11 14:10:53 aa-dv6 kernel: [ 1178.601905] sdb:
Dec 11 14:10:53 aa-dv6 kernel: [ 1178.609869] sd 15:0:0:0: [sdb] No Caching mode page present
Dec 11 14:10:53 aa-dv6 kernel: [ 1178.609876] sd 15:0:0:0: [sdb] Assuming drive cache: write through
Dec 11 14:10:53 aa-dv6 kernel: [ 1178.609881] sd 15:0:0:0: [sdb] Attached SCSI removable disk
Dec 11 14:10:53 aa-dv6 kernel: [ 1178.639076] sr1: CDROM (ioctl) error, command: Xpwrite, Read disk info 51 00 00 00 00 00 00 00 02 00
Dec 11 14:10:53 aa-dv6 kernel: [ 1178.639092] sr: Sense Key : Hardware Error [current]
Dec 11 14:10:53 aa-dv6 kernel: [ 1178.639097] sr: Add. Sense: No additional sense information

Excerpt from dmesg for CDROM part:
andres@aa-dv6:~$ dmesg|grep sr
[ 2.094031] sr0: scsi3-mmc drive: 24x/24x writer dvd-ram cd/rw xa/form2 cdda tray
[ 2.094184] sr 1:0:0:0: Attached scsi CD-ROM sr0
[ 2.094231] sr 1:0:0:0: Attached scsi generic sg1 type 5
[ 3.745128] sr1: scsi3-mmc drive: 0x/0x caddy
[ 3.745284] sr 6:0:0:0: Attached scsi CD-ROM sr1
[ 3.745355] sr 6:0:0:0: Attached scsi generic sg2 type 5
[ 9.728467] type=1400 audit(1323604282.562:3): apparmor="STATUS" operation="profile_load" name="/usr/lib/NetworkManager/nm-dhcp-client.action" pid=565 comm="apparmor_parser"
[ 9.728737] type=1400 audit(1323604282.562:4): apparmor="STATUS" operation="profile_load" name="/usr/lib/connman/scripts/dhclient-script" pid=565 comm="apparmor_parser"
[ 10.012123] sr1: CDROM (ioctl) error, command: Xpwrite, Read disk info 51 00 00 00 00 00 00 00 02 00
[ 10.012752] sr: Sense Key : Hardware Error [current]
[ 10.012756] sr: Add. Sense: No additional sense information
[ 13.693206] sr1: scsi3-mmc drive: 0x/0x caddy
[ 13.693368] sr 8:0:0:0: Attached scsi CD-ROM sr1
[ 13.693425] sr 8:0:0:0: Attached scsi generic sg3 type 5
[ 13.740130] sr1: CDROM (ioctl) error, command: Xpwrite, Read disk info 51 00 00 00 00 00 00 00 02 00
[ 13.740138] sr: Sense Key : Hardware Error [current]
[ 13.740141] sr: Add. Sense: No additional sense information

sr0 is proper DVD here and sr1 is CNU-680 device.

Here is the flash drive part:

andres@aa-dv6:~$ dmesg|grep sdb
[ 3.809129] sd 7:0:0:0: [sdb] 102401 512-byte logical blocks: (52.4 MB/50.0 MiB)
[ 3.811179] sd 7:0:0:0: [sdb] Write Protect is off
[ 3.811186] sd 7:0:0:0: [sdb] Mode Sense: 0b 00 00 08
[ 3.813106] sd 7:0:0:0: [sdb] No Caching mode page present
[ 3.813111] sd 7:0:0:0: [sdb] Assuming drive cache: write through
[ 3.821098] sd 7:0:0:0: [sdb] No Caching mode page present
[ 3.821103] sd 7:0:0:0: [sdb] Assuming drive cache: write through
[ 3.831077] sdb:
[ 3.840065] sd 7:0:0:0: [sdb] No Caching mode page present
[ 3.840068] sd 7:0:0:0: [sdb] Assuming drive cache: write through
[ 3.840070] sd 7:0:0:0: [sdb] Attached SCSI removable disk
[ 10.201122] sd 7:0:0:0: [sdb] Unhandled error code
[ 10.201129] sd 7:0:0:0: [sdb] Result: hostbyte=DID_ERROR driverbyte=DRIVER_OK
[ 10.201133] sd 7:0:0:0: [sdb] CDB: Read(10): 28 00 00 00 00 00 00 00 08 00
[ 10.201141] end_request: I/O error, dev sdb, sector 0
[ 10.201207] Buffer I/O error on device sdb, logical block 0
[ 10.201268] Buffer I/O error on device sdb, logical block 1
[ 10.201326] Buffer I/O error on device sdb, logical block 2
[ 10.201384] Buffer I/O error on device sdb, logical block 3
[ 10.201440] Buffer I/O error on device sdb, logical block 4
[ 10.201522] Buffer I/O error on device sdb, logical block 5
[ 10.201582] Buffer I/O error on device sdb, logical block 6
[ 10.201717] sd 7:0:0:0: [sdb] Unhandled error code
[ 10.201720] sd 7:0:0:0: [sdb] Result: hostbyte=DID_ERROR driverbyte=DRIVER_OK
[ 10.201723] sd 7:0:0:0: [sdb] CDB: Read(10): 28 00 00 00 00 00 00 00 08 00
[ 10.201731] end_request: I/O error, dev sdb, sector 0
[ 10.201885] sd 7:0:0:0: [sdb] Unhandled error code
[ 10.201888] sd 7:0:0:0: [sdb] Result: hostbyte=DID_ERROR driverbyte=DRIVER_OK
[ 10.201891] sd 7:0:0:0: [sdb] CDB: Read(10): 28 00 00 00 00 00 00 00 08 00
[ 10.201899] end_request: I/O error, dev sdb, sector 0
[ 13.693186] sd 9:0:0:0: [sdb] 102401 512-byte logical blocks: (52.4 MB/50.0 MiB)
[ 13.694567] sd 9:0:0:0: [sdb] Write Protect is off
[ 13.694571] sd 9:0:0:0: [sdb] Mode Sense: 0b 00 00 08
[ 13.696221] sd 9:0:0:0: [sdb] No Caching mode page present
[ 13.696224] sd 9:0:0:0: [sdb] Assuming drive cache: write through
[ 13.702203] sd 9:0:0:0: [sdb] No Caching mode page present
[ 13.702206] sd 9:0:0:0: [sdb] Assuming drive cache: write through
[ 13.713217] sdb:
[ 13.722171] sd 9:0:0:0: [sdb] No Caching mode page present
[ 13.722175] sd 9:0:0:0: [sdb] Assuming drive cache: write through
[ 13.722178] sd 9:0:0:0: [sdb] Attached SCSI removable disk

sudo lsusb -v -d 16d8:

Bus 001 Device 010: ID 16d8:680a CMOTECH Co., Ltd.
Device Descriptor:
  bLength 18
  bDescriptorType 1
  bcdUSB 1.10
  bDeviceClass 2 Communications
  bDeviceSubClass 0
  bDeviceProtocol 0
  bMaxPacketSize0 64
  idVendor 0x16d8 CMOTECH Co., Ltd.
  idProduct 0x680a
  bcdDevice 0.00
  iManufacturer 1 CMOTECH CO., LTD.
  iProduct 2 CMOTECH CDMA Technologies
  iSerial 0
  bNumConfigurations 1
  Configuration Descriptor:
    bLength 9
    bDescriptorType 2
    wTotalLength 113
    bNumInterfaces 6
    bConfigurationValue 1
    iConfiguration 0
    bmAttributes 0x80
      (Bus Powered)
    MaxPower 500mA
    Interface Descriptor:
      bLength 9
      bDescriptorType 4
      bInterfaceNumber 0
      bAlternateSetting 0
      bNumEndpoints 1
      bInterfaceClass 2 Communications
      bInterfaceSubClass 2 Abstract (modem)
      bInterfaceProtocol 1 AT-commands (v.25ter)
      iInterface 0
      CDC Header:
        bcdCDC 1.09
      CDC Call Management:
        bmCapabilities 0x03
          call management
          use DataInterface
        bDataInterface 1
      CDC ACM:
        bmCapabilities 0x0f
          connection notifications
          sends break
          line coding and serial state
          get/set/clear comm features
      CDC Union:
        bMasterInterface 0
        bSlaveInterface 1
      Endpoint Descriptor:
        bLength 7
        bDescriptorType 5
        bEndpointAddress 0x81 EP 1 IN
        bmAttributes 3
          Transfer Type Interrupt
          Synch Type None
          Usage Type Data
        wMaxPacketSize 0x0010 1x 16 bytes
        bInterval 32
    Interface Descriptor:
      bLength 9
      bDescriptorType 4
      bInterfaceNumber 1
      bAlternateSetting 0
      bNumEndpoints 2
      bInterfaceClass 10 CDC Data
      bInterfaceSubClass 0 Unused
      bInterfaceProtocol 0
      iInterface 3 Data Interface
      Endpoint Descriptor:
        bLength 7
        bDescriptorType 5
        bEndpointAddress 0x82 EP 2 IN
        bmAttributes 2
          Transfer Type Bulk
          Synch Type None
          Usage Type Data
        wMaxPacketSize 0x0040 1x 64 bytes
        bInterval 0
      Endpoint Descriptor:
        bLength 7
        bDescriptorType 5
        bEndpointAddress 0x02 EP 2 OUT
        bmAttributes 2
          Transfer Type Bulk
          Synch Type None
          Usage Type Data
        wMaxPacketSize 0x0040 1x 64 bytes
        bInterval 0
    Interface Descriptor:
      bLength 9
      bDescriptorType 4
      bInterfaceNumber 5
      bAlternateSetting 0
      bNumEndpoints 2
      bInterfaceClass 8 Mass Storage
      bInterfaceSubClass 6 SCSI
      bInterfaceProtocol 80 Bulk (Zip)
      iInterface 0
      Endpoint Descriptor:
        bLength 7
        bDescriptorType 5
        bEndpointAddress 0x86 EP 6 IN
        bmAttributes 2
          Transfer Type Bulk
          Synch Type None
          Usage Type Data
        wMaxPacketSize 0x0040 1x 64 bytes
        bInterval 0
      Endpoint Descriptor:
        bLength 7
        bDescriptorType 5
        bEndpointAddress 0x07 EP 7 OUT
        bmAttributes 2
          Transfer Type Bulk
          Synch Type None
          Usage Type Data
        wMaxPacketSize 0x0040 1x 64 bytes
        bInterval 0
    Interface Descriptor:
      bLength 9
      bDescriptorType 4
      bInterfaceNumber 6
      bAlternateSetting 0
      bNumEndpoints 2
      bInterfaceClass 8 Mass Storage
      bInterfaceSubClass 6 SCSI
      bInterfaceProtocol 80 Bulk (Zip)
      iInterface 0
      Endpoint Descriptor:
        bLength 7
        bDescriptorType 5
        bEndpointAddress 0x87 EP 7 IN
        bmAttributes 2
          Transfer Type Bulk
          Synch Type None
          Usage Type Data
        wMaxPacketSize 0x0040 1x 64 bytes
        bInterval 0
      Endpoint Descriptor:
        bLength 7
        bDescriptorType 5
        bEndpointAddress 0x08 EP 8 OUT
        bmAttributes 2
          Transfer Type Bulk
          Synch Type None
          Usage Type Data
        wMaxPacketSize 0x0040 1x 64 bytes
        bInterval 0
Device Status: 0x0000
  (Bus Powered)

Revision history for this message
Andres Attemann (attemann) said :
#2

One more piece of the puzzle. ignore_device is no more:
https://lists.ubuntu.com/archives/lucid-changes/2009-December/001116.html
http://git.kernel.org/?p=linux/hotplug/udev.git;a=commit;h=cdae488a3fbca5a61b3f8ea0651730cfa2da9cb0

Question remains. How to tell kernel to ignore specific (USB) device.
Blacklisting modules for entire USB subsystem is not an option as other regular flash disks must be usable.

Revision history for this message
Andres Attemann (attemann) said :
#3

Looks like it's resolved with quirks parameters for usb-storage:

andres@aa-dv6:/etc/modprobe.d$ cat blacklist-cmotech-cnu680-storage.conf
#This does inhibit modeswitch somehow
#options usb-storage quirks=16d8:6803:i,16d8:680a:i
# So ignore storage after modeswitch only
options usb-storage quirks=16d8:680a:i
andres@aa-dv6:/etc/modprobe.d$