Samba/Guide

Purpose
This HOWTO is designed to help you 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, happily coexisting environment.

Following the directions outlined in this HOWTO should give you an excellent step towards a peaceful cohabitation between Windows, and virtually all known variations of *nix.

This HOWTO originally started not as a HOWTO, but as a FAQ. It was intended to explore the functionality and power of the Gentoo system, portage and the flexibility of USE flags. Like so many other projects, it was quickly discovered what was missing in the Gentoo realm: there weren't any Samba HOWTOs catered for Gentoo users. These users are more demanding than most; they require performance, flexibility and customization. This does not however imply that this HOWTO was not intended for other distributions; rather that it was designed to work with a highly customized version of Samba.

This HOWTO will describe how to share files and printers between Windows PCs and *nix PCs. It will also show you how to mount and manipulate shares.

There are a few topics that will be mentioned, but are out of the scope of this HOWTO. These will be noted as they are presented.

This HOWTO 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 your reference:


 * HOWTO CUPS+Samba: printing from Windows & Linux

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

Brief Overview
After presenting the various USE flags, the following list will outline all of the topics covered as they are presented:


 * On the Samba server:
 * Install and configure Samba
 * Install and configure CUPS
 * Adding the printer to CUPS
 * Adding the PS drivers for the Windows clients


 * On the Unix clients:
 * Install and configure CUPS
 * Configuring a default printer
 * Mounting a Windows or Samba share


 * On the Windows Clients:
 * Configuring the printer
 * Accessing Samba shares

Requirements
We will need the following:


 * net-fs/samba
 * net-print/cups (built with the  USE flag)
 * net-print/hplip (if you have an HP printer)
 * A kernel of sorts (2.6)
 * A printer (PS or non-PS)
 * A working network (home/office/etc) consisting of more than one machine)

The main package we use here is, however, you will need a kernel with CIFS support enabled in order to mount a Samba or Windows share from another computer. CUPS will be emerged if it is not already.

The USE Flags
Before emerging anything, 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.

A couple of 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 HOWTO, you may find these links as helpful to your cause:
 * http://www.bluelightning.org/linux/samba_acl_howto/
 * http://www.wlug.org.nz/HowtoSamba3AndActiveDirectory

Emerging Samba
First of all: be sure that all your hostnames resolve correctly. Either have a working domain name system running on your network or appropriate entries in your file. often borks if hostnames don't point to the correct machines.

Hopefully now you can make an assessment of what you'll actually need in order to use Samba with your particular setup. The setup used for this HOWTO is:


 * cups
 * readline
 * pam

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

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

Now install the samba software:

This will emerge Samba and CUPS.

Emerging net-print/hplip
You only need to emerge this if you use an HP printer.

Configuring Samba
The main Samba configuration file is. It is divided in sections indicated by [sectionname]. Comments are either # or ;. A sample is included below with comments and suggestions for modifications. If more details are required, see the man page for, the installed  , the Samba Web site or any of the numerous Samba books available.

Now 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 so that Windows systems can be found easily using NetBIOS:

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

Edit 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 LinuxPrinting.Org to find and download the correct PPD file for your printer and CUPS. To do so, click the link Printer Listings to the left. Select your printers manufacturer and the model in the pulldown 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 ( argument) right (the name you set above during the Samba configuration!) and to put in the correct  ,   or whatever device you are using for your printer.

You should now be able to access the printer from the web interface and be able 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 doesn't 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 HOWTO uses the CUPS drivers for Windows. Install them as shown:

Now we'll use the script  provided by the CUPS distribution. Be sure to read its manpage, as it will tell you which Windows drivers you'll need to copy to the proper CUPS directory. Once you've copied the drivers, restart CUPS by running. Next, run  as shown:

Instead of HPDeskJet930C you could also specify "-a", which 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 doesn't 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 you should do is substitute   with   and try it again.
 * The command fails with an NT_STATUS_UNSUCCESSFUL . This error message is quite common, but can be triggered by many problems. It's unfortunately not very helpful. One thing to try is to temporarily set  in your  . 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 which you gave the printer when installing it (see above).

Pending no errors or other complications, your drivers are now installed.

Finalizing our setup
Lastly, setup our directories.

Testing our Samba configuration
We will want to test our configuration file to ensure that it is formatted properly and all of our options have at least the correct syntax. To do this we run.

Starting the Samba service
Now configure Samba to start at bootup; then go ahead and start it.

Checking our services
It would probably be prudent to check our logs at this time also. We will also want to take a peak at our Samba shares using.

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.

If you use only one printer, it will be your default printer. If your print server manages several printers, your administrator will have defined a default printer on the server. If you want to define a different default printer for yourself, use the  command.

First list the available printers:

Now define your 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):

Just point your web browser to  on the client if you want to manage your printers and their jobs with a nice web interface. Replace  with the name of the machine that acts as your print server, not the name you gave to the cups print server if you used different names.

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  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 you mount the share, you would be able to access it as if it were a local drive.

Printer Configuration for Windows NT/2000/XP clients
That's just 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 and now every application (such as Word or Acrobat) will offer HPDeskJet930C as an available printer to print to. :-)

Links
These are some links that may help you in setting up, configuration and troubleshooting your installation:


 * CUPS Homepage
 * Samba Homepage, especially the chapter on Samba/CUPS configuration
 * LinuxPrinting dot Org
 * 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. A really 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 first, before posting questions and problems! Maybe the solution you're looking for is right there.