Setting up Samba as a Print Server

From SambaWiki
Revision as of 17:16, 16 January 2017 by Mmuehlfeld (talk | contribs) (Updated links)


A print server accepts print jobs from network computers, queues them locally and then sends them to the appropriate printers. As well as having domain and file service capabilities, Samba can also act as a MS Windows compatible print server. While Samba provides the interface to Windows/SMB machines, CUPS or LDP is used by Samba to send print jobs to the devices.

In the following, we give an overview about Sambas supported backends, including how to add a new network printer to them. The examples setup a RAW printer (content is sent unmodified to the device). We don't use filters or drivers on the backend, because a RAW printer allows the rendering of the output to be done on the workstation by the printer vendors specific driver. In the latter the printer will be shared by Samba to provide the service to the network. If you're also interested in automatic printer driver deployment via Point'n'Print, see the corresponding documentation.

Print server backends

In the following we assume that the print server backend is already basically configured, running and printers can be added.


CUPS is currently the most widely used spool system in *nix environments and shipped with most distributions. Samba has built-in support and defaults to CUPS, if the development package (header files and libraries) are found at compile time.

  • Open the CUPS admin web frontend (https://servername:631/admin)
  • Click "Add Printer" on the "Administration" tab
  • Choose the way that your printer is connected and enter the appropriate URL. Examples:
  • LPD protocol:
  • Internet Printing Protocol
  • Forwarding the jobs to a Windows print server (Note: Vista and higher don't allow anonymous connects by default. You have to provide a username and password for the connection)
  • Enter a name for the printer
  • Choose "Raw" for the printer vendor and model
  • Save the the settings


This was the first widely used printing system and is still used on many servers. It is very simple to install and to configure. There are different implementations of LPD servers, such as the often used LPRng.

  • Add the following line to your "printcap" file (typically located in /etc/)
For the options used in the example above, check out the printcap man page.
  • Create the printers spool directory
# checkpc -f
  • Restart LPD
# service lpd restart
  • The following command allows you query the state of the printer:
 Queue: no printable jobs in queue

no entries

Configure Samba as print server

Enable spoolssd (optional)

Note: Some features of spoolssd were broken before 4.0.17 and 4.1.7. If you are considering using spoolssd, please use a later version!

spoolssd, a feature introduced in Samba 4.0, increases printer performance. In the past, when a print job came in, a smbd child process was forked, to initialize the printcap cache, spoolss, etc. If you have a huge printcap cache and it needs to be updated first, the client could hang for several seconds. Since Samba 4.0, you can configure spoolssd to be started as forked processes. If enabled, you'll see additional smbd processes, which will handle only spoolss requests. The master process is a simple daemon with a small memory footprint, that only forks and kills childrens serving the spoolss pipe. When a connection comes in, it can directly start to talk to the daemon and ask for information about the printer without any delay, this gives a performance improvement.

To enable spoolssd, add the following to the [global] section of your smb.conf:

rpc_server:spoolss = external
rpc_daemon:spoolssd = fork

After the next restart of Samba, you will discover additional smbd processes that handle spoolss requests:

With spoolssd enabled:                     With spoolssd disabled (default):
30903 smbd                                 30903 smbd
30912  \_ smbd                             30912  \_ smbd
30913      \_ smbd
30914      \_ smbd
30915      \_ smbd
30916      \_ smbd
30917      \_ smbd
30918      \_ smbd
30920      \_ smbd
30921      \_ smbd
30922      \_ smbd
30923      \_ smbd
30924      \_ smbd

You can adjust the daemons behaviour through the following parameters (the values in the examples are the defaults):

spoolssd:prefork_min_children = 5           # Minimum number of child processes
spoolssd:prefork_max_children = 25          # Maximum number of child processes
spoolssd:prefork_spawn_rate = 5             # Start (fork) x new children if one connection comes in (up to prefork_max_children)
spoolssd:prefork_max_allowed_clients = 100  # Number of clients, a child process should be responsible for
spoolssd:prefork_child_min_life = 60        # Minimum lifetime of a child process (60 seconds
                                            # is the minimum, even a lower value has been configured)

spoolssd is still a new feature. If you encounter any bug, please report it at, to get it fixed as soon as possible.

Setup the [printers] share

This share defines general information about your printing backend. See the "[printers]" section in the smb.conf man page for further information.

  • Add the [printers] section to your smb.conf
       path = /var/spool/samba/
       printable = yes
       printing = CUPS|LPRNG|...
  • Check for Samba CUPS support (only necessary, if "printing = CUPS")
# smbd -b | grep CUPS
If you don't get any output, make sure that the CUPS header files and libraries are installed and recompile Samba with --with-cups
  • Create the Samba spool directory, defined in the "[printer]" share.
# mkdir -p /var/spool/samba/
# chmod 1777 /var/spool/samba/

Share a printer

Unless "load printers = yes" was set in your smb.conf to automatically share all printers available in the backend, a separate share is required for each printer that should be shared by Samba:

       path = /var/spool/samba/
       printable = yes
       printer name = Printername_in_backend
       # Set the "printer name" parameter to the name of your
       # corresponding CUPS/LPD/... queue name

Reload Samba after configuration changes:

# smbcontrol all reload-config

Further documention