Whilst searching the Web I have found many other people experiencing this problem, which I believe happens as a consequence of the way Linux is designed. Basically, if you have a multi-function peripheral that you connect to your computer via USB, the chances are that either scanning or printing will not work. The Web is littered with blog posts, forum threads, mailing list posts and bug reports regarding this phenomenon. There are numerous suggested fixes, usually entailing the addition or modification of udev rules. Sometimes the suggested fixes work; often they don’t. Linux can be a major hassle where peripherals are concerned.
I have a Canon Pixma MP560 MFP (multi-function printer/peripheral), which is a printer, scanner and copier. It also has memory card slots and a USB pen drive socket, to be able to store images directly from the scanner without the need to connect a computer. The MP560 provides two alternative means of connection to a computer: USB and Wi-Fi. I normally connect it via USB to my Clevo W230SS laptop running Gentoo Linux (amd64), but I can also connect it to the laptop via my home Wi-Fi network. Either connection method allows me to print, but I can scan only via the wireless connection.
The dmesg
command displays the following messages after I plug a USB cable from the MP560 into my laptop:
usb 1-1.2.2: new high-speed USB device number 8 using ehci-pci
usb 1-1.2.2: New USB device found, idVendor=04a9, idProduct=173e
usb 1-1.2.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 1-1.2.2: Product: MP560 series
usb 1-1.2.2: Manufacturer: Canon
usb 1-1.2.2: SerialNumber: 1653C4
usb-storage 1-1.2.2:1.2: USB Mass Storage device detected
scsi host6: usb-storage 1-1.2.2:1.2
scsi 6:0:0:0: Direct-Access Canon MP560 series 0104 PQ: 0 ANSI: 2
sd 6:0:0:0: Attached scsi generic sg1 type 0
sd 6:0:0:0: [sdb] Attached SCSI removable disk
Notice that the device also has some internal storage.
The lsusb
command shows the device:
$ lsusb
Bus 002 Device 002: ID 8087:8000 Intel Corp.
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 006: ID 5986:055c Acer, Inc
Bus 001 Device 004: ID 8087:07dc Intel Corp.
Bus 001 Device 007: ID 0603:00f2 Novatek Microelectronics Corp. Keyboard (Labtec Ultra Flat Keyboard)
Bus 001 Device 009: ID 04a9:173e Canon, Inc. MP560
Bus 001 Device 005: ID 045e:00d1 Microsoft Corp. Optical Mouse with Tilt Wheel
Bus 001 Device 003: ID 05e3:0606 Genesys Logic, Inc. USB 2.0 Hub / D-Link DUB-H4 USB 2.0 Hub
Bus 001 Device 002: ID 8087:8008 Intel Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
My Linux user account is in the lp
and scanner
groups:
$ groups
disk lp wheel floppy uucp cron audio cdrom video games cdrw usb users plugdev crontab wireshark vboxusers scanner fitzcarraldo
The device is in the lp
group and I can print without any trouble:
$ ls -la /dev/bus/usb/001/009
crw-rw-r--+ 1 root lp 189, 8 Jun 19 02:55 /dev/bus/usb/001/009
The usblp
driver, a common cause of problems with USB printers, does not exist because I purposely did not set CONFIG_USB_PRINTER
when I built the kernel, specifically to avoid such problems:
$ grep CONFIG_USB_PRINTER /usr/src/linux/.config
# CONFIG_USB_PRINTER is not set
so, obviously, the usblp
driver is neither built into the kernel nor compiled as a module:
$ lsmod | grep usb
btusb 22292 0
bluetooth 281605 27 bnep,hidp,btusb,rfcomm
I have the latest stable versions of the udev-related packages installed (as you can see below, I use eudev instead of udev):
$ eix -I udev
[I] dev-python/pyudev
Available versions: 0.16.1-r1 {pygobject pyqt4 pyside test PYTHON_TARGETS="python2_7 python3_3 python3_4"}
Installed versions: 0.16.1-r1(03:32:17 18/04/15)(pyqt4 -pygobject -pyside -test PYTHON_TARGETS="python2_7 python3_3 -python3_4")
Homepage: http://pyudev.readthedocs.org https://github.com/pyudev/pyudev
Description: Python binding to libudev
[I] sys-fs/eudev
Available versions: *1.3 *1.5.3-r1 1.9-r2 1.10-r2 ~2.1.1 ~3.0 3.1.2 ~3.1.2-r10 **9999 {doc gudev (+)hwdb introspection (+)keymap (+)kmod +modutils +openrc +rule-generator selinux static-libs test ABI_MIPS="n32 n64 o32" ABI_PPC="32 64" ABI_S390="32 64" ABI_X86="32 64 x32"}
Installed versions: 3.1.2(19:44:12 16/07/15)(gudev hwdb introspection kmod -doc -selinux -static-libs -test ABI_MIPS="-n32 -n64 -o32" ABI_PPC="-32 -64" ABI_S390="-32 -64" ABI_X86="32 64 -x32")
Homepage: https://github.com/gentoo/eudev
Description: Linux dynamic and persistent device naming support (aka userspace devfs)
[I] sys-fs/udev-init-scripts
Available versions: 27^t [M]~29^t ~30^t **9999^t
Installed versions: 27^t(05:29:06 09/04/15)
Homepage: http://www.gentoo.org
Description: udev startup scripts for openrc
[I] virtual/libgudev
Available versions: 215-r1(0/0) 215-r2(0/0) 215-r3(0/0) ~230(0/0) {introspection static-libs systemd ABI_MIPS="n32 n64 o32" ABI_PPC="32 64" ABI_S390="32 64" ABI_X86="32 64 x32"}
Installed versions: 215-r3(10:18:16 11/06/15)(introspection -static-libs -systemd ABI_MIPS="-n32 -n64 -o32" ABI_PPC="-32 -64" ABI_S390="-32 -64" ABI_X86="64 -32 -x32")
Description: Virtual for libgudev providers
[I] virtual/libudev
Available versions: 215-r1(0/1) {static-libs systemd ABI_MIPS="n32 n64 o32" ABI_PPC="32 64" ABI_S390="32 64" ABI_X86="32 64 x32"}
Installed versions: 215-r1(17:51:42 18/04/15)(-static-libs -systemd ABI_MIPS="-n32 -n64 -o32" ABI_PPC="-32 -64" ABI_S390="-32 -64" ABI_X86="32 64 -x32")
Description: Virtual for libudev providers
[I] virtual/udev
Available versions: 215 ~217 {systemd}
Installed versions: 215(05:28:55 09/04/15)(-systemd)
Description: Virtual to select between different udev daemon providers
Found 6 matches.
I have the latest stable SANE-related packages installed:
$ eix -I sane
[I] dev-perl/Sane
Available versions: (~)0.50.0-r1 {test}
Installed versions: 0.50.0-r1(17:39:10 23/06/15)(-test)
Homepage: http://search.cpan.org/dist/Sane/
Description: The Sane module allows you to access SANE-compatible scanners in a Perl
[I] kde-apps/ksaneplugin
Available versions: (4) 4.14.3(4/4.14)
{aqua debug}
Installed versions: 4.14.3(4)(14:13:01 17/04/15)(-aqua -debug)
Homepage: http://www.kde.org/
Description: SANE Plugin for KDE
[I] kde-apps/libksane
Available versions: (4) 4.14.3(4/4.14)
{aqua debug}
Installed versions: 4.14.3(4)(13:55:44 17/04/15)(-aqua -debug)
Homepage: http://www.kde.org/
Description: SANE Library interface for KDE
[I] media-gfx/sane-backends
Available versions: 1.0.24-r5 ~1.0.25_pre20150628 {avahi doc gphoto2 ipv6 snmp systemd threads usb v4l xinetd ABI_MIPS="n32 n64 o32" ABI_PPC="32 64" ABI_S390="32 64" ABI_X86="32 64 x32" SANE_BACKENDS="+abaton +agfafocus +apple +artec +artec_eplus48u +as6e +avision +bh +canon +canon630u +canon_dr -canon_pp +cardscan +coolscan +coolscan2 +coolscan3 +dc210 +dc240 +dc25 +dell1600n_net +dmc +epjitsu +epson +epson2 +fujitsu +genesys +gt68xx +hp +hp3500 +hp3900 +hp4200 +hp5400 +hp5590 +hpljm1005 -hpsj5s +hs2p +ibm +kodak +kodakaio +kvs1025 +kvs20xx kvs40xx +leo +lexmark +ma1509 +magicolor +matsushita +microtek +microtek2 +mustek -mustek_pp +mustek_usb mustek_usb2 +nec +net +niash +p5 +pie +pixma +plustek +plustek_pp -pnm +qcam +ricoh +rts8891 +s9036 +sceptre +sharp +sm3600 +sm3840 +snapscan +sp15c +st400 +stv680 +tamarack +teco1 +teco2 +teco3 +test +u12 +umax +umax1220u +umax_pp +xerox_mfp"}
Installed versions: 1.0.24-r5(17:55:11 18/04/15)(avahi gphoto2 ipv6 usb v4l -doc -snmp -systemd -threads -xinetd ABI_MIPS="-n32 -n64 -o32" ABI_PPC="-32 -64" ABI_S390="-32 -64" ABI_X86="32 64 -x32" SANE_BACKENDS="abaton agfafocus apple artec artec_eplus48u as6e avision bh canon canon630u canon_dr cardscan coolscan coolscan2 coolscan3 dc210 dc240 dc25 dell1600n_net dmc epjitsu epson epson2 fujitsu genesys gt68xx hp hp3500 hp3900 hp4200 hp5400 hp5590 hpljm1005 hs2p ibm kodak kodakaio kvs1025 kvs20xx leo lexmark ma1509 magicolor matsushita microtek microtek2 mustek mustek_usb nec net niash p5 pie pixma plustek plustek_pp qcam ricoh rts8891 s9036 sceptre sharp sm3600 sm3840 snapscan sp15c st400 stv680 tamarack teco1 teco2 teco3 test u12 umax umax1220u umax_pp xerox_mfp -canon_pp -hpsj5s -kvs40xx -mustek_pp -mustek_usb2 -pnm")
Homepage: http://www.sane-project.org/
Description: Scanner Access Now Easy - Backends
[I] media-gfx/sane-frontends
Available versions: 1.0.14 {gimp}
Installed versions: 1.0.14(19:47:50 18/06/15)(gimp)
Homepage: http://www.sane-project.org
Description: Scanner Access Now Easy
[I] media-gfx/xsane
Available versions: 0.999-r1 {gimp jpeg lcms nls ocr png tiff}
Installed versions: 0.999-r1(12:03:12 19/04/15)(gimp jpeg lcms nls png tiff -ocr)
Homepage: http://www.xsane.org/
Description: graphical scanning frontend
Found 6 matches.
The following SANE backends were installed when I installed SANE:
$ ls -F1 /etc/sane.d/ | columns -c 3 -w 20
abaton.conf agfafocus.conf apple.conf
artec.conf artec_eplus48u.conf avision.conf
bh.conf canon.conf canon630u.conf
canon_dr.conf cardscan.conf coolscan.conf
coolscan2.conf coolscan3.conf dc210.conf
dc240.conf dc25.conf dell1600n_net.conf
dll.conf dll.d/ dmc.conf
epjitsu.conf epson.conf epson2.conf
fujitsu.conf genesys.conf gphoto2.conf
gt68xx.conf hp.conf hp3900.conf
hp4200.conf hp5400.conf hs2p.conf
ibm.conf kodak.conf kodakaio.conf
leo.conf lexmark.conf ma1509.conf
magicolor.conf matsushita.conf microtek.conf
microtek2.conf mustek.conf mustek_usb.conf
nec.conf net.conf p5.conf
pie.conf pixma.conf plustek.conf
plustek_pp.conf qcam.conf ricoh.conf
rts8891.conf s9036.conf saned.conf
sceptre.conf sharp.conf sm3840.conf
smfp.conf snapscan.conf sp15c.conf
st400.conf stv680.conf tamarack.conf
teco1.conf teco2.conf teco3.conf
test.conf u12.conf umax.conf
umax1220u.conf umax_pp.conf v4l.conf
xerox_mfp.conf
I checked all the SANE backend configuration files, and none of them mention the MP560 (I was not expecting them to mention it, as, according to man sane-pixma
, the pixma
backend detects Canon PIXMA USB devices automatically):
$ grep -rnwi /etc/sane.d/ -e "173e"
$
The SANE file dll.conf
does list the pixma
backend configuration file which is only for declaring networked Canon PIXMA devices, as the pixma
backend detects Canon USB devices automatically):
$ grep pixma /etc/sane.d/dll.conf
pixma
$ cat /etc/sane.d/pixma.conf
# pixma.conf configuration for the sane pixma backend
#
# define URI's of scanners (one per line)
# This is only used for network scanners.
# normally scanners will be detected by sending a broadcast
# if this does not work under your OS, or if the scanners
# are on a different subnet, configure your scanners URI here
#
# method must be bjnp
# port number can normally be left out, port 8612 is used as default
# Example:
# bjnp://myscanner.my.domain:8612
# bjnp://printer-1.pheasant.org
#
I don’t think it is even used these days, but the file /etc/hotplug/usb/libsane.usermap
already includes the device:
# Canon PIXMA MP560
libusbscanner 0x0003 0x04a9 0x173e 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000
The file /lib64/udev/rules.d/41-libsane.rules already includes the device:
# Canon PIXMA MP560
ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="173e", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"
However, scanning from Linux via USB is a troubled affair. Very occasionally the scanner application (XSane, Simple Scan, gscan2pdf, or whatever) will launch and the scanner works, but usually the scanner application just hangs and the dmesg
command shows one or more error messages such as the following:
usb 1-1.2.2: usbfs: interface 2 claimed by usb-storage while 'xsane' sets config #1
usb 1-1.2.2: usbfs: interface 2 claimed by usb-storage while 'gscan2pdf' sets config #1
I have USB mass storage support enabled in the kernel so that my laptop can access external USB mass storage devices:
$ grep CONFIG_USB_STORAGE= /usr/src/linux/.config
CONFIG_USB_STORAGE=y
As the three interfaces (printer, scanner and internal storage) are all accessed as a single USB device (/dev/bus/usb/001/009
, or whatever), there appears to be a conflict between the kernel claiming the MFP’s internal mass storage and SANE trying to access the scanner. I do not want to disable the kernel’s USB mass storage support (not even by rebuilding the kernel with CONFIG_USB_STORAGE=m
and temporarily unloading manually the usb-storage
module, as some people suggest), as I would not be able to access my external USB mass storage devices.
The scanimage
and sane-find-scanner
utilities detect the scanner correctly via USB:
$ scanimage -L
device `v4l:/dev/video0' is a Noname BisonCam, NB Pro virtual device
device `pixma:04A9173E_1653C4' is a CANON Canon PIXMA MP560 multi-function peripheral
(The BisonCam is the Webcam built into my laptop.)
$ sane-find-scanner
# sane-find-scanner will now attempt to detect your scanner. If the
# result is different from what you expected, first make sure your
# scanner is powered up and properly connected to your computer.
# No SCSI scanners found. If you expected something different, make sure that
# you have loaded a kernel SCSI driver for your SCSI adapter.
found USB scanner (vendor=0x04a9 [Canon], product=0x173e [MP560 series]) at libusb:001:009
# Your USB scanner was (probably) detected. It may or may not be supported by
# SANE. Try scanimage -L and read the backend's manpage.
# Not checking for parallel port scanners.
# Most Scanners connected to the parallel port or other proprietary ports
# can't be detected by this program.
# You may want to run this program as root to find all devices. Once you
# found the scanner devices, be sure to adjust access permissions as
# necessary.
The scanimage
test commands do not indicate any problem:
$ scanimage -d test -T
scanimage: scanning image of size 157x196 pixels at 8 bits/pixel
scanimage: acquiring gray frame, 8 bits/sample
scanimage: reading one scanline, 157 bytes... PASS
scanimage: reading one byte... PASS
scanimage: stepped read, 2 bytes... PASS
scanimage: stepped read, 4 bytes... PASS
scanimage: stepped read, 8 bytes... PASS
scanimage: stepped read, 16 bytes... PASS
scanimage: stepped read, 32 bytes... PASS
scanimage: stepped read, 64 bytes... PASS
scanimage: stepped read, 128 bytes... PASS
scanimage: stepped read, 256 bytes... PASS
scanimage: stepped read, 255 bytes... PASS
scanimage: stepped read, 127 bytes... PASS
scanimage: stepped read, 63 bytes... PASS
scanimage: stepped read, 31 bytes... PASS
scanimage: stepped read, 15 bytes... PASS
scanimage: stepped read, 7 bytes... PASS
scanimage: stepped read, 3 bytes... PASS
$ scanimage -d pixma -T
scanimage: scanning image of size 638x877 pixels at 24 bits/pixel
scanimage: acquiring RGB frame, 8 bits/sample
scanimage: reading one scanline, 1914 bytes... PASS
scanimage: reading one byte... PASS
scanimage: stepped read, 2 bytes... PASS
scanimage: stepped read, 4 bytes... PASS
scanimage: stepped read, 8 bytes... PASS
scanimage: stepped read, 16 bytes... PASS
scanimage: stepped read, 32 bytes... PASS
scanimage: stepped read, 64 bytes... PASS
scanimage: stepped read, 128 bytes... PASS
scanimage: stepped read, 256 bytes... PASS
scanimage: stepped read, 512 bytes... PASS
scanimage: stepped read, 1024 bytes... PASS
scanimage: stepped read, 2048 bytes... PASS
scanimage: stepped read, 2047 bytes... PASS
scanimage: stepped read, 1023 bytes... PASS
scanimage: stepped read, 511 bytes... PASS
scanimage: stepped read, 255 bytes... PASS
scanimage: stepped read, 127 bytes... PASS
scanimage: stepped read, 63 bytes... PASS
scanimage: stepped read, 31 bytes... PASS
scanimage: stepped read, 15 bytes... PASS
scanimage: stepped read, 7 bytes... PASS
scanimage: stepped read, 3 bytes... PASS
As mentioned earlier, the udev/eudev rules file appears to contain a valid rule for the scanner:
# Canon PIXMA MP560
ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="173e", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"
Notice the rule assigns the device’s group to be ‘scanner
‘, not ‘lp
‘, although changing the group assignment to ‘lp
‘ in the rule makes no discernable difference to the scanning problem in my case. As the device’s group
is actually ‘lp
‘, I assume another rule overrides this rule, but I have no idea which rule it is and in which rules file it occurs.
Occasionally I am lucky and scanning does work, but, more often than not, scanner applications cannot access the scanner and just hang.
A work-around if the peripheral also has a network interface
I configured my home network router always to use the IP address 192.168.1.78
for the MP560 and I added the following line to the file /etc/sane.d/pixma.conf
in order to be able to scan via Wi-Fi instead of USB (I have the package cups-bjnp
installed for printing purposes, but I am not sure if that package is also needed by SANE in this case):
bjnp://192.168.1.78
With the above line added to /etc/sane.d/pixma.conf
the scanimage utility detects the scanner correctly via both the Wi-Fi connection and the USB interface:
$ scanimage -L
device `v4l:/dev/video0' is a Noname BisonCam, NB Pro virtual device
device `pixma:MP560_192.168.1.78' is a CANON Canon PIXMA MP560 multi-function peripheral
device `pixma:04A9173E_1653C4' is a CANON Canon PIXMA MP560 multi-function peripheral
So, as I usually cannot get scanning to work via USB, I can scan via Wi-Fi instead. It’s a work-around, not a solution, but at least by doing that I can scan reliably as well as print. Of course you can’t use such a work-around if you have a model of MFP that only provides a USB connection.
Failed experiments
Experiment 1
I also tried unbinding the usb-storage driver from the usb device:
# ls /sys/bus/usb/drivers
btusb hub usb usb-storage usbfs usbhid uvcvideo
# ls /sys/bus/usb/drivers/btusb/
1-1.3:1.0 1-1.3:1.1 bind module new_id remove_id uevent unbind
# ls /sys/bus/usb/drivers/hub
1-0:1.0 1-1.2:1.0 1-1:1.0 2-0:1.0 2-1:1.0 bind module new_id remove_id uevent unbind
# ls /sys/bus/usb/drivers/usb
1-1 1-1.2 1-1.2.1 1-1.2.2 1-1.2.4 1-1.3 1-1.4 2-1 bind uevent unbind usb1 usb2
# ls /sys/bus/usb/drivers/usb-storage/
1-1.2.2:1.2 bind module new_id remove_id uevent unbind
# ls /sys/bus/usb/drivers/usbfs
bind module new_id remove_id uevent unbind
# ls /sys/bus/usb/drivers/usbhid
1-1.2.1:1.0 1-1.2.4:1.0 1-1.2.4:1.1 bind module new_id remove_id uevent unbind
# ls /sys/bus/usb/drivers/uvcvideo
1-1.4:1.0 1-1.4:1.1 bind module new_id remove_id uevent unbind
# tree /sys/bus/usb/drivers/usb-storage/
/sys/bus/usb/drivers/usb-storage/
├── 1-1.2.2:1.2 -> ../../../../devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2/1-1.2.2/1-1.2.2:1.2
├── bind
├── module -> ../../../../module/usb_storage
├── new_id
├── remove_id
├── uevent
└── unbind
2 directories, 5 files
# echo -n "1-1.2.2:1.2" > /sys/bus/usb/drivers/usb-storage/unbind
# tree /sys/bus/usb/drivers/usb-storage/
/sys/bus/usb/drivers/usb-storage/
├── bind
├── module -> ../../../../module/usb_storage
├── new_id
├── remove_id
├── uevent
└── unbind
1 directory, 5 files
# tree /sys/bus/usb/devices/1-1.2.2:1.2
/sys/bus/usb/devices/1-1.2.2:1.2
├── bAlternateSetting
├── bInterfaceClass
├── bInterfaceNumber
├── bInterfaceProtocol
├── bInterfaceSubClass
├── bNumEndpoints
├── ep_05
│ ├── bEndpointAddress
│ ├── bInterval
│ ├── bLength
│ ├── bmAttributes
│ ├── direction
│ ├── interval
│ ├── power
│ ├── type
│ ├── uevent
│ └── wMaxPacketSize
├── ep_84
│ ├── bEndpointAddress
│ ├── bInterval
│ ├── bLength
│ ├── bmAttributes
│ ├── direction
│ ├── interval
│ ├── power
│ ├── type
│ ├── uevent
│ └── wMaxPacketSize
├── modalias
├── power
├── subsystem -> ../../../../../../../../bus/usb
├── supports_autosuspend
└── uevent
6 directories, 27 files
After unbinding the usb-storage
driver from the USB device, no more messages such as ‘usbfs: interface 2 claimed by usb-storage while 'xsane' sets config #1
‘ are added to /var/log/messages
when I launch a scanner application and select the USB device, but the scanner application still hangs (e.g. the XSane windows do not appear until I switch off the MP560 or unplug the USB cable). This happens irrespective of whether the USB device permissions are:
# ls -la /dev/bus/usb/001/009
crw-rw-r--+ 1 root lp 189, 8 Jul 20 20:35 /dev/bus/usb/001/009
or:
# ls -la /dev/bus/usb/001/009
crw-rw-r--+ 1 fitzcarraldo lp 189, 8 Jul 20 20:35 /dev/bus/usb/001/009
or:
# ls -la /dev/bus/usb/001/009
crw-rw-r--+ 1 fitzcarraldo scanner 189, 8 Jul 20 20:51 /dev/bus/usb/001/009
To reiterate, neither unbinding the usb-storage
driver from the USB device first nor changing the owner and group of the USB device solves the problem. So possibly the problem is not caused by udev or by a USB driver, but by the SANE software.
Experiment 2
I found a thread in the SANE developers’ mailing list about the same problem with a different model of MFP: Help needed diagnosing strange failure to scan with Samsung SCX-4500W. The same user posted the same query in the Arch Linux forums: [SOLVED] Samsung SCX4500W MFP can’t get scanner to work. Like my Canon PIXMA MP560, that MFP has more than one interface in a single USB device. Notice in the Arch Linux thread that the user never found a solution and finally adopted the same work-around I use, namely to scan via a network interface rather than via the USB interface.
Theodore Kilgore gives a good explanation in that SANE developers’ mailing list thread of why the problem occurs in Linux, and Thorsten Müller’s post suggests a udev rule that sets the permissions for the MFP so that SANE, CUPS and logged-in users can all access the USB device. All I had to do was replace references to Samsung (such as the vendor ID and product ID) with those for my Canon PIXMA MP560. I left everything else in my installation exactly the way it was (for example I did not touch /lib64/udev/rules.d/41-libsane.rules
and /lib64/udev/rules.d/70-printers.rules
). The only thing I did was to add a udev rules file /etc/udev/rules.d/99-canon-mp560.rules
with the following contents:
# ACL settings for Canon PIXMA MP560 printer MFP
ATTR{idVendor}=="04a9", ATTR{idProduct}=="173e", GOTO="canon"
GOTO="canon_end"
LABEL="canon"
RUN+="/bin/setfacl -m g:scanner:rw -m g:lp:rw $env{DEVNAME}"
TEST=="/var/run/ConsoleKit/database", \
RUN+="udev-acl --action=$env{ACTION} --device=$env{DEVNAME}"
LABEL="canon_end"
Both /bin/setfacl
and /var/run/ConsoleKit/database
exist in my installation, and, as shown earlier, my user account is a member of both the lp
and scanner
groups. After adding the above file, I rebooted and it appears the rule works as intended:
# getfacl /dev/bus/usb/001/009
getfacl: Removing leading '/' from absolute path names
# file: dev/bus/usb/001/009
# owner: root
# group: lp
user::rw-
user:fitzcarraldo:rw-
group::rw-
group:lp:rw-
group:scanner:rw-
mask::rw-
other::r--
However, although I was still able to print I still could not scan. Mind you, the line beginning ‘TEST==
‘ in the file /etc/udev/rules.d/99-canon-mp560.rules
is also in the file /lib64/udev/rules.d/70-udev-acl.rules
, but I’m no expert in udev rules, which are frankly beyond the ability of most users.
Experiment 3
I found a blog post about the same problem but with a Canon MP210 MFP: Canon multifunction printer: getting the printer drivers and scanner to work in debian/ubuntu/mint. This post suggested creating a udev rule file /etc/udev/rules.d/40-scanner-permissions.rules
containing the following:
# usb scanner
SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", MODE:="0666"
SUBSYSTEM=="usb_device",MODE:="0666"
but, although the rule appears to work as intended, it is still not possible to scan in my case. I then changed the file name to /etc/udev/rules.d/95-scanner-permissions.rules
, but that made no difference in my case.
Experiment 4
I also tried changing MODE="0664"
to MODE="0666"
in the following line in the file /lib64/udev/rules.d/50-udev-default.rules
but that made no difference either:
SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", MODE="0664"
Experiment 5
I am able to change the group of the USB device to ‘scanner
‘ instead of ‘lp
‘ by adding a rules file /lib64/udev/rules.d/99-canon.rules
(apparently 41-libsane.rules
does not work as intended because it is overruled by a higher-numbered file, but I have no idea which one, as 41-libsane.rules
is the only one explicitly mentioning the MP560) containing the following:
ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="173e", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"
But scanning still does not work, whether or not I unbind the usb-storage
driver from the USB device first and whether or not I change the owner and group of the USB device to root:lp
, root:scanner
, fitzcarraldo:lp
or fitzcarraldo:scanner
.
Conclusion
Although my installation can print via USB, scanning via USB does not work, whether or not the usb-storage
driver is bound to the USB device and whoever is the owner and group of the USB device. So it could be that the problem is not caused by udev or by the kernel (a USB driver), but by the SANE software itself. However, I think it is more likely to be some sort of contention between kernel and userspace, despite unbinding the usb-storage
driver from the device. Although I’m not excluding the possibility of a bug in SANE, irrespective of that it seems to me that the way GNU/Linux handles multiple interfaces of a single USB device is flawed. The udev design results in a morass of confusing and potentially conflicting rules in umpteen files in different directories, and the apparently uncoordinated independent demands on the same USB interface by the kernel and userspace are another potential source of problems. There is no standardisation in the udev rules files and their contents between the different Linux distributions, making investigation and solution of such problems even more complicated. Having to resort to work-arounds such as scanning via a network interface or scanning to a USB pen drive or memory card is a poor way of circumventing the problem, and is of no help anyway if a multi-function peripheral does not have a network interface, pen drive socket or memory card slot.
UPDATE (July 24, 2015): I have tried some other approaches, and had more success using a ‘quirk’ for the usb-storage
driver — see my next post for details.
Addendum: How to stop scanning applications detecting a Webcam
By the way, to stop XSane and other scanning applications detecting my Webcam via the Video for Linux SANE backend, I commented out all the device lines in the file /etc/sane.d/v4l.conf
like so:
$ cat
# In order to use the v4linux backend you have to give the device
# You can enable multiple lines if
# you really have multible v4l devices.
#
#/dev/bttv0
#/dev/video0
#/dev/video1
#/dev/video2
#/dev/video3