Network Installation of Windows Printers from Samba

Network Installation of Windows Printers from Samba

by Carla Schroder, author of the Linux Cookbook
01/13/2005

The combination of Samba and CUPS makes network printing on a mixed Linux/Windows LAN easier than ever. You can share Linux printers with Windows clients, and Windows printers with Linux clients. A Linux/Samba/CUPS printer server is reliable and reasonably simple to set up and maintain.

CUPS without Samba makes an excellent print server for both Windows and Linux clients. But it has one drawback: no network installation of Windows printer drivers. CUPS automatically shares printer drivers with Linux hosts with no extra work on your part; CUPS and Samba together can do the same for Windows hosts. You should have a functioning LAN, all of your Windows hosts in the same workgroup, a Linux machine already running at least one printer with CUPS, and Samba installed and ready to go to work.

When you're first trying this out, it is all right to run the commands as root, like in the following examples. It makes it easier to troubleshoot. But after you get the hang of it, it is better to create a user just for Samba administration chores.

Obtaining Drivers

First off, you need either the CUPS driver for Windows, or the Adobe PostScript driver files. Currently, the CUPS driver is unavailable, though an updated version is supposed to be ready soon.

The Adobe driver package works for all versions of Windows, so you can do without the CUPS drivers. The CUPS driver set is a better choice for Windows NT/2000/XP, because it offers more features and better performance. But the CUPS drivers do not support Windows 95/98/ME; you will still need the Adobe drivers for those. These are the files needed:



CUPS files for Windows NT/2000/XP

	cups.hlp

	cupsdrvr.dll

	cupsui.dll

	

Adobe PostScript files for Windows 95/98/ME	

	ADFONTS.MFM

	ADOBEPS4.DRV

	ADOBEPS4.HLP

	DEFPRTR2.PPD

	ICONLIB.DLL

	PSMON.DLL

	

Adobe PostScript files for Windows NT/2000/XP

	ADOBEPS5.DLL

	ADOBEPSU.DLL

	ADOBEPSU.HLP

	

In this article, we'll use only the Adobe drivers. Download the Adobe driver installer (the English version is called winsteng.exe) to a Windows PC and run the installer (even if you don't have a printer to install), so you can copy the files you need to your Samba server. Look for these two directories after installation: w32x86, which contains the files for Windows NT/2000/XP, and WIN40, which contains the files for Windows 95/98/ME.

The next step is to edit smb.conf to set up a printers and a print$ share. You must use these exact share names, as they are special reserved Samba shares. This is a complete example for wide-open, no-login network printer installations. Of course you will use your own hostnames, workgroup name, and network addresses:



workgroup = familia

server string = %h lan file server (Samba %v)

hosts allow = 192.168.1.

netbios name = windbag



log file = /var/log/samba/log.%m

max log size = 1000

syslog = 0

security = user

passwd program = /usr/bin/passwd %u



passwd chat = *Enter\snew\sUNIX\spassword:* %n\n *Retype\snew\sUNIX\spassword:* %n\n .

load printers = yes

printing = cups

printcap name = cups



[printers]

   comment = All Printers

   browseable = no

   path = /tmp

   printable = yes

   guest ok = yes

   public = yes

   writable = no

   create mode = 0700

   printer admin = root



[print$] 

   comment = Printer Drivers 

   path = /var/lib/samba/printers

   browseable = yes

   read only = yes

   guest ok = no

   write list = root

Save your changes and run the testparm command. When it says your smb.conf is free of errors, restart Samba:

# /etc/init.d/samba restart

Make sure there is a Samba root user:

# smbpasswd -a root

New SMB password:

Retype new SMB password:

Now copy the WIN40 and w32x86 directories to /usr/share/cups/drivers. Make sure that the Adobe filenames are all uppercase. If you use the CUPS drivers, they must be lowercase.

Run this command to ensure that CUPS is the printer back end for Samba:

# ln -s `which smbspool` /usr/lib/cups/backend/smb

Note that those are backticks, not apostrophes.

Copying the Drivers

Now it's time to use cupsaddsmb to export all of the installed CUPS printers to Samba. These command options assume that CUPS, Samba, and all of the drivers are on the same machine:

# cupsaddsmb  -U root -v -a

Password for root required to access localhost via SAMBA:

....

Running command: rpcclient localhost -N -U'root%1234' -c 'setdriver hp6L hp6L'

Succesfully set hp6L to driver hp6L.

Use your Samba password. You should see bales of output fly by, and the last two lines should resemble the example above. The last thing to do is edit smb.conf one more time. Change security = user to security = share, and then restart Samba. There may be a more elegant way to do this; the problem is you need user-level security to enable root to log in to Samba and run cupsaddsmb. But for users to install network printers without requiring Samba accounts, you need share-level security.

You should now be able to go to any Windows PC on your Samba LAN and install printers over the network, and Samba will automatically download the drivers.

Linux Printer Server

This is a great way to build a dedicated Linux print server. You can fine-tune access to printers any way you like with the usual Samba accounts and access controls. Use an old Pentium--don't clutter landfills; there's lots of life in those old PCs. Connect several parallel port printers to a single printer server by using PCI parallel expansion cards. USB printers are even easier and cheaper--a four-port USB hub costs around $20.

Resources

  • See the following man pages:
    cupsaddsmb (8)
    smb.conf (5)
    smbpasswd (5)

  • Chapter 23 of the Linux Cookbook has recipes for using Samba as a file server, for a peer network, for a domain controller, and all kinds of printing scenarios. Chapter 14 (free sample chapter!) covers printing with CUPS, including how to build a printer server for Windows without Samba.

  • Chapter 19 of The Official Samba-3 HOWTO and Reference Guide covers printing in extreme detail. See the Samba list archives for solutions to almost any problem.

Carla Schroder is a self-taught Linux and Windows sysadmin and the author of the Linux Cookbook.


Return to the Linux DevCenter.

Close    To Top
  • Prev Article-OS:
  • Next Article-OS:
  • Now: Tutorial for Web and Software Design > OS > Linux > OS Content
    Photoshop Tutorial
     

    Special Effect

      3D Effect
      Photoshop Articles
    Programming Tutorial
     

    C/C++ Tutorial

      Visual Basic
      C# Tutorial
    Database Tutorial
     

    MySQL Tutorial

      MS SQL Tutorial
      Oracle Tutorial
    Geek Tutorial
     

    Blogging Tutorial

      RSS Tutorial
      Podcasting Tutorial
    Graphic Design Tutorial
      Coreldraw Tutorial
      Illustrator Tutorial
      3D Tutorials
    Webmaster Articles
     

    Domain Service

      Web Hosting
      Site Promotion
    Java Tutorial/ Articles
     

    Java Servlets

      JavaEE Tutorial
     

    JavaBeans Tutorial

    XML Tutorial/ Articles
     

    XML Style

      AJAX Tutorial
      XML Mobile
    Flash Tutorial/ Articles
     

    Flash Video

      Action Script
      Flash Articles
    OS Tutorial/ Articles
      Linux Tutorial
      Symbian Tutorial
      MacOS Tutorial
    Personal Tech
      Hardware Tutorial
      Software Tutorial
      Online Auction