Setting up Samba as a Print Server: Difference between revisions

From SambaWiki
(caveot for driver sharing in mixed 32/64 bit Windows client environments)
m (Add actual directions for fix)
 
(65 intermediate revisions by 10 users not shown)
Line 1: Line 1:
= Introduction =
==Overview==
Samba could no only act in the fileserver role. There is also the possibility to do the job as printserver for the windows clients.


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.
This seems to be well known, and nobody needs to any instruction because it is working :-)


When we take a closer lool to this role, it consists out of the following parts:


* printer share -> at the printingprocess the client copies the spoolfiles
* printserver software -> cups, lprng, lpr or something else. He delivers the spoolfiles to the printing devices. Maybe over the network or localy
* windows printer driver -> to use the 'point and print' functionality it makes sence to store the windows printer driver in a special share (print$) on the server. Inside of this driver also the default settings of the printer are stored.
* printer formular -> Every windows printout depends on the formular with his papersizes and so on. If a formular isn't know to the printserver the client could not use this although the printer was able to do it. Think about large formular or special paper like photos.
* something I have forgotten ...


==Printserver software / Using printers connected to the Samba server==
In most of the cases you want to use printers which are directly connected to the samba server. A printer can be connected via various hardware devices (i.e. parallel port, usb, scsi and so forth). But thats not all, you have to take care about the fact that two users can request a print job at the same time. To serve this, you need a software which controls the printer.
===CUPS===
CUPS is currently the most widely used spool system in Unix environments. Samba has built in support and defaults to CUPS if the develepment package (aka header files and libraries) could be found at compile time. The home of CUPS is [[http://www.cups.org]]. Basically all sorts of files can be printed with CUPS, but using a Postscript printer driver will give you the most benefit and the client can control the settings for the printers. A multi-purpose printer driver for Windows can be found at the Adobe site, see [[http://www.adobe.com/products/printerdrivers/main.html]]. The very big advantage of using Postscript as the printing language is that it doesn't matter whether your job has to be printed on a cheap inkjet or a big laser.


= Supported Print Server Back Ends =
====Using printers connected to another Samba or Windows server====
=====Using a printer connected to another Samba server=====
It is most likely that the other server is running CUPS to. So you only have to forward the print jobs to the other CUPS service. This is a simple to do in CUPS.


Samba supports the multiple print server back ends, such as [https://www.cups.org/ CUPS] and [http://www.lprng.com/ LPRng]. For a complete list, see the <code>printing</code> parameter in the <code>smb.conf(5)</code> man page.
=====Using a printer connected to a Windows server=====
You also can use CUPS for it. CUPS has the special backend smb://<server>/<printer>. This in turn calls the smbspool program which is part of the samba suite. So if you set up a printer connected to a Windows server, you set up a normal printer with a special PrinterURI.


{{Imbox
Note: the full form of that URI is: smb://[''<username>''[:''<password>'']@][''domain''/]''<server>''/''<printer>''
| type = note
| text = You must set up the printer server back end locally on the Samba host. Samba cannot forward print jobs to a remote host. However, you can configure the local printer server back end to forward the job to a remote print server.
}}


For details how to set up the back end, see the print server's documentation.
----
--[[User:Rcsu|rcsu]] 15:34, 15 April 2006 (CDT)
[[Category:Category Configuration]]




===LPD===
This is the first widely used printing system. It is very simple and doesnt use Postscript. But it is binary clean, so you can print to it directly via client side installed printer drivers.


== Samba <code>CUPS</code> or <code>IPRINT</code> Back End Support ==
==Providing Printer Drivers to Windows clients with the [print$] share==
to do a upload of the windows printer driver there must be done some steps.
# We need a user which is permited to do the job -> a printer admin windows call it 'Printer Operator'
# a share have to be prepaired an the printer admin need permission to read and write.


When using the <code>CUPS</code> or <code>IPRINT</code> print server back end, Samba must have been built with CUPS support enabled. To verify, enter:
===how to configure printer admin===


# smbd -b | grep "HAVE_CUPS"
since samba 3.0.20 the parameter is depricated and in the actuall version it isn't working anymore.
HAVE_CUPS


If no output is displayed:
so what is the commandline to get a printer admin?
* Samba was built using the <code>--disable-cups</code> parameter.
* The Samba <code>configure</code> script was unable to locate the required libraries for CUPS support. For details, see [[Package Dependencies Required to Build Samba]].


do the following command and the user or group will be printer admin:


net rpc rights grant "<domain|hostname\<user|group>" SePrintOperatorPrivilege -U <hostname>/root


example:
net rpc rights grant "cake\support" SePrintOperatorPrivilege -U cake/root


this mean the user support on machine is printeradmin by the user root on the hostname "cake"


= Adding a printer to the Print Server Back End =
===Directory structure in drivers directory===
The normal directory structure for your printer drivers looks like
<pre>drwxr-xr-x 2 root root 96 Feb 24 20:02 COLOR
drwxr-xr-x 2 root root 48 Feb 24 20:02 IA64
drwxr-xr-x 2 root root 48 Feb 24 20:02 W32ALPHA
drwxr-xr-x 2 root root 48 Feb 24 20:02 W32MIPS
drwxr-xr-x 2 root root 48 Feb 24 20:02 W32PPC
drwxr-xr-x 3 root root 72 Feb 24 20:02 W32X86
drwxr-xr-x 2 root root 48 Feb 24 20:02 WIN40
drwxr-xr-x 2 root root 48 Feb 24 20:02 x64
</pre>
You have to create it yourself. Here is a command line which does it. You only have to change the value of BASEDIR:
<pre>BASEDIR=/var/lib/samba/drivers;
for X in COLOR IA64 W32ALPHA W32MIPS W32PPC W32X86 WIN40 x64; do
mkdir -p $BASEDIR/$X;
done</pre>
===Create the share===
Please have a look at the smb.conf and change only the necessary lines (user,groups), most of the distributions are well prepaired.


== CUPS ==
<pre>[print$]
comment = Printer Drivers
path = /var/lib/samba/drivers
browseable = yes
guest ok = no
read only = yes
write list = root, chrisr
</pre>


===Uploading a printer driver (vendor drivers)===
To add a raw printer to an CUPS print server:
Do it like:
*http://www.samba.org/samba/docs/man/Samba-Guide/happy.html#id2582657


* Open the CUPS admin web interface in your browser. For example, <nowiki>https://servername:631/admin</nowiki>
Configuring point and print driver sharing in mixed 32/64 bit Windows client environments requires a differing procedure to the regular (32 bit only) add printer wizard usage:
* The 64bit driver must be uploaded using the "\\server\printers\ -> server properties" wizard. This wizard allows the uploading of printer drivers that differ in architecture to what is reported by the spoolss server (configurable in 3.6.3).
* A 32 bit driver with an identical name must also be uploaded to the server and associated with the printer, the regular add printer wizard can be used for this.


* Select the <code>Administration</code> tab and click <code>Add Printer</code>.
==Formular / Special settings on printer and faxes==
===Enabling new papersizes===
Only standardsizes of formulars are known. You have to add the neccessary sizes by hand.


* Select the connection type and enter the corresponding URL to the printer's queue or to the remote print server queue. For example:
# connect to the server \\<SambaServer>>
:* LPD-based printers: <code>lpd://''printer_name''/''queue''</code>
# printer -> Server Propertes -> Forms
:* IPP (Internet Printing Protocol)-based printers: <code>ipp://''printer_name''/ipp/port</code>
# Create new form
:* SMB (Server Message Block)-based printers: <code>smb://''username'':''password''@''domain''/''windows_print_server_host_name''/''printer_name''</code>
#:[[Image:SambaFormA0.png]]
:: Note that forwarding a job to a print server running Windows Vista or newer, or Windows Server 2008 or newer requires authentication.
#: A0 With 84,10 cm Height 118,90 cm
#:[[Image:SambaFormA1.png]]
#: A1 With 59,40 cm cm Height 84,10 cm
# After this steps the large papersizes a shown in the different dialogs


* Enter a name for the printer. This name is used in the <code>smb.conf</code> when sharing the printer using Samba.
The Size of the formulars depends on the ppds

* Select the <code>Raw</code> printer vendor and model.

* Save the settings.



== LPRng ==

To add a raw printer to a LPRng print server:

* Add the following line to the <code>/etc/printcap</code> file:

''printer_name'':sd=/var/spool/lpd/''printer_name''/:sh:mx=0:mc=0:rm=''Printer_DNS_name_or_IP_address''
: The printer name is used in the smb.conf when sharing the printer using Samba.
: For further details about the options used, see the <code>printcap(5)</code> man page.

* To create the spool directory, enter:

# checkpc -f

* Restart the LPRng service.





= Enabling the <code>spoolssd</code> Service =


{{Imbox
| type = warning
| text = This only applies to Samba version 4.15 and older versions!
}}


The Samba <code>spoolssd</code> is a service that is integrated into the smbd service. If you configured Samba as a print server, you can additionally enable <code>spoolssd</code> to increase performance on print servers with a high number of jobs or printers.
: Without <code>spoolssd</code>, Samba forks the <code>smbd</code> process or each print job and initializes the <code>printcap</code> cache. In case of a large number of printers, the <code>smbd</code> service can become unresponsive for multiple seconds when initializing the cache. The <code>spoolssd</code> service enables you to start pre-forked <code>smbd</code> processes that are processing print jobs without any delay. The main <code>spoolssd</code> <code>smbd</code> process uses a low amount of memory, and forks and terminates child processes

To enable the <code>spoolssd</code> service:

* Edit the <code>[global]</code> section in your <code>smb.conf</code> file:

:* Add the following parameters:

rpc_server:spoolss = external
rpc_daemon:spoolssd = fork

:* Optionally, you can set the following parameters:
::{| class="wikitable"
!Parameter
!Default
!Description
|-
|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
|Samba forks this number of new child processes, up to the value set in <code>spoolssd:prefork_max_children</code>, if a new connection is established
|-
|spoolssd:prefork_max_allowed_clients
|100
|Number of clients, a child process serves
|-
|spoolssd:prefork_child_min_life
|60
|Minimum lifetime of a child process in seconds. 60 seconds is the minimum.
|}

* Restart Samba.

After the restart, Samba automatically starts <code>smbd</code> sub-processes:
# ps axf
...
30903 smbd
30912 \_ smbd
30913 \_ smbd
30914 \_ smbd
30915 \_ smbd
...

= Tuning rpcd-spoolss =

{{Imbox
| type = note
| text = This applies to Samba 4.16 and newer versions!
}}


By default there is no dcerpc service running at all. You need to connect to a service in order to spawn the process.

If you connect the very first time, then the printers list is not filled up and you need some time till it collects all the information.

This can be time consuming as we need ~1s to get information for a printer from CUPS. If you have more than 50 printers you need to tune it.

Make sure that the idle seconds are bigger than the number of printers connected to CUPS!

[global]
rpcd_spoolss:idle_seconds=300

If it doesn't scale you can increase the number of workers (default=5):

[global]
rpcd_spoolss:num_workers = 10

= Enabling the Print Server Support in Samba =

To enable the print server support:

* Set the printing back end in the <code>printing</code> parameter of the <code>[global]</code> section in your <code>smb.conf</code> file. For example:
printing = CUPS

* Add the following section to your <code>smb.conf</code>:

[printers]
path = /var/tmp/
printable = yes

* 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 <code>[global]</code> section of your <code>smb.conf</code> file:

load printers = no

* Reload Samba:

# smbcontrol all reload-config



== Manual Sharing of Printers ==

To manually share a printer:

* Verify that the automatic printer sharing is disabled. See [[#Disabling_the_Automatic_Printer_Sharing|Disabling the Automatic Printer Sharing]].

* Add the share for the printer to your <code>smb.conf</code> file:

[''Samba_printer_name'']
path = /var/tmp/
printable = yes
printer name = ''printer_name_in_the_back_end''

: Set the <code>printer name</code> parameter to the name of the printer used in the local print server back end.

* Reload Samba:

# smbcontrol all reload-config





= Setting up Automatic Printer Driver Download for Windows Clients =

See [[Setting_up_Automatic_Printer_Driver_Downloads_for_Windows_Clients|Setting up Automatic Printer Driver Downloads for Windows Clients]].

= Known issues =

There seems to be an issue with printing after updating Windows 11 to 22H2. Please see [https://winaero.com/windows-11-22h2-users-suffer-from-printing-issues/ this] website for more info.

The solution is to edit a Group Policy Object at the computer level under Administrative Templates \ Printers \ Configure RPC connection settings.

* Set this to "Enabled"
* Protocol to use for outgoing RPC connections: `RPC over named pipes`
* Use authentication for outgoing RPC connections: `Default`

If you do not see the settings here, then make sure you either download the Windows 22H2 or later Group Policy Objects from Microsoft's website, or launch the Group Policy Management Console from a computer running Windows 11 22H2 or later.

----
[[Category:Active Directory]]
[[Category:Domain Members]]
[[Category:NT4 Domains]]
[[Category:Printing]]
[[Category:Standalone Server]]

Latest revision as of 21:30, 25 July 2023

Introduction

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"
   HAVE_CUPS

If no output is displayed:



Adding a printer to the Print Server Back End

CUPS

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.


LPRng

To add a raw printer to a LPRng print server:

  • Add the following line to the /etc/printcap file:
printer_name:sd=/var/spool/lpd/printer_name/:sh:mx=0:mc=0:rm=Printer_DNS_name_or_IP_address
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 Service


The Samba spoolssd is a service that is integrated into the smbd service. If you configured Samba as a print server, you can additionally enable spoolssd to increase performance on print servers with a high number of jobs or printers.

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

To enable the spoolssd service:

  • Edit the [global] section in your smb.conf file:
  • Add the following parameters:
rpc_server:spoolss = external
rpc_daemon:spoolssd = fork
  • Optionally, you can set the following parameters:
Parameter Default Description
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 Samba forks this number of new child processes, up to the value set in spoolssd:prefork_max_children, if a new connection is established
spoolssd:prefork_max_allowed_clients 100 Number of clients, a child process serves
spoolssd:prefork_child_min_life 60 Minimum lifetime of a child process in seconds. 60 seconds is the minimum.
  • Restart Samba.

After the restart, Samba automatically starts smbd sub-processes:

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

Tuning rpcd-spoolss


By default there is no dcerpc service running at all. You need to connect to a service in order to spawn the process.

If you connect the very first time, then the printers list is not filled up and you need some time till it collects all the information.

This can be time consuming as we need ~1s to get information for a printer from CUPS. If you have more than 50 printers you need to tune it.

Make sure that the idle seconds are bigger than the number of printers connected to CUPS!

 [global]
   rpcd_spoolss:idle_seconds=300

If it doesn't scale you can increase the number of workers (default=5):

 [global]
   rpcd_spoolss:num_workers = 10

Enabling the Print Server Support in Samba

To enable the print server support:

  • Set the printing back end in the printing parameter of the [global] section in your smb.conf file. For example:
printing = CUPS
  • Add the following section to your smb.conf:
[printers]
       path = /var/tmp/
       printable = yes
  • 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:
[Samba_printer_name]
       path = /var/tmp/
       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



Setting up Automatic Printer Driver Download for Windows Clients

See Setting up Automatic Printer Driver Downloads for Windows Clients.

Known issues

There seems to be an issue with printing after updating Windows 11 to 22H2. Please see this website for more info.

The solution is to edit a Group Policy Object at the computer level under Administrative Templates \ Printers \ Configure RPC connection settings.

  • Set this to "Enabled"
  • Protocol to use for outgoing RPC connections: `RPC over named pipes`
  • Use authentication for outgoing RPC connections: `Default`

If you do not see the settings here, then make sure you either download the Windows 22H2 or later Group Policy Objects from Microsoft's website, or launch the Group Policy Management Console from a computer running Windows 11 22H2 or later.