Samba/Guide

Purpose
This configuration article is designed to help the reader move a network from many different clients speaking different languages, to many different machines that speak a common language. The ultimate goal is to help differing architectures and technologies, come together in a productive, happy coexisting environment.

Following the directions outlined in this article should provide an excellent step towards a peaceful cohabitation between Windows operating systems and virtually all known variations of *nix.

This article originally started as a FAQ, morphed into a HOWTO document, then was converted into a wiki article. The original intent was to explore the functionality and power of Gentoo, Portage, and the flexibility of USE flags. Like so many other projects, it was quickly discovered what was missing in the Gentoo realm: there were not any Samba guides catered for Gentoo users. Gentoo users are more demanding than most; they require performance, flexibility and customization. This does not however imply that this article was not intended for other distributions; rather that it was designed to work with a highly customized version of Samba.

This article will describe how to share files and printers between Windows and *nix PCs. It will cover how to mount and manipulate shares.

In addition to shares few other topics will be mentioned, but they are out of the scope of this article. These will be noted as they are presented.

This article is based on a compilation and merge of an excellent HOWTO provided in the Gentoo forums by Andreas "daff" Ntaflos and the collected knowledge of Joshua Preston. The link to this discussion is provided below for reference purposes:


 * HOWTO CUPS+Samba: printing from Windows & Linux

Before using this guide
There are a several other guides for setting up CUPS and/or Samba, please read them as well, as they may provide instructions concerning things left out of this article (intentional or otherwise). One such document is the very useful and well written Gentoo Printing Guide, as configuration issues and specific printer setup will not be discussed here.

Requirements
The following software will be needed:


 * (if an HP printer will be used)
 * A kernel (2.6 and up)
 * A printer (PS or non-PS)
 * A working network consisting of more than one machine
 * A printer (PS or non-PS)
 * A working network consisting of more than one machine

The main package used here is, however, a kernel with CIFS support enabled is needed in order to mount a Samba or Windows share from another computer. CUPS will be emerged if it has not been already installed.

The USE Flags
Before anything is emerging, take a look at some of the various USE flags available to Samba. Depending on the network topology and the specific requirements of the server, the USE flags outlined below will define what to include or exclude from the emerging of Samba.

Some things worth mentioning about the USE flags and different Samba functions include:


 * ACLs on ext2/3 are implemented through extended attributes (EAs). EA and ACL kernel options for ext2 and/or ext3 will need to be enabled (depending on which file system is being used - both can be enabled).
 * While Active Directory, ACL, and PDC functions are out of the intended scope of this article, the following links may be helpful:
 * http://www.bluelightning.org/linux/samba_acl_howto/
 * http://www.wlug.org.nz/HowtoSamba3AndActiveDirectory
 * Please remove existing "test" USE flags as that would cause problem:
 * https://bugs.gentoo.org/674468

Emerging Samba
To start things correctly, be sure that all hostnames resolve correctly. Either have a working domain name system running on the network or appropriate entries in the file. Certain things could break if hostnames do not point to the correct machines.

Hopefully an assessment can be made of what will actually be need in order to use Samba with the a particular setup. The setup used for this article is:


 * cups
 * readline
 * pam

To optimize performance, size, and the time of the build, USE flags are specifically included or excluded.

First, add USE flags to make sure that when samba is built, it has proper support:

Now install the Samba software:

This will emerge Samba and CUPS.

HP printers
The following package should be emerged if an HP printer will be used:

Configuring Samba
The main Samba configuration file is located at and can be modified using a standard text editor. Root permissions must be obtained to open the file. It is divided in sections indicated by. Comments are defined by either  (hash tags) or   (semicolons). A sample file is included below with comments and suggestions for modifications. If more details are required, see the man page for ( man smb.conf, the installed , the Samba website, or any of the numerous Samba books available at local libraries or for purchase where ever such books are sold.

Create the directories required for the minimum configuration of Samba to share the installed printer throughout the network:

At least one Samba user is required in order to install the printer drivers and to allow users to connect to the printer. Users must exist in the system's file. The next example uses the root user, but others can be used as well.

The Samba passwords need not be the same as the system passwords in

You will also need to update the file so that Windows systems can be found easily using NetBIOS:

Configuring CUPS
This section is a little more complicated. CUPS' main configuration file is Its structure is similar to Apache's  file, so many may find it familiar. Outlined in the example are the directives that need to be changed:

Edit file to uncomment some lines. The changes to and  are needed to make CUPS print Microsoft Office document files.

The following line is found near the end of the file. Uncomment it:

Edit to uncomment some lines.

The following line is found near the end of the file. Uncomment it:

CUPS needs to be started on boot, and started immediately.

Installing a printer for and with CUPS
First, go to OpenPrinting to find and download the correct PPD file for the printer and CUPS. To do so, click the link Printer Listings to the left. Select the printers manufacturer and the model in the pull down menu, e.g. HP and DeskJet 930C. Click "Show". On the page coming up click the "recommended driver" link after reading the various notes and information. Then fetch the PPD file from the next page, again after reading the notes and introductions there. You may have to select your printers manufacturer and model again. Reading the CUPS quickstart guide is also very helpful when working with CUPS.

Now you have a PPD file for your printer to work with CUPS. Place it in. The PPD for the HP DeskJet 930C was named. You should now install the printer. This can be done via the CUPS web interface or via command line. The web interface is found at once CUPS is running.

Remember to adjust to what you have. Be sure to have the name ( option) right (the name you set above during the Samba configuration!) and to put in the correct  ,   or whatever device you are using for the printer.

The printer should now be available from the web interface and to print a test page.

Installing the Windows printer drivers
Now that the printer should be working it is time to install the drivers for the Windows clients to work. Samba 2.2 introduced this functionality. Browsing to the print server in the Network Neighbourhood, right-clicking on the printer share and selecting "connect" downloads the appropriate drivers automatically to the connecting client, avoiding the hassle of manually installing printer drivers locally.

There are two sets of printer drivers for this. First, the Adobe PS drivers which can be obtained from Adobe (PostScript printer drivers). Second, there are the CUPS PS drivers, to be obtained by emerging. There does not seem to be a difference between the functionality of the two, but the Adobe PS drivers need to be extracted on a Windows System since it's a Windows binary. Also the whole procedure of finding and copying the correct files is a bit more hassle. The CUPS drivers support some options the Adobe drivers don't.

This article uses the CUPS drivers for Windows. Install them as shown:

Now use the script provided by the CUPS distribution. Be sure to read its man page ( man cupsaddsmb ), as it will tell which Windows drivers are needed to be copied to the proper CUPS directory. Once the drivers have been copied, restart CUPS by issuing to the command line. Next, run as shown:

Instead of HPDeskJet930C the  option use be specified. This will "export all known printers":

Here are common errors that may happen:


 * The hostname given as a parameter for  and    often does not resolve correctly and does not identify the print server for CUPS/Samba interaction. If an error like: Warning: No PPD file for printer "CUPS_PRINTER_NAME" - skipping! occurs, the first thing to do is substitute   with   and try again.
 * The command fails with an NT_STATUS_UNSUCCESSFUL error. This error message is quite common, but can be triggered by many problems. It is unfortunately not very helpful. One thing to try is to temporarily set  in the  After/if the installation completes successfully, you should set it back to share, or whatever it was set to before.

This should install the correct driver directory structure under. That would be The files contained should be the 3 driver files and the PPD file, renamed to  (the name given to the printer when installing it, see above).

Pending no errors or other complications drivers will now be installed.

wsdd
wsdd implements a Web Service Discovery host daemon. This enables (Samba) hosts, like your local NAS device, to be found by Web Service Discovery Clients like Windows.



Purpose
Since NetBIOS discovery is not supported by Windows anymore, wsdd makes hosts to appear in Windows again using the Web Service Discovery method. This is beneficial for devices running Samba, like NAS or file sharing servers on your local network.

Background
With Windows 10 version 1511, support for SMBv1 and thus NetBIOS device discovery was disabled by default. Depending on the actual edition, later versions of Windows starting from version 1709 ("Fall Creators Update") do not allow the installation of the SMBv1 client anymore. This causes hosts running Samba not to be listed in the Explorer's "Network (Neighborhood)" views. While there is no connectivity problem and Samba will still run fine, users might want to have their Samba hosts to be listed by Windows automatically.

Installing
wsdd does not yet exist in the Portage tree but the author of wsdd has provided an ebuild available at https://github.com/christgau/wsdd-gentoo

For information on how to add a custom ebuild to your local Portage overlay see the Wiki https://wiki.gentoo.org/wiki/Custom_repository

Finalizing the setup
Lastly, setup the directories:

Testing the Samba configuration
Test the configuration file to ensure that it is formatted properly and to verify all options have the correct syntax. To do this, run the program:

Starting the Samba service
Now configure Samba to start at boot and then start it:


 * OpenRC


 * systemd

Checking the services
It might be prudent to check out logs at this time. Take a peak at the Samba shares using the smbclient command:

Printer configuration of *nix based clients
Despite the variation or distribution, the only thing needed is CUPS. Do the equivalent on any other UNIX/Linux/BSD client.

That should be it. Nothing else will be needed.

When using only one printer, it will be set as the default printer. If the print server manages several printers, the administrator will have defined a default printer on the server. If a user would like to define a different default printer, use the lpoptions command.

First list the available printers:

Now define the printer (in the example, HPDeskJet930C) as the default printer:

To enable printing on the Unix/Linux systems, either specify the printer to be used, or just use the default printer (second example):

Point a web browser to  on the client to manage the printers and their jobs via a nice web interface. Replace  with the name of the machine which acts as the print server. Be careful to not use the name given to the cups print server if a different name was used.

Mounting a Windows or Samba share in GNU/Linux
Now is time to configure our kernel to support CIFS. Since I'm assuming we've all compiled at least one kernel, we'll need to make sure we have all the right options selected in our kernel. For simplicity's sake, make it a module for ease of use. It is the author's opinion that kernel modules are a good thing and should be used whenever possible.

Then make the module/install it; insert it with:

Once the module is loaded, mounting a Windows or Samba share is possible. Use mount to accomplish this, as detailed below.

The syntax for mounting a Windows/Samba share is:

You can drop the  and   options if no password is needed.

After mounting the share, it can be accessed as if it were a local drive.

Printer configuration for Windows NT/2000/XP clients
Configuring printers is simply a bit of point-and-click. Browse to and right click on the printer (HPDeskJet930C) and click connect. This will download the drivers to the Windows client which will enable applications (such as Word or Acrobat) to offer HPDeskJet930C as an available printer.

Access for Windows XP Clients
The Samba server smb.conf requires at least the following for enabling access from Windows XP clients.

Modify the Windows XP registery with the following, exporting/saving the original default first:

Change LMCompatibilityLevel=0 to LMCompatibilityLevel=5

Restart the Samba server and Windows XP client.

Debugging Samba Server Access
Can view more Samba server debug info by adding the following to the /etc/smb.conf and restarting the Samba server:

External resources

 * CUPS Homepage
 * Samba Homepage, especially the chapter on Samba/CUPS configuration
 * OpenPrinting
 * Kurt Pfeifle's Samba Print HOWTO ( This HOWTO really covers ANYTHING and EVERYTHING I've written here, plus a LOT more concerning CUPS and Samba, and generally printing support on networks. An interesting read with lots and lots of details.)
 * FreeBSD Diary's CUPS Topic

Troubleshooting
See this page from Kurt Pfeifle's "Printing Support in Samba 3.0" manual. Lots of useful tips there! Be sure to look this one up before posting questions and problems. Using this resource the solution may be quickly found.