Saturday, March 13, 2004

Creating a Print Server using Samba

I'm using samba to allow me to hook a printer up to one of my machines and then print form my Windows laptop. These are the steps I took to connect my HP5550 using USB:

1/ Connect the printer and use the Red Hat Printer Configuration GUI to set up the printer and print a test page. So far so good.

2/ Edit the samba configuration file (/etc/samba/smb.conf).

Make sure the workgroup and server string are set to something sensible. I'm using the default "workgroup" and the a string that relates to the name of the server "Dionysus Share".

Edit the hosts allowed section to allow everything on my subnet (192.168.0)

Uncomment the printer configuration, to load the printer configuration:
printcap name = /etc/printcap
load printers = yes

Dont worry about specifying the printer system - samb will use CUPS by default

Towards the bottom of the file uncomment the printers section and modify it so that it looks like this:
[printers]
comment = All Printers
path = /var/spool/samba/lpd/
browseable = no
# Set public = yes to allow user 'guest account' to print
guest ok = yes
public = yes
writable = no
printable = yes
create mode = 0700
use client driver = yes

The important bits here are:
path = /var/spool/samba/lpd/ - this tells samba where to write the temporary file created for printing. This directory needs to exist and needs to be writable (by all users ?!?!)

use client driver = yes - this tells samba that clients using the service will have a print driver installed (so they don't have to download it from the server). This is what makes the queue viewable from Windows machines.

3/ Restart Samba using /etc/init.d/smb restart

4/ On the client (i.e. Windows machine), browse the network and find the print server (in this case it's called Dionysus). Drilling down on the server should show the printer (with the name it was given in the CUPS conffiguration of step 1).

5/ Double click on the printer. If the drivers are set up correctly on the client the print queue should be displayed; if they are'nt, then Windows will prompt for the driver to be installed.

6/ Attempt to print a test page (In Windows, open the print queue, select the Printer menu and the Printing Preferences option. Click the "Print Test Page" button).

7/ If the test page does'nt print then check the samba log for the client machine in /var/log/samba for clues. The following message:
lpr: unable to print file: client-error-document-format-not-supported
had me foxed for a while. I could see that the file was making its way via the /var/spool/samba/lpr directory becasue the timestamp on the directory would change. A google search on the error message turned up the following changes that must be made to the CUPS configuration file /etc/cups/mime.convs to enable the raw filter (by uncommenting the line):

application/octet-stream application/vnd.cups-raw 0 -

Also, edit the mime.types file to un comment the line:

application/octet-stream

8/ restart CUPS using /etc/init.d/cups restart

9/ Repeat step 6 and the test page *should* print.