NSLU2 print server

Principles of operation

The Linksys NSLU2 is used as a diskless (more or less diskless, see below...) spooling, non-filtering (i.e. raw) network printer server.
The original Linksys firmware is replaced with OpenWRT, which is lightweight enough to host a basic CUPS spooler leaving some 5 MB RAM disk space free.

A lighter way to have a non-spoling, non-filtering (i.e. pass-thru) print server using p910nd is described in the OpenWRT PrinterSharingHowto

Prerequisites

  • A Debian-based administration client (can be used almost any GNU/Linux distribution where upslug2 is supported, there are also Windows based counterparts, but here we only deal with Debian... duh!).
  • Latest OpenWRT firmware for Linksys NSLU2 (download it from www.slug-firmware.net)
  • An USB printer (here a DesignJet T610 44 in plotter will be used... a brain so small for a printer so big...)

Installation

  1. On the debian-based administration client, install upslug2:
    1. <pre>
    2. apt-get install upslug2
    3. </pre>
  2. Make sure that the administration client is on a wired network. Can also use a wireless link, but some consider it as less reliable. I tested both ways and there are no appreciable differences.
  3. Connect the NSLU2 to an ethernet network.
  4. Enter into upgrade mode
  5. Search for the NSLU2 with upslug2:
    1. <pre>
    2. upslug2 --device eth0
    3. </pre>
  6. Burn firmware:
    1. <pre>
    2. upslug2 -d eth0 -i &lt;image.bin&gt;
    3. </pre>
  7. Access the OpenWRT web asministration interface, set root password and network configuration parameters (better give a static IP, there).
    Note:
    The most recent OpenWRT firmware obtains its IP address via DHCP. Use a network analyser to find out DHCPREQUEST/DHCPACK.

For reference, check OpenWRT installation page.

Additional packages installation & configuration

What follows can be either done in the OpenWRT Web Management Interface, or via ssh/telnet. Here, console commands used in a ssh session will be used. Basic setup has been adapter from an how-to by Jim Lick (thank you, Jim).

Once logged in onto the NSLU2 as root, do the following:

  1. Update packages list: ipkg update.
  2. Check OpenWRT UsbStorageHowto for proper USB 1.1 and/or 2.0 support
  3. Install packages needed fo USB printer support: (reference: OpenWRT PrinterSharingHowto), basically all you should need to do is ipkg install kmod-usb-printer
  4. Install cups: ipkg install cups
  5. Make cupsd active at startup: /etc/init.d/cupsd enable
  6. Configure cups:
    /etc/cups/printers.conf
    .
    On recent OpenWRT, USB printer is found under /dev/lp0 instead of the expected /dev/usb/lp0. The config file must be modified, adjusting for printer name and characteristics. Furthermore, there are two template stanzas, one for an USB printer, another for a parallel one. Use one of these (e.g. USB) as your template and remove the other one. Feel free to change printer name as well as the Info and Location keys. Here is my /etc/cups/printers.conf:
    1. <pre>
    2. &lt;DefaultPrinter plotter&gt;
    3. Info Plotter HP DesignJet T610 44"
    4. Location Lab. SIT - Monopiano
    5. DeviceURI usb:/dev/lp0
    6. State Idle
    7. Accepting Yes
    8. JobSheets none none
    9. QuotaPeriod 0
    10. PageLimit 0
    11. KLimit 0
    12. &lt;/Printer&gt;</pre>
    Enable raw data spooling
    CUPS typically uses filters to convert print jobs to the printer’s native format. Because of memory limitations on the NSLU2, we don't want this. We instead use the printer as a raw one, while the client provides a file already in the printer's native format. Edit /etc/cups/mime.convs and /etc/cups/mime.types, uncommenting any line beginning with #application/octet-stream.
    Set up security settings in /etc/cups/cupsd.conf
    By default, CUPS requires user authentication to print. This is rather cumbersome, so it is adviceable to allow printing for all the IP address range of your network, especially if you're using one of the RFC 1918 (e.g. 192.168.1.x) address sets.
    1. <pre>
    2. &lt;Location /&gt;
    3. AuthClass Anonymous
    4. AuthType None
    5. Order Deny,Allow
    6. Deny From All
    7. Allow From 192.168/16
    8. &lt;/Location&gt;
    9. &lt;Location /admin&gt;
    10. Order Deny,Allow
    11. Deny From All
    12. &lt;/Location&gt;</pre>
    Set up a minimal spool area
    On OpenWRT, CUPS uses /tmp/cups to store temporary spool files. Anyway, /tmp on OpenWRT relies on remaining free memory as storage. NSLU2 in particular has little or no space left there. In my case, a plotter printout can easily eat out as much as 100 MB.
    A first temporary solution can be to use the space left on your device as a CUPS staging area:
    1. create a directory in /jffs: mkdir /jffs/cups
    2. give it proper access rights: chmod 1770 /jffs/cups
    3. in /etc/cups/cupsd.conf change RequestRoot and TempDir values:
      1. <pre>
      2. RequestRoot /jffs/cups
      3. TempDir /jffs/cups
      4. </pre>
    (Optional) set up a serious spool area
    This is done using an old 128 MB USB pendrive, but any USB storage device would do. The technique is the same as above, just check where your USB storage device is mounted, and substitute that path in RequestRoot and TempDir.
    Hint: before plugging the pendrive (or hard disk, or whatever it is) format it as ext2 on your Debian host...
    To have your USB storage device mounted at boot, refer to OpenWRT UsbStorageHowTo
  7. Reboot the NSLU2, or start CUPS with /etc/init.d/S50cupsd

Is everything ok?

On your administrative host, open a browser and point it to <your NSLU2 hostname or IP address>:631.
You should see the CUPS server web interface, and the printer you've configured. Make sure that you cannot access the admin functions, and remember that stock CUPS for OpenWRT lacks several functions.

Client configuration

On Windows clients, have at hand your printer driver software, as if the printer was a local one. Start normal printer installation process, using the "Add Printer" icon in the Control Panel "Printers" folder.
Select a "Network printer", and in the URL box type in your CUPS server printer address, as seen in the CUPS web administration interface (e.g. mine is http://plotter.uagra.net:631/printers/plotter).
Click on "next" and select the manufacturer and type of printer you have, or select "Have Disk" if the printer driver is not part of the standard Windows driver set) and go on with the rest of the normal printer setup process.
Another way of having this cat skinned is to install your printer as a local one, connected to FILE: or whatever, then open the printer properties dialog and change the port to a network printer port.