Setting up Samba as a Print Server: Difference between revisions

From SambaWiki
m (Removed category)
m (Added categories)
Line 219: Line 219:

[[Category:Active Directory]]
[[Category:Domain Member]]
[[Category:NT4 Domains]]
[[Category:Standalone Server]]

Revision as of 21:12, 26 February 2017


If you set up Samba as a print server, clients in your network are able to send print jobs to the Samba host using the server message block (SMB) protocol. The examples shown in this documentation use a raw printer in the back end. This configuration requires that the print job is formatted by a driver on the client and thus can be processed by the printer without further processing or filtering.

Supported Print Server Back Ends

Samba supports the multiple print server back ends, such as CUPS and LPRng. For a complete list, see the printing parameter in the smb.conf(5) man page.

For details how to set up the back end, see the print server's documentation.

Samba CUPS or IPRINT Back End Support

When using the CUPS or IPRINT print server back end, Samba must have been built with CUPS support enabled. To verify, enter:

# smbd -b | grep "HAVE_CUPS"

If no output is displayed:

Adding a printer to the Print Server Back End


To add a raw printer to an CUPS print server:

  • Open the CUPS admin web interface in your browser. For example, https://servername:631/admin
  • Select the Administration tab and click Add Printer.
  • Select the connection type and enter the corresponding URL to the printer's queue or to the remote print server queue. For example:
  • LPD-based printers: lpd://printer_name/queue
  • IPP (Internet Printing Protocol)-based printers: ipp://printer_name/ipp/port
  • SMB (Server Message Block)-based printers: smb://username:password@domain/windows_print_server_host_name/printer_name
Note that forwarding a job to a print server running Windows Vista or newer, or Windows Server 2008 or newer requires authentication.
  • Enter a name for the printer. This name is used in the smb.conf when sharing the printer using Samba.
  • Select the Raw printer vendor and model.
  • Save the settings.


To add a raw printer to a LPRng print server:

  • Add the following line to the /etc/printcap file:
The printer name is used in the smb.conf when sharing the printer using Samba.
For further details about the options used, see the printcap(5) man page.
  • To create the spool directory, enter:
# checkpc -f
  • Restart the LPRng service.

Enabling the spoolssd Daemon

Optional. On a Samba print server that processes a high number of print jobs, you can enable the spoolssd daemon to increase the Samba performance. Without spoolssd, Samba forks the smbd process for each print job and initializes the printcap cache. In case of a large number of printers, the smbd process can become unresponsive for multiple seconds when initializing the printcap cache. The spoolssd daemon enables you to start pre-forked smbd processes that are processing print jobs without delay. The main spoolssd smbd process uses a low amount of memory, and forks and terminates child processes.

To enable spoolssd:

  • Add the following parameters to the [global] section of your smb.conf file:
rpc_server:spoolss = external
rpc_daemon:spoolssd = fork
  • Optionally, you can set the following parameters to fine-tune spoolssd
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             # Fork this number of new child processes, up to the value set in the spoolssd:prefork_max_children parameter,
                                            # if a new connection is established
spoolssd:prefork_max_allowed_clients = 100  # Number of clients, a child process is responsible for
spoolssd:prefork_child_min_life = 60        # Minimum lifetime of a child process (60 seconds minimum)
The values used in the previous example are the defaults.
  • Restart Samba.

After the restart, Samba automatically forks additional smbd processes. To verify, enter:

# ps axf
30903 smbd
30912  \_ smbd
30913      \_ smbd
30914      \_ smbd
30915      \_ smbd

Enabling the Print Server Support in Samba

To enable the print server support:

  • Add the following section to your smb.conf file:
       path = /var/spool/samba/
       printable = yes
       printing = print_server_back_end
  • Create the spool directory set in the path parameter:
# mkdir -p /var/spool/samba/
# chmod 1777 /var/spool/samba/
  • Reload Samba:
# smbcontrol all reload-config

Sharing a Printer

Automatic Sharing of All Printers Configured in the Print Server Back End

Using the default setting, all printers configured in the print server back end are automatically shared.

Disabling the Automatic Printer Sharing

To disable the automatic printer sharing:

  • Add the following parameter to the [global] section of your smb.conf file:
load printers = no
  • Reload Samba:
# smbcontrol all reload-config

Manual Sharing of Printers

To manually share a printer:

  • Add the share for the printer to your smb.conf file:
       path = /var/spool/samba/
       printable = yes
       printer name = printer_name_in_the_back_end
Set the printer name parameter to the name of the printer used in the local print server back end.
  • Reload Samba:
# smbcontrol all reload-config

Granting the SePrintOperatorPrivilege Privilege

Only users and groups having the SePrintOperatorPrivilege privilege granted can upload and preconfigure printer drivers.

To grant the privilege to the Domain Admins group, enter:

# net rpc rights grant "SAMDOM\Domain Admins" SePrintOperatorPrivilege -U "SAMDOM\administrator"
Enter SAMDOM\administrator's password:
Successfully granted rights.

To list all users and groups having the SePrintOperatorPrivilege privilege granted, enter:

# net rpc rights list privileges SePrintOperatorPrivilege -U "SAMDOM\administrator"
  SAMDOM\Domain Admins

Setting up Automatic Printer Driver Download for Windows Clients

See Setting up Automatic Printer Driver Downloads for Windows Clients.