Differences between revisions 46 and 48 (spanning 2 versions)
Revision 46 as of 2015-03-06 17:36:43
Size: 939
Comment: moved commented item at the end of the list to remove awkward empty line
Revision 48 as of 2017-08-14 16:16:49
Size: 12705
Editor: Brian Potkin
Comment: An extensive expansion and updating of the material on this page.
Deletions are marked like this. Additions are marked like this.
Line 5: Line 5:
 * You probably want to install a front-end such as DebianPkg:simple-scan or DebianPkg:sane to use your scanner.
 * Then add users to the scanner group to give them access to your scanner.

## I'm sure we can comeup with a better name
SaneOverNetwork

=== Installation notes for various scanners ===
## Some day I'll get my SCSI scanner out and test whether the same advice given here applies to it. (Brian Potkin)
Setting up and administering a scanner connected to a USB port.

<<TableOfContents()>>

=== Introduction ===

Scanning a document from a standalone scanner or one in a multifunctional device involves using [[http://www.sane-project.org/intro.html| SANE]] (Scanner Access Now Easy). The Project provides a collection of scanner backends which can communicate with the scanner in order to drive it. Backends not provided by SANE can easily be accomodated within the SANE scanning framework whether or not the software is free ([[http://hplipopensource.com/hplip-web/index.html|HP]]) or non-free (Brother, Samsung etc). Those scanners which SANE directly supports are listed [[http://www.sane-project.org/sane-supported-devices.html|here]]

The first step on the road to successful scanning is to install [[DebianPkg:libsane|libsane]], which has the central library for operating scanners. The package also provides SANE's collection of scanner backends. If the scanner is [[http://www.sane-project.org/sane-supported-devices.html|not supported]] by SANE, the backend (and other files) will have to be obtained from the Debian archives or the vendor. A notable free backend source requiring this step is the one for the [[#aio|all-in-one machines]] from [[DebianPkg:hplip|HP]].

The next two sections assume you have the backend (and other files) that SANE or the vendor supply. Your scanner should work out-of the-box with a [[#front|frontend]] without bothering with any of the next steps, but it is as well to be aware there are trouble-shooting procedures which can be followed.

<<Anchor(discovery)>>
=== Scanner and Backend Discovery ===

Connect the scanner to the computer and see what [[DebianMan:lsusb|lsusb]]
gives:

{{{
brian@desktop:~$ lsusb

Bus 002 Device 005: ID 04b8:080f Seiko Epson Corp. Stylus Photo RX420/RX425/RX430
}}}

There is an Epson Stylus Photo on USB Bus 002 and at Device 005. That's fine,
but it tells us nothing about whether we can get the device scanning.

Install [[DebianPkg:sane-utils|sane-utils]] and see if the [[DebianMan:sane-find-scanner|scanner is detected]] with

{{{
sane-find-scanner
}}}

Hopefully, you will see your scanner found.

{{{
brian@test:~$ 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.

could not open USB device 0x0644/0x0200 at 004:002: Access denied (insufficient permissions)
could not open USB device 0x1d6b/0x0002 at 004:001: Access denied (insufficient permissions)
could not open USB device 0x045e/0x008c at 007:002: Access denied (insufficient permissions)
could not open USB device 0x1d6b/0x0001 at 007:001: Access denied (insufficient permissions)
could not open USB device 0x1d6b/0x0001 at 006:001: Access denied (insufficient permissions)
could not open USB device 0x1d6b/0x0001 at 005:001: Access denied (insufficient permissions)
could not open USB device 0x1d6b/0x0002 at 003:001: Access denied (insufficient permissions)
found USB scanner (vendor=0x04b8 [EPSON], product=0x080f [USB MFP]) at libusb:002:005
could not open USB device 0x1d6b/0x0001 at 002:001: Access denied (insufficient permissions)
could not open USB device 0x04b3/0x3003 at 001:005: Access denied (insufficient permissions)
could not open USB device 0x04b3/0x3004 at 001:004: Access denied (insufficient permissions)
could not open USB device 0x1d6b/0x0001 at 001:001: Access denied (insufficient permissions)
  # Your USB scanner was (probably) detected. It may or may not be supported by
  # SANE. Try scanimage -L and read the backend's manpage.
}}}

A scanner has correctly been located on Bus 002 as Device 005. If access to this device had also been denied (as was access to the other USB devices) the [[#perms|permissions on the USB bus]] would have had to be looked at.

Now it is known that a USB scanner exists, run

{{{
scanimage -L
}}}

The output obtained here is:

{{{
device `epson:libusb:002:005' is a Epson RX420 flatbed scanner
}}}

The [[DebianMan:scanimage|scanimage manual]] describes what ''-L'' is intended to do. In the context of a local USB device, the positive response indicates that SANE has a backend to support the scanner.

Now place a document on the scanner's glass plate and scan it with

{{{
scanimage > image.pnm
}}}

Success in generating image.pnm is a good indication that scanning with
other [[#front|frontends]] is also likely to be successful. The file should
be viewable with an image viewer such as [[DebianPkg:imagemagick|imagemagick]]

<<Anchor(perms)>>
=== Permissions ===

{{{#!wiki note
It is not necessary for a locally logged-in user to be in the scanner group. Permissions on the scanner device are automatically taken care of by the kernel and those on the USB bus are granted to a user by udev, given that

 * libpam-systemd is installed.
 * There is an appropriate vendor ''*.rules'' file in ''/lib/udev/rules.d''.
}}}

A user wishing to access and use a scanner must have permission to access a scanner device file and to use a device on the USB bus. Under Debian's default init system,[[DebianPkg:systemd|systemd]], and with [[DebianPkg:libpam-systemd|libpam-systemd]] installed, the correct permissions are set up by ''/lib/udev/rules.d/60-libsane.rules'' when the scanner is plugged in.

For the scanner device file:

{{{
brian@test:~$ ls -l /dev/sg*
crw------- 1 root root 21, 0 Aug 4 09:40 /dev/sg0
crw-rw----+ 1 root root 21, 1 Aug 4 09:40 /dev/sg1
crw------- 1 root root 21, 2 Aug 4 09:40 /dev/sg2
crw------- 1 root root 21, 3 Aug 4 09:40 /dev/sg3
crw------- 1 root root 21, 4 Aug 4 09:40 /dev/sg4
crw------- 1 root root 21, 5 Aug 4 09:40 /dev/sg5
crw------- 1 root root 21, 6 Aug 4 09:40 /dev/sg6
crw------- 1 root root 21, 7 Aug 4 14:46 /dev/sg7
}}}

Observe the ''+'' after the Unix permissions for ''/dev/sdg1''. It indicates an [[DebianMan:acl|ACL]] (Access Control List), which specifies which users are granted access to''/dev/sdg1''. To see an ACL, do

{{{
brian@test:~$ getfacl /dev/sg1
getfacl: Removing leading '/' from absolute path names
# file: dev/sg1
# owner: root
# group: root
user::rw-
user:brian:rw-
group::---
mask::rw-
other::---
}}}

User brian has ''rw'' access to the device file. Similar permissions would be required on the USB bus.

For the USB bus:

{{{
brian@test:~$ ls -l /dev/bus/usb/*/*
crw------- 1 root root 189, 0 Aug 4 09:40 /dev/bus/usb/001/001
crw------- 1 root root 189, 3 Aug 4 13:40 /dev/bus/usb/001/004
crw------- 1 root root 189, 4 Aug 4 13:40 /dev/bus/usb/001/005
crw------- 1 root root 189, 128 Aug 4 09:40 /dev/bus/usb/002/001
crw-rw----+ 1 root root 189, 132 Aug 4 18:25 /dev/bus/usb/002/005
crw------- 1 root root 189, 256 Aug 4 09:40 /dev/bus/usb/003/001
crw------- 1 root root 189, 384 Aug 4 09:40 /dev/bus/usb/004/001
crw------- 1 root root 189, 385 Aug 4 09:40 /dev/bus/usb/004/002
crw------- 1 root root 189, 512 Aug 4 09:40 /dev/bus/usb/005/001
crw------- 1 root root 189, 640 Aug 4 09:40 /dev/bus/usb/006/001
crw------- 1 root root 189, 768 Aug 4 09:40 /dev/bus/usb/007/001
crw------- 1 root root 189, 769 Aug 4 09:40 /dev/bus/usb/007/002

brian@test:~$ getfacl /dev/bus/usb/002/005
getfacl: Removing leading '/' from absolute path names
# file: dev/bus/usb/002/005
# owner: root
# group: root
user::rw-
user:brian:rw-
group::---
group:scanner:rw-
mask::rw-
other::---
}}}

User brian could also gain access to the USB device by being in the scanner group. But there is little point in doing that.

<<Anchor(configs)>>
=== Configuration Files for libsane ===

[[DebianPkg:libsane-common|libsane-common]] installs the configuration files dll.conf, dll.d, [[DebianMan:sane-net|net.conf]] and [[DebianMan:saned|saned.conf]] in ''/etc/saned.d''. The first, third and fourth files are central to accessing a scanner [[SaneOverNetwork|over the network]].

The contents of dll.conf is a list of backends that may be loaded dynamically upon demand. Commenting out the backends not used might lead to a slight decrease in scanning time. It is also possible to add a file in ''/etc/sane.d/dll.d'' that contains a list of backends to be added. This is often done by software providing a [[#aio|non-SANE backend]].

<<Anchor(aio)>>
=== HP all-in-one (aio) Machines ===

A backend for these devices is developed and supported by HP via [[DebianPkg:hplip|HPLIP]]. The backend is named ''hpaio'' and is listed in the file ''hplip'' in ''/etc/saned/dll.d''. Device detection support is provided by ''/lib/udev/rules.d/56-hpmud.rules''. The straightforward way to employ ''hpaio'' and ''56-hpmud.rules'' is to install ''hplip'' and its recommended dependencies. This way also makes it easier to install a non-free plugin with DebianMan:hp-plugin if [[http://hplipopensource.com/hplip-web/plugin.html|the scanner needs one]].

As a matter of interest, all that is really needed for scanning with an aio scanner is libsane-hpaio (without its recommended packages) and ''56-hpmud.rules''. Copy the latter file to ''/lib/udev/rules.d/'' from the hplip package.

<<Anchor(front)>>
=== Frontends for Scanning ===

A frontend is a program which interfaces with a SANE backend to produce a scanned output in a desired format. SANE has been designed to interwork with any SANE-compliant frontend, command line or GUI based

 * [[DebianPkg:sane-utils|scanimage]]: A command line interface from the SANE Project to control scanning.
 * [[DebianPkg:xsane|xsane]]: A GUI for image acquisition from a scanner. Can be invoked through [[DebianPkg:gimp|The GIMP]].
 * [[DebianPkg:simple-scan|simple-scan]]: A GTK+ application with a minimal GUI. Offers ease-of-use and integration with the [[DebianPkg:gnome|GNOME desktop]].
 * [[DebianPkg:sane|xscanimage]]: A SANE Project GUI for image acquisition from a scanner. Can be invoked through The GIMP.
 * [[DebianPkg:skanlite|skanlite]]: A graphical scanner application by KDE.
 * [[DebianPkg:gscan2pdf|gscan2pdf]]: A graphical application to produce PDFs or !DjVus from scanned documents.

## Capital letter for titles.
## Pages reviewed but no changes to make any of them consistent with this page. (BrianPotkin)

<<Anchor(various)>>
=== Installation Notes for Various Scanners ===
Line 21: Line 208:

=== Finally ===

Do not forget to read the Debian and other documentation in ''/usr/share/doc/libsane''. Hopefully, there is no conflict between it and what is on this page.



#######################################################
#################### END OF WIKI PAGE #################
## Portions of the original page are below, together ##
### with comments on why they were altered, removed ###
########## or restructured. (Brian Potkin) ############
#######################################################

###### Move to another section.
## * You probably want to install a front-end such as DebianPkg:simple-scan or DebianPkg:sane to use your scanner.

###### A blanket "add users to the scanner group" is incorrect.
## Adding a user to the lp group is a security risk. cupsd.conf, PPD files in /etc/cups and files in /var/spool/cups can be read by such users. I wonder if the advice relates in some way to parallel port scanners. (BrianPotkin)
## * Then add users to the scanner group to give them access to your scanner. If you use a multifunctional, you probably have to add your user to the lp group as well.

###### Perhaps best to link to the relevant page later on. (BP)
## I'm sure we can comeup with a better name
## Perhaps best to link to the relevant page later on.
##SaneOverNetwork

Translation(s): English - Français - Italiano


Setting up and administering a scanner connected to a USB port.

Introduction

Scanning a document from a standalone scanner or one in a multifunctional device involves using SANE (Scanner Access Now Easy). The Project provides a collection of scanner backends which can communicate with the scanner in order to drive it. Backends not provided by SANE can easily be accomodated within the SANE scanning framework whether or not the software is free (HP) or non-free (Brother, Samsung etc). Those scanners which SANE directly supports are listed here

The first step on the road to successful scanning is to install libsane, which has the central library for operating scanners. The package also provides SANE's collection of scanner backends. If the scanner is not supported by SANE, the backend (and other files) will have to be obtained from the Debian archives or the vendor. A notable free backend source requiring this step is the one for the all-in-one machines from HP.

The next two sections assume you have the backend (and other files) that SANE or the vendor supply. Your scanner should work out-of the-box with a frontend without bothering with any of the next steps, but it is as well to be aware there are trouble-shooting procedures which can be followed.

Scanner and Backend Discovery

Connect the scanner to the computer and see what lsusb gives:

brian@desktop:~$ lsusb

Bus 002 Device 005: ID 04b8:080f Seiko Epson Corp. Stylus Photo RX420/RX425/RX430

There is an Epson Stylus Photo on USB Bus 002 and at Device 005. That's fine, but it tells us nothing about whether we can get the device scanning.

Install sane-utils and see if the scanner is detected with

sane-find-scanner

Hopefully, you will see your scanner found.

brian@test:~$ 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.

could not open USB device 0x0644/0x0200 at 004:002: Access denied (insufficient permissions)
could not open USB device 0x1d6b/0x0002 at 004:001: Access denied (insufficient permissions)
could not open USB device 0x045e/0x008c at 007:002: Access denied (insufficient permissions)
could not open USB device 0x1d6b/0x0001 at 007:001: Access denied (insufficient permissions)
could not open USB device 0x1d6b/0x0001 at 006:001: Access denied (insufficient permissions)
could not open USB device 0x1d6b/0x0001 at 005:001: Access denied (insufficient permissions)
could not open USB device 0x1d6b/0x0002 at 003:001: Access denied (insufficient permissions)
found USB scanner (vendor=0x04b8 [EPSON], product=0x080f [USB MFP]) at libusb:002:005
could not open USB device 0x1d6b/0x0001 at 002:001: Access denied (insufficient permissions)
could not open USB device 0x04b3/0x3003 at 001:005: Access denied (insufficient permissions)
could not open USB device 0x04b3/0x3004 at 001:004: Access denied (insufficient permissions)
could not open USB device 0x1d6b/0x0001 at 001:001: Access denied (insufficient permissions)
  # Your USB scanner was (probably) detected. It may or may not be supported by
  # SANE. Try scanimage -L and read the backend's manpage.

A scanner has correctly been located on Bus 002 as Device 005. If access to this device had also been denied (as was access to the other USB devices) the permissions on the USB bus would have had to be looked at.

Now it is known that a USB scanner exists, run

scanimage -L

The output obtained here is:

device `epson:libusb:002:005' is a Epson RX420 flatbed scanner

The scanimage manual describes what -L is intended to do. In the context of a local USB device, the positive response indicates that SANE has a backend to support the scanner.

Now place a document on the scanner's glass plate and scan it with

scanimage > image.pnm

Success in generating image.pnm is a good indication that scanning with other frontends is also likely to be successful. The file should be viewable with an image viewer such as imagemagick

Permissions

It is not necessary for a locally logged-in user to be in the scanner group. Permissions on the scanner device are automatically taken care of by the kernel and those on the USB bus are granted to a user by udev, given that

  • libpam-systemd is installed.
  • There is an appropriate vendor *.rules file in /lib/udev/rules.d.

A user wishing to access and use a scanner must have permission to access a scanner device file and to use a device on the USB bus. Under Debian's default init system,systemd, and with libpam-systemd installed, the correct permissions are set up by /lib/udev/rules.d/60-libsane.rules when the scanner is plugged in.

For the scanner device file:

brian@test:~$ ls -l /dev/sg*
crw-------  1 root root 21, 0 Aug  4 09:40 /dev/sg0
crw-rw----+ 1 root root 21, 1 Aug  4 09:40 /dev/sg1
crw-------  1 root root 21, 2 Aug  4 09:40 /dev/sg2
crw-------  1 root root 21, 3 Aug  4 09:40 /dev/sg3
crw-------  1 root root 21, 4 Aug  4 09:40 /dev/sg4
crw-------  1 root root 21, 5 Aug  4 09:40 /dev/sg5
crw-------  1 root root 21, 6 Aug  4 09:40 /dev/sg6
crw-------  1 root root 21, 7 Aug  4 14:46 /dev/sg7

Observe the + after the Unix permissions for /dev/sdg1. It indicates an ACL (Access Control List), which specifies which users are granted access to/dev/sdg1. To see an ACL, do

brian@test:~$ getfacl /dev/sg1
getfacl: Removing leading '/' from absolute path names
# file: dev/sg1
# owner: root
# group: root
user::rw-
user:brian:rw-
group::---
mask::rw-
other::---

User brian has rw access to the device file. Similar permissions would be required on the USB bus.

For the USB bus:

brian@test:~$ ls -l /dev/bus/usb/*/*
crw-------  1 root root 189,   0 Aug  4 09:40 /dev/bus/usb/001/001
crw-------  1 root root 189,   3 Aug  4 13:40 /dev/bus/usb/001/004
crw-------  1 root root 189,   4 Aug  4 13:40 /dev/bus/usb/001/005
crw-------  1 root root 189, 128 Aug  4 09:40 /dev/bus/usb/002/001
crw-rw----+ 1 root root 189, 132 Aug  4 18:25 /dev/bus/usb/002/005
crw-------  1 root root 189, 256 Aug  4 09:40 /dev/bus/usb/003/001
crw-------  1 root root 189, 384 Aug  4 09:40 /dev/bus/usb/004/001
crw-------  1 root root 189, 385 Aug  4 09:40 /dev/bus/usb/004/002
crw-------  1 root root 189, 512 Aug  4 09:40 /dev/bus/usb/005/001
crw-------  1 root root 189, 640 Aug  4 09:40 /dev/bus/usb/006/001
crw-------  1 root root 189, 768 Aug  4 09:40 /dev/bus/usb/007/001
crw-------  1 root root 189, 769 Aug  4 09:40 /dev/bus/usb/007/002

brian@test:~$ getfacl /dev/bus/usb/002/005
getfacl: Removing leading '/' from absolute path names
# file: dev/bus/usb/002/005
# owner: root
# group: root
user::rw-
user:brian:rw-
group::---
group:scanner:rw-
mask::rw-
other::---

User brian could also gain access to the USB device by being in the scanner group. But there is little point in doing that.

Configuration Files for libsane

libsane-common installs the configuration files dll.conf, dll.d, net.conf and saned.conf in /etc/saned.d. The first, third and fourth files are central to accessing a scanner over the network.

The contents of dll.conf is a list of backends that may be loaded dynamically upon demand. Commenting out the backends not used might lead to a slight decrease in scanning time. It is also possible to add a file in /etc/sane.d/dll.d that contains a list of backends to be added. This is often done by software providing a non-SANE backend.

HP all-in-one (aio) Machines

A backend for these devices is developed and supported by HP via HPLIP. The backend is named hpaio and is listed in the file hplip in /etc/saned/dll.d. Device detection support is provided by /lib/udev/rules.d/56-hpmud.rules. The straightforward way to employ hpaio and 56-hpmud.rules is to install hplip and its recommended dependencies. This way also makes it easier to install a non-free plugin with hp-plugin if the scanner needs one.

As a matter of interest, all that is really needed for scanning with an aio scanner is libsane-hpaio (without its recommended packages) and 56-hpmud.rules. Copy the latter file to /lib/udev/rules.d/ from the hplip package.

Frontends for Scanning

A frontend is a program which interfaces with a SANE backend to produce a scanned output in a desired format. SANE has been designed to interwork with any SANE-compliant frontend, command line or GUI based

  • scanimage: A command line interface from the SANE Project to control scanning.

  • xsane: A GUI for image acquisition from a scanner. Can be invoked through The GIMP.

  • simple-scan: A GTK+ application with a minimal GUI. Offers ease-of-use and integration with the GNOME desktop.

  • xscanimage: A SANE Project GUI for image acquisition from a scanner. Can be invoked through The GIMP.

  • skanlite: A graphical scanner application by KDE.

  • gscan2pdf: A graphical application to produce PDFs or DjVus from scanned documents.

Installation Notes for Various Scanners

Finally

Do not forget to read the Debian and other documentation in /usr/share/doc/libsane. Hopefully, there is no conflict between it and what is on this page.


CategoryHardware CategoryScanner CategoryPrinter