FreeBSD - Printing Setup

The first section involves setting up access to printers on FreeBSD 6.2.

The second section involves setting up access to printers on FreeBSD 4.9.

  1. First will be setting up a local parallel printer using lpd.
  2. Next will be setting up access to a remote printer using CUPS.

Setting up Local Parallel-Port Printer on FreeBSD 6.2 Using CUPS

My computer running 6.2 has an AMD 64-bit processor, and the built-in line printer daemon would not work, so I switched to using CUPS.

I'm still polishing these instructions since I configured printing on CUPS without logging my actions as I went along, so I'm reproducing from memory and from the various command shells and web browser tabs holding the information I'm reporting here.

My printer (Canon BJ200 - an old one) has a parallel interface, so I'll only talk about parallel interface setup.

Prepare Hardware and Kernel

Check Kernel Recognition of Parallel Port Device

Ensure the kernel recognizes the parallel port device (/dev/ppc0) and the printer port device (/dev/lpt0). Do this by grep ppc /var/run/dmesg.boot and grep lpt /var/run/dmesg.boot - if these aren't there, read the FreeBSD handbook about this.

Check Kernel Support for Port

Ensure the kernel supports the port. You already did the first part by ensuring the device entries exist. By default, interrupt-driven communications mode is set up for the port, using an IRQ.

Test the port by:

# lptest > /dev/lpt0

and seeing if you get output from the printer.

Configure System

Set Permissions for Parallel Port Device

Modify the permissions and ownership of the parallel printer port device by changing its ownership as follows:

chown root:cups /dev/lpt0

and its permissions as follows

chmod g+rw /dev/lpt0

Make these changes permanent by adding the following lines to /etc/devfs.conf:

own	lpt0	root:cups
perm	lpt0	0660

Enable CUPS Daemon

Add the following line to /etc/rc.conf so that you can run the cupsd control script while you are setting up the system and so that cupsd will be started upon boot. The cupsd control script will invoke cupsd only if this control value is set in /etc/rc.conf, whether run from the command line or while booting.

cupsd_enable="YES"

If you run lpd, remove the lines for lpd in /etc/rc.conf

Handle LPD Support Binaries

The lpd client utility programs lpr, lpq, and lprm are part of the operating system and are located in /usr/bin, while the CUPS client programs that are named are part of a third-party port and are located in /usr/local/bin. By default, /usr/bin is placed before /usr/local/bin in the default PATH environment variable, so if you use those programs, you will end up using the lpd versions of the programs instead of the CUPS versions unless you make one of the following changes:

Build Supporting Software

Build the following ports:

Download and Install Printer Configuration File

Obtain a printer configuration file for your printer and install it so CUPS can use it to configure your printer.

Obtain the Printer Configuration File

  1. Go to Linux Printing, find your printer on the printer listings, and obtain the printer configuration file (PPD) for your printer.

Install the Printer Configuration File

The PPD file goes in /usr/share/cups/model/.

Make Parallel Port Driver Poll if Necessary

I had the problem of the printer printing too slowly (one printer head pass, wait a long time, then another printer head pass) where a clue is an entry in /var/log/messages mentioning interrupt throttling and interrupt storm.

Try out the following to change the parallel port into polling mode from the default interrupt mode:

lptcontrol -p -d /dev/lpt0.ctl

Specify Device Hints for Parallel Port Chipset Driver

To set the parallel port permanently in polling mode upon subsequent boots, add the following to /boot/device.hints:

hint.ppc.0.flags="0x28"

The bit mask is as follows:

Start CUPS and Create the Printer

Start cups with /usr/local/etc/rc.d/cupsd start. Access the CUPS administration page at http://localhost:631. Create the printer; you should see the parallel port in the list of devices and the entry for your printer matching the PPD file you installed. Generate a test page using the admin interface.

Useful References

Check out Roland's FreeBSD Page, Foomatic - Installing a Printer, Printer Compatibility, CUPS User Documentation


Setting up Access to Printers on FreeBSD 4.9

This is obviously older stuff, and CUPS has changed since then.

Setting up a Local Parallel-port Printer

Read the FreeBSD Handbook

Read the FreeBSD Handbook section on printing - this page follows that closely.

Prepare Hardware and Kernel

My printer (BJ200 - it's an old one) has a parallel interface, so I'll only talk about parallel interface setup.

Ensure the kernel recognizes the parallel port device (/dev/ppc0) and the printer port device (/dev/lpt0). Do this by grep ppc /var/run/dmesg.boot and grep lpt /var/run/dmesg.boot - if these aren't there, read the FreeBSD handbook about this.

Ensure the kernel supports the port. You already did the first part by ensuring the device entries exist. By default, interrupt-driven communications mode is set up for the port, using an IRQ.

Test the port by:

# lptest > /dev/lpt0

and seeing if you get output from the printer.

Enable the Spooler to Support this Local Printer Locally

I'm just using plain old lpd for now.

Do just like the handbook section 11.3.1.4 says, and create an entry in /etc/printcap for your printer

  1. Pick a name - there should be at least one printer with name lp and the last entry in the name list should be the full printer name
  2. Suppress headers as instructed
  3. make a spooling directory - the handbook says a different directory from what was set up on my machine, namely /var/spool/output/lpd.
  4. set the device entry
  5. install/reference an input filter - here's mine for my BJ-200 printer, which I put at /usr/local/libexec/lpd/bj200if - this file is derived from the one presented in the Advanced Printing Setup page in the FreeBSD Handbook. Set the file as executable.
  6. start the line printer daemon lpd - use the -s flag if you only want local clients for your printer, and add the following two lines to /etc/rc.conf:
  7. test the system using lpr or your browser or word processor print function

Accessing a Remote Printer using CUPS

Build the port

Prepare for building the print/cups meta-port by adding the following entries to /etc/make.conf:

CUPS_OVERWRITE_BASE=yes allows you to build the CUPS binaries that replace the FreeBSD-supplied lp/lq/lpr/lprm binaries in /usr/bin. NO_LPR=yes prevents future operating system rebuilds/upgrades from overwriting the CUPS binaries. See /usr/ports/print/cups-lpr/Makefile for the note on the make flag CUPS_OVERWRITE_BASE.

Then, build the print/cups meta-port. As part of the build of print/cups-lpr, the FreeBSD- supplied lpr binaries will be renamed with a .bak extension, so you can still have access to them.

Set up CUPS daemon

Kill your existing lpd, and remove the parameters in /etc/rc.conf that starts it on system startup.

Run the CUPS daemon by entering cupsd at the command line (as root).

You can use the lpadmin command line program to administer the CUPS daemon. Try the web interface at http://localhost:631/ for a GUI experience.

Choose Create printer, define a name, indicate the device. If the device is a network printer that provides an IPP interface, choose ipp, then set the URI as ipp://ip-address:631. Choose the driver for your printer, or choose Generic.

Set up other Programs to Use CUPS

For PDF viewers (on KDE), specify that they should use CUPS for printing.

For OpenOffice, run the spadmin program in the (installpath)/program directory - see the help topic on "Setting up Printer, Fax, and Fonts Under UNIX Based Programs".

Invoking CUPS on System Startup

The CUPS startup script is located at /usr/local/etc/rc.d/cups.sh.sample - you will probably have to rename this.


Back to FreeBSD main page