More Linux Server Topics - Network Diagram - About This Site

 

Chapter 16

Sharing Resources With Samba

 

= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

In This Chapter

Chapter 16

Sharing Resources With Samba

Adding A Printer To A Samba PDC

Creating Group Shares in SAMBA

Windows Drive Sharing With Your SAMBA Server

 

© Peter Harrison, www.linuxhomenetworking.com

 

= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

Now that you have Samba up and running, you may want to allow users to share resources such as floppy drives, directories and printers via the Samba server. Here’s how to do it all.

Adding A Printer To A Samba PDC

Sharing printers amongst all your PCs is one of the advantages of creating a home network. Here’s how to connect your printer directly to your PDC and make it available to all your windows workstations. This makes your Samba PDC a print server too!

The method explained here requires the Windows printer driver to be loaded on every client machine. This may be OK for a small home network but may be impractical for a huge corporate network.

Adding The Printer To Linux

By far the easiest way to add a printer in Linux is to use the GUI from the VGA console. The way to get a GUI on the console is outlined in the runlevels chapter. We’ll assume the printer is locally attached to the parallel port. Here are the menus to use:

o        Click on the RedHat icon in the bottom left hand corner of the screen

o        Click on System Settings

o        Click on Printing

o        Click on New


 

o        You'll now get the "Add a New Print Queue" menu

v      Click "forward" 

 

o        You'll get the "Set the Print Queue name and Type" menu 

v      Give the printer an easy to remember name. (My printer is an Epson Stylus C60, I called the printer queue EpsonC60)

v      Click the local printer button

v      Click "forward"

 

o        You'll get the "Configure a Local Printer" menu 

v      Select /dev/lp0 as I assume the printer is on the parallel port (not USB)

 

o        You'll get the "Select Print Driver" menu 

v      Scroll to the printer

v      Double click on the name

v      Select the driver

v      Click "forward"

 

o        You'll get the "Finish and Create the New Print Queue" menu 

v      Click finished

 

o        Click "Apply" 

v      Do a test print to make sure all is OK

Make Samba Aware Of The Printer 

The easiest way to do this is using the Samba SWAT web interface. Once you are in SWAT: 

o        Select the "Printers" button

o        Find your printer in the drag down menu

o        If the printer name has a [*] beside it, then it has been auto configured by Samba, but may not be visible on your network because Samba hasn't been restarted since creating the printer. If this is the case, restart Samba and go to the next section.

o        If this isn't the case, edit/create the printer

o        Click on the “Commit Changes” button to create an updated /etc/samba/smb.conf file.

o        Click on the “Status” tab at the top of the screen and restart smbd and nmbd to restart Samba.


 

Configure The Printer Driver On The Workstations

o        Download the Windows printer driver from the manufacturer and install it.

 

o        Go to the Add printer menu

v      Click the "Next" button

 

o        Select the "Network Printer" button to get the "Local or Network Printer" menu

v      Click the "Next" button

 

o        You should be on the "Locate Your Printer" menu

v      Don't enter a name, Click next so you can browse for your printer

 

o        You should be on the "Browse for Printer" menu 

v      Double Click on the name of your Linux Samba Box

v      You should see the new printer

v      Click on the printer name

v      Click the "Next" button

 

o        You may get a message stating "The server on which the printer resides does not have the correct printer driver installed. If you want to install the driver on your local computer, click OK". Fortunately, you pre installed the driver

v      Click the "OK" button

 

o        The "Add Printer Wizard" will appear

v      Select the manufacturer of your printer

v      Select the printer model

v      Click the "OK" button

 

o        The "Add Printer Wizard" will prompt you whether you want to use this new printer as the default printer.

v      Select "Yes" or "No" depending on your preference

v      Click the "Next" button

 

o        The "Completing the Add Printer Wizard" menu will appear

v      Click the "Finish" button

 

o        The new printer should now show up on the Windows Printers menu in "Control Panel"

 

o        Send a test print.

 

Creating Group Shares in SAMBA

On occasion, subgroups of a family need a share that is fully accessible by all members of the group. For example, parents working in a home office environment may need a place where they can share, distribute or collaboratively work on documents. Here’s how it’s done. 

Create The Directory And User Group

o        Create a new Linux group parents:

 

[root@bigboy tmp]# /usr/sbin/groupadd parents

 

o        Create a new directory for the group's files. If one user is designated as the leader, you might want to change the chown statement to make them owner

 

[root@bigboy tmp]# mkdir /home/parent-files
[root@bigboy tmp]# chown parents /home/parent-files
[root@bigboy tmp]# chmod 0770 /home/parent-files

 

o        Next we add the group members to the new group. For instance, let's add user "father" to the group.

 

[root@bigboy tmp]# /usr/sbin/usermod -G parents father

 

Configure The Share In SWAT

o        Finally, create the share in Samba using SWAT.

o        Click on the shares button then enter the name of the share you want to create, let’s say “only-parents”.

o        Click on the “Create Share” button. Make sure the path maps to “/home/parent-files” and make the valid users be @parents, where parents is the name of the Linux user group.

o        Click on the “Commit Changes” button to create a new /etc/samba/smb.conf file.

o        Click on the “Status” tab at the top of the screen and restart smbd and nmbd to restart Samba.


 

Your /etc/samba/smb.conf file should have an entry like this at the end:

 

# Parents Shared Area
[only-parents]

        path = /home/parent-files

        valid users = @parents

Map The Directory Using “My Computer”

o        Let the user log into the domain from a remote PC

o        Right click on the "My Computer" icon on the desktop

o        Click on "Map Network Drive"

o        Select a drive letter

o        Browse to the HOMENET domain, then the Samba server, then the share named only-parents

o        Click on the check box "Reconnect at Logon", to make the change permanent 

Windows Drive Sharing With Your SAMBA Server

You can also access a CD, DVD, ZIP, floppy or hard drive installed on a Windows Client from the Samba server.  In this section we’ll attempt to share a ZIP drive.

Windows Setup

The Windows client box should first be setup as a member of a Samba domain or workgroup. The next step is to make the ZIP drive shared.

Windows 98/ME

·         Double click 'My Computer'

·         Right click on the ZIP drive and choose 'Sharing'

·         Set the Share Name as 'zip' with the appropriate access control

·         Restart windows

Windows 2000

·         Double click 'My Computer'

·         Right click on the ZIP drive and choose 'Sharing'

·         Set the Share Name as 'zip' and the appropriate access control

·         Logout and login again as normal using your current login


 

Windows XP

·         Double click 'My Computer'

·         Right click on the ZIP drive and choose 'Sharing and Properties'

·         Set the Share Name as 'zip' and the appropriate access control

·         Logout and login again as normal using your current login

 

Test Your Windows Client Configuration

Use the smbclient command to test your share. You should substitute "WinClient" with the name of your widows client PC and "username" with a valid workgroup/domain username that normally has access to the Windows client. You should get output like this when using the username's corresponding password:

 

[root@bigboy tmp]# smbclient -L WinClient -U username

added interface ip=192.168.1.100 bcast=192.168.1.255 nmask=255.255.255.0
added interface ip=127.0.0.1 bcast=127.255.255.255 nmask=255.0.0.0
Got a positive name query response from 192.168.1.253 ( 192.168.1.253 )
Password:
Domain=[HOMENET] OS=[Windows 5.1] Server=[Windows 2000 LAN Manager]

Sharename Type Comment
--------- ---- -------
IPC$ IPC Remote IPC
D$ Disk Default share
print$ Disk Printer Drivers
SharedDocs Disk
zip Disk
Printer2 Printer Acrobat PDFWriter
ADMIN$ Disk Remote Admin
C$ Disk Default share


Server Comment
--------- -------

Workgroup Master
--------- -------
 

Note: You could have got the same result using the following command, though it is less secure:

 

[root@bigboy tmp]# smbclient -L WinClient -U username%password

 

Create A ZIP Drive Mount Point On Your Samba Server

You’ll need to create the mount point on the Linux server in order to mount and access the ZIP floppy. Here’s how to do it.

Prompted For Password Method

[root@bigboy tmp]# mkdir /mnt/zip

[root@bigboy tmp]# mount -t smbfs -o username=username //winclient/zip /mnt/zip

Not Prompted For Password Method

[root@bigboy tmp]# mkdir /mnt/zip

[root@bigboy tmp]# mount -t smbfs -o username=username,password=password //winclient/zip /mnt/zip

 

Using The smbmount Command Method

Some versions of Linux support the smbmount command to mount the remote drive. Incompatible versions will give errors like this: 

 

[root@bigboy tmp]# smbmount //winclient/zip /mnt/zip  -o username=username
Password:
27875: session setup failed: ERRDOS - ERRnoaccess (Access denied.)
SMB connection failed