SANE: Network Access to a USB Scanner in Xubuntu 12.04

The missing link turns out to be assigning a device node with the proper owner, group, and permissions to let saned share the scanner over the network. IIRC, this worked right out of the box in previous versions of Xubuntu, but now requires manual tweakage.

That post gives the steps for my old SCSI scanner. It turns out that the udev rule is not optional for USB scanners… at least not in 12.04, anyway.

In order to build the udev rule, you start with lsusb:

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 002: ID 0424:2504 Standard Microsystems Corp. USB 2.0 Hub
Bus 002 Device 005: ID 0d8c:000c C-Media Electronics, Inc. Audio Adapter
Bus 002 Device 006: ID 046d:c52f Logitech, Inc. Wireless Mouse M305
Bus 008 Device 006: ID 04a9:220e Canon, Inc. CanoScan N1240U/LiDE 30
Bus 008 Device 003: ID 413c:1003 Dell Computer Corp. Keyboard Hub
Bus 008 Device 004: ID 413c:2010 Dell Computer Corp. Keyboard

That gives you the bus and device numbers, which means the corresponding device is, at least right now:

/dev/bus/usb/008/006

The udevinfo command I used a while ago has Gone Away, replaced by udevadm with even more syntactic sugar:

udevadm info --query=all --attribute-walk --name=/dev/bus/usb/008/006

Which produces a ton of information, starting with:

  looking at device '/devices/pci0000:00/0000:00:1d.2/usb8/8-1':
    KERNEL=="8-1"
    SUBSYSTEM=="usb"
    DRIVER=="usb"
    ATTR{configuration}==""
    ATTR{bNumInterfaces}==" 1"
    ATTR{bConfigurationValue}=="1"
    ATTR{bmAttributes}=="a0"
    ATTR{bMaxPower}=="500mA"
    ATTR{urbnum}=="18658"
    ATTR{idVendor}=="04a9"
    ATTR{idProduct}=="220e"
    ATTR{bcdDevice}=="0100"
    ATTR{bDeviceClass}=="ff"
    ATTR{bDeviceSubClass}=="00"
    ATTR{bDeviceProtocol}=="ff"
    ATTR{bNumConfigurations}=="1"
    ATTR{bMaxPacketSize0}=="8"
    ATTR{speed}=="12"
    ATTR{busnum}=="8"
    ATTR{devnum}=="6"
    ATTR{devpath}=="1"
    ATTR{version}==" 1.10"
    ATTR{maxchild}=="0"
    ATTR{quirks}=="0x0"
    ATTR{avoid_reset_quirk}=="0"
    ATTR{authorized}=="1"
    ATTR{manufacturer}=="Canon"
    ATTR{product}=="CanoScan"

Extracting the two highlighted values lets you create a udev rule. If your udev-fu is strong, you can pluck them directly from the lsusb output.

I created a new file:
/etc/udev/rules.d/60-scanner.rules

Which contains this rule:

# Canon LiDE 30 scanner
ATTRS{idVendor}=="04a9",ATTRS{idProduct}=="220e",SYMLINK+="scanner",MODE="0660",OWNER="root",GROUP="saned"

Based on the advice there, I added the port number to the /etc/xinetd.d/saned stanza, but I’m not sure it’s needed:

service sane-port
            {
              port = 6566
              socket_type = stream
              server = /usr/sbin/saned
              protocol = tcp
              user = saned
              group = scanner
              wait = no
              disable = no
            }

After doing all the rest of the saned and xinetd setup, unplug and replug the scanner, which should produce these devices:

ll /dev/bus/usb/008/006 /dev/scan*
crw-rw----+ 1 root saned 189, 901 Jan  5 21:30 /dev/bus/usb/008/006
lrwxrwxrwx  1 root root        15 Jan  5 21:14 /dev/scanner -> bus/usb/008/006

And then it should Just Work…

  1. #1 by Red County Pete on 2013-01-26 - 17:52

    I’ve got a silly(?) question. I’m looking at shifting my 2001 vintage P4 Vaio back to Linux. It doesn’t have any more critical jobs to do, and I’d like a more USB friendly version than my old Red Hat. Is Xubuntu 12.04 on a 1.6GHz box (500Mb Ram, 80Gb hard drive) going to work well, or is it too much? Long run, I’d like to get the RT mods and try it as a MIDI host processor, but there’s lots to learn on USB and driver-fu.

    • #2 by Ed on 2013-01-26 - 18:53

      shifting my 2001 vintage P4 Vaio back to Linux

      I don’t know for sure, but I think that one is slag: you could get a lean distro running, but it might take a lot of effort. I think any of the major distros, Xubuntu included, pretty much require hardware built in the last few years.

      A friend asked me to scrape-and-rebuild a machine from that era and it just didn’t go well, for a variety of reasons related to being slow and cramped, and I eventually gave up. I just retired a Pentium D from around 2006 and it’s a dud compared to this slightly less obsolete Core 2 Duo box, not to mention burning much more power.

      I’d say give it a try, but don’t get too attached to the project and stay ready to cut your losses…

      • #3 by david on 2013-01-27 - 02:04

        I’ll have you know that current Slackware builds run just fine on such hardware. Zippily, even. :)

        • #4 by Ed on 2013-01-27 - 06:36

          current Slackware builds run just fine

          It’s amazing what you can get out of good ol’ Slack.

          Back in the day, I actually conjured a stripped-down command-line-only Slackware install on a then-ancient Thinkpad 560Z with 96 MB of RAM… which pretty well cured me of thinking that was a Good Idea. [grin]

      • #5 by Erik on 2013-01-31 - 11:49

        Ubuntu 12.04 says it needs a processor with PAE – Physical Address Extensions. I’m working on a small project with a stack of Thinkpad T43s… most will install Ubuntu, one won’t (slightly older). So away it went and in its place I loaded a recent version of Centos 5. That works. Of course, if you want to play mp3 files on Centos, then you’re looking at an all-day compile festival. But yeah, Centos still deals with older cruft fairly well. It’ll work well enough in 512mb to use for surfing and LibreOffice, but bear in mind I’m doing a failsafe login and running twm by hand. No Gnome, no KDE in that amount of memory. :-)

        • #6 by Ed on 2013-01-31 - 12:57

          it needs a processor with PAE

          Every time I see PAE, I think of my good old EMS board: Expanded Memory and Extended Memory beyond the 640 kB limit…

          Now we need more than 4 GB of address space just for desktop apps. [sigh]

    • #7 by ewf on 2013-01-28 - 11:04

      This is probably the best place for airing one of my Lubuntu 12.10 woes. I was not able to use xemacs after the upgrade. The cure was to purge (wajig purge) emacsen-common and emacs23. Find and install/reinstall emacs24 and the xemacs21.

      • #8 by Ed on 2013-01-28 - 11:37

        after the upgrade

        I hadn’t attempted a version upgrade for quite a while, so I unleashed one on the Token Windows Laptop. It turned into a complete disaster, about which I haven’t written because I’m reluctant to even poke the wreckage with a long pole. It will boot into Windows and Xubuntu, but I suspect they’re gradually destroying each other’s filesystem; the partition table says that the partitions overlap in mysterious ways.

        In any event, I put up with all the hassle of re-configurating all the programs from scratch specifically so I can do a clean installation. That, of course, causes me to hang on to releases long after their best-used-by date…

        • #9 by ewf on 2013-01-29 - 11:20

          I’m getting more cautious as the newer distributions do not seem to be aware of (or care much about) the existing applications which need to be updated (new and shiny is better?). I use clonezilla to make a copy and upgrade the copy with syncing turned off. Ubuntu is moving in some directions that are not to my advantage so I’ve been running Arch Linux as a alternative with good success so far.

          • #10 by Ed on 2013-01-29 - 12:06

            running Arch Linux

            I fear I’m working back to Arch, too.

            What turned me off was the day when the X update that killed pretty nearly everything arrived… given the extensive hackage required to get all my inputs & displays working, I never did quite recover from that event.

  2. #11 by Red County Pete on 2013-01-27 - 12:33

    Thanks for the tips. I’ve had enough experience getting *nix running on less-than-capable machines (mostly 10-15 years ago, alas) that I think I can dust off the neurons and find a Good Enough solution. I do have a 350MHz P2 happily running (not much…) on Red Hat 7.

    The MIDI box used to run on a 30MHz Mac Classic II with 10Mb RAM, and 40M HDD, so there’s hope.

  3. #12 by Bill Rutiser on 2013-01-28 - 09:40

    A Raspberry Pi showed up under the holiday tree. If you haven’t heard of the Pi, it is worth a Google. Credit card sized, 700Mhz clock, ARM based, 512 Mbyte, etc. Organized and designed by a UK charity for educational use. Target price was 25USD but the actual price is somewhat higher. It runs a Debian based distribution and other ports are underway.
    17 or so GPIO pins including SPI, I2C, and a serial Tx,Rx.

    Takes up a lot less room than any retired PC.

    • #13 by Ed on 2013-01-28 - 10:10

      There’s a cadre of RPi enthusiasts in the local LUG, all having a great time beating the thing into submission. As I understand the situation, the A version is underwhelming, the B version is what you really want, and nobody seems happy with the closed-source nature of the CPU/video.

      I have reservations about the 3.3 V I/O pins for my purposes, because 5 V devices chew up the inputs and ordinary logic-level MOSFETs (i.e., the ones I have) don’t work with the outputs.

      But, yeah, I’m going to force myself to play with one… [grin]