# usb_storage taking ownership of Epson printer

## CanuteTheGreat

Short version: I have an Epson Stylus Photo R380 that works pretty decently with CUPS 2.4.8 as long as usb_storage is NOT loaded. I would like to make it so that usb_storage does NOT attempt to take ownership of the device but I don't want to blacklist usb_storage because I have other usb devices.

Longer version: When the printer is plugged in/turned on, usb_storage sees the card reader ability of the printer (probably because this functionality has a lower device number) and takes control of it leaving the printer unusable by CUPS. If I remove usb_storage module, and chgrp the proc device to "lp" printing works again.

Here is the relevant output from lsusb:

```

...

Bus 001 Device 005: ID 04b8:082c Seiko Epson Corp. Storage Device

Device Descriptor:

  bLength                18

  bDescriptorType         1

  bcdUSB               2.00

  bDeviceClass            0 (Defined at Interface level)

  bDeviceSubClass         0 

  bDeviceProtocol         0 

  bMaxPacketSize0        64

  idVendor           0x04b8 Seiko Epson Corp.

  idProduct          0x082c Storage Device

  bcdDevice            1.00

  iManufacturer           1 EPSON

  iProduct                2 USB2.0 MFP(Hi-Speed)

  iSerial                 3 L34P30611102020060

  bNumConfigurations      1

  Configuration Descriptor:

    bLength                 9

    bDescriptorType         2

    wTotalLength           55

    bNumInterfaces          2

    bConfigurationValue     1

    iConfiguration          4 USB2.0 MFP(Hi-Speed)

    bmAttributes         0xc0

      Self Powered

    MaxPower                2mA

    Interface Descriptor:

      bLength                 9

      bDescriptorType         4

      bInterfaceNumber        0

      bAlternateSetting       0

      bNumEndpoints           2

      bInterfaceClass         8 Mass Storage

      bInterfaceSubClass      6 SCSI

      bInterfaceProtocol     80 Bulk (Zip)

      iInterface              7 USB2.0 Mass Storage

      Endpoint Descriptor:

        bLength                 7

        bDescriptorType         5

        bEndpointAddress     0x07  EP 7 OUT

        bmAttributes            2

          Transfer Type            Bulk

          Synch Type               None

          Usage Type               Data

        wMaxPacketSize     0x0200  1x 512 bytes

        bInterval               0

      Endpoint Descriptor:

        bLength                 7

        bDescriptorType         5

        bEndpointAddress     0x88  EP 8 IN

        bmAttributes            2

          Transfer Type            Bulk

          Synch Type               None

          Usage Type               Data

        wMaxPacketSize     0x0200  1x 512 bytes

        bInterval               0

    Interface Descriptor:

      bLength                 9

      bDescriptorType         4

      bInterfaceNumber        1

      bAlternateSetting       0

      bNumEndpoints           2

      bInterfaceClass         7 Printer

      bInterfaceSubClass      1 Printer

      bInterfaceProtocol      2 Bidirectional

      iInterface              6 USB2.0 Printer

      Endpoint Descriptor:

        bLength                 7

        bDescriptorType         5

        bEndpointAddress     0x04  EP 4 OUT

        bmAttributes            2

          Transfer Type            Bulk

          Synch Type               None

          Usage Type               Data

        wMaxPacketSize     0x0200  1x 512 bytes

        bInterval               0

      Endpoint Descriptor:

        bLength                 7

        bDescriptorType         5

        bEndpointAddress     0x85  EP 5 IN

        bmAttributes            2

          Transfer Type            Bulk

          Synch Type               None

          Usage Type               Data

        wMaxPacketSize     0x0200  1x 512 bytes

        bInterval               0

Device Qualifier (for other device speed):

  bLength                10

  bDescriptorType         6

  bcdUSB               2.00

  bDeviceClass            0 (Defined at Interface level)

  bDeviceSubClass         0 

  bDeviceProtocol         0 

  bMaxPacketSize0        64

  bNumConfigurations      1

Device Status:     0x0001

  Self Powered

...

```

When usb_storage takes ownership and I try to print to the printer, the below line is repeated every few seconds on the system logger:

```

...

Dec 22 23:33:29 mustang kernel: usb 1-5: usbfs: interface 0 claimed by usb-storage while 'usb' sets config #1

...

```

Honestly I could care less about the card reader ability of the printer (I have other devices to fulfull that need) and just want the printer to be a printer. 

I'm guessing I need to make a new udev rule but I do not know where to start...

Thanks!

----------

## genterminl

First try  to identify the rule that is currently triggering for the printer.  You can grep "04b8" and "082c" in all the files in /etc/udev/rules.d.  (Those are the vendor and device codes from your lsusb output.)  You might be able to comment out the rule that grabs it as a storage device, or perhaps change what it does with it.

----------

## CanuteTheGreat

There are some libsane rules in 70-libsane.rules that include 04b8 but no 082c:

```

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0101", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0102", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0103", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0104", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0105", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0106", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0107", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0108", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0109", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="010a", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="010b", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="010c", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="010d", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="010e", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="010f", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0110", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0112", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0114", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0116", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0118", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0119", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="011a", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="011b", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="011c", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="011d", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="011e", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="011f", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0120", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0121", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0122", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0126", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0128", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0129", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="012a", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="012b", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="012c", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="012d", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="012e", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="012f", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0801", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0802", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0805", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0806", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0807", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0808", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="080a", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="080c", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="080d", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="080e", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="080f", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0810", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0811", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0813", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0814", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0815", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0817", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0818", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0819", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="081a", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="081c", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="081d", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="081f", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0820", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0821", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0827", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0828", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0829", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="082a", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="082b", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="082e", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="082f", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0830", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0831", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0833", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0835", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0836", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0837", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0838", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0839", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="083a", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="083c", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="083f", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

```

I'm wondering if I created a new rule called 99-custom.rules that set the group to "lp" if that would fix it? Not sure what the syntax is, but looking at the other files I think it should look something like:

```

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="082c", MODE="0664", GROUP="lp"

```

Not sure what else I would need in that file? (sorry I'm not that familiar with udev these days)

----------

## genterminl

Have you also looked for rules in other files in that directory?  As I remember, your problem is that the device is recognized as usb-storage, not as printer.

If there are no appropriate rules in other files, I might  just try duplicating one of the rules in 70-libsane, changing the product-id to your device, and changing the group from scanner to lp.

----------

## CanuteTheGreat

 *genterminl wrote:*   

> Have you also looked for rules in other files in that directory?  As I remember, your problem is that the device is recognized as usb-storage, not as printer.
> 
> 

 

Yes I did. There are no other files that contain either device code.

 *genterminl wrote:*   

> 
> 
> If there are no appropriate rules in other files, I might  just try duplicating one of the rules in 70-libsane, changing the product-id to your device, and changing the group from scanner to lp.

 

I tried creating a new file called 99-custom.rules with the following contents:

```

ACTION!="add", GOTO="epson_rules_end"

SUBSYSTEMS=="scsi", ATTRS{type}=="3|6", MODE="660", GROUP="lp"

ENV{DEVTYPE}=="usb_device", GOTO="epson_create_usb_dev"

SUBSYSTEM=="usb_device", GOTO="epson_rules_begin"

SUBSYSTEM!="usb|usb_device", GOTO="epson_rules_end"

SUBSYSTEM=="usb", ENV{DEVTYPE}!="usb_device" ,GOTO="epson_rules_end"

# Kernel >= 2.6.22 jumps here

LABEL="epson_create_usb_dev"

# Kernel < 2.6.22 jumps here

LABEL="epson_rules_begin"

ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="082c", MODE="0664", GROUP="lp"

LABEL="epson_rules_end"

```

However, the printer still gets picked up as a usb storage device on reboot and on insertion of any usb devices after the system is up and running. This makes me wonder if it's some sort of automount in gnome, hal, dbus, etc. ? I have "-automount" in /etc/make.conf but honestly gnome (or something) does automatically mount usb devices when they are plugged in. I don't see anything under system->preferences or system->administration that indicates any sort of automount feature, but I'm out of ideas...

----------

## augury

Have you added "probe-all-luns" to the scsi section of the kernel config?

----------

## genterminl

It might also help if you post the output of dmesg and /var/log/messages at the time the device is plugged in.

----------

## CanuteTheGreat

 *augury wrote:*   

> Have you added "probe-all-luns" to the scsi section of the kernel config?

 

Negative:

```

# CONFIG_SCSI_MULTI_LUN is not set

```

----------

## CanuteTheGreat

 *genterminl wrote:*   

> It might also help if you post the output of dmesg and /var/log/messages at the time the device is plugged in.

 

Sure!

```

Jan  3 12:12:30 mustang kernel: usb 1-5: new high speed USB device using ehci_hcd and address 7

Jan  3 12:12:30 mustang kernel: Initializing USB Mass Storage driver...

Jan  3 12:12:30 mustang kernel: scsi15 : usb-storage 1-5:1.0

Jan  3 12:12:30 mustang kernel: usbcore: registered new interface driver usb-storage

Jan  3 12:12:30 mustang kernel: USB Mass Storage support registered.

Jan  3 12:12:31 mustang kernel: scsi 15:0:0:0: Direct-Access     EPSON    Stylus Storage   1.00 PQ: 0 ANSI: 2

Jan  3 12:12:31 mustang kernel: sd 15:0:0:0: Attached scsi generic sg6 type 0

Jan  3 12:12:31 mustang kernel: sd 15:0:0:0: [sdf] Attached SCSI removable disk

```

----------

## augury

You should probe all of the luns on your Epson.

----------

## genterminl

sys-apps/rescan-scsi-bus is useful for this purpose.  I haven't needed to use it in years, so I forget whether it actually requires the 

CONFIG_SCSI_MULTI_LUN=y be set in your kernel config.  It probably does, but it allows checking for LUNS that don't show up until you power the device, without requiring a reboot.

----------

## CanuteTheGreat

 *genterminl wrote:*   

> sys-apps/rescan-scsi-bus is useful for this purpose.  I haven't needed to use it in years, so I forget whether it actually requires the 
> 
> CONFIG_SCSI_MULTI_LUN=y be set in your kernel config.  It probably does, but it allows checking for LUNS that don't show up until you power the device, without requiring a reboot.

 

rescan-scsi-bus is already installed. I changed my .config, recompiled, rebooted, but no change. usb_storage still grabs the printer...

----------

## genterminl

It's hard to imagine that the printer primarily responds as a storage device and not (also or instead) as a printer and/or scanner.  I think we're all missing something, but I  can't tell what.  I would still consider adding a  modified line to the 70-xxx rules file, rather than adding a new file.  I would also try to track down what udev rule is actually adding the epson as a storage device.  I don't know what kind of -debug options there are for udev, but I think that's what I'd track down next, other than looking for other folks with the same device to see how they are dealing with it.

----------

## augury

Ordinarily if you have a usb drive with two physical addresses (different flash readers hardwares-in-one)  the kernel will only pick up one of them.  But the luns thing usually does the trick.

You would think they would put a hub or something in these things.

What is your lsusb and lshw?  Can you see the various devices at all?

It doesn't make sense to me that you would be completely unable to see the printer with the other device activated.  There should be some way to address the printer as opposed to the flash drive.  Perhaps manually.

----------

## Fitzcarraldo

I wonder if you could use a quirk to tell the usb-storage driver to ignore the printer? I had to do something similar a while back, to stop the usbhid driver thinking a DVB-T stick was a keyboard.

If the usb-storage driver is a kernel module (CONFIG_USB_STORAGE=m in the kernel config), you could you try something like:

```
options usb-storage quirks=0x04b8:0x082c:i
```

in /etc/modprobe.d/usb-storage.conf (I think that would be the correct file name and path to use), or whatever the manufacturer and model codes are. I had to prefix the hex with "0x" even though many examples on the Web don't show this. 

However, if usb-storage is not a module but is built into the kernel (CONFIG_USB_STORAGE=y in the kernel config), the way to tell it to ignore the specific device would be to pass the quirk to the usb-storage driver as a boot parameter, by editing /boot/grub/grub.conf (GRUB Legacy) or /boot/grub/grub.cfg (GRUB 2 [well, you should really do it by editing /etc/default/grub and running grub-mkconfig, but it would work by editing grub.cfg directly]) and adding the following to the end of the kernel boot line:

```
usb-storage.quirks=0x04b8:0x082c:i
```

I had a cursory search for available quirks for usb-storage, and spotted [usb-storage] [PATCH] usb-storage: add "quirks=" module parameter, so it seems a possibility, but my apologies if I'm wide of the mark.

----------

