Feb. 9, 2011, 10:14 p.m.
posted by lime
Disk Share Configuration
So far we have not defined the [data] share on our server. So the next step is to create the directory tree on disk that will be exported, as well as the share section in smb.conf to make it accessible to clients.
Samba requires that the directory path being shared actually exist in order for clients to connect it. Otherwise the client will receive an error message about a "bad network path." So if this is a new share with no preexisting files, we must create the path first. The second of the following commands sets the permissions to allow anyone to create files and directories, but the sticky bit prevents a user from deleting another user's files.
root# mkdir -p /export/smb/data root# chmod 1777 /export/smb/data
The service details in smb.conf resemble the [test] share we created in Chapter 2:
[data] path = /export/smb/data comment = Data Drive read only = no
The [data] share is typical for a Samba disk share. The share maps to the directory /export/smb/data on the Samba server. We've also provided a comment that describes the share as a Data Drive.
Samba's default is to create a read-only share. As a result, the read only option must be explicitly disabled for each disk share that is intended to be writable. Of course, we could define read only = no in the [global] section as the runtime default.
Now, if we connect to the PIGEON server again by double-clicking its icon in the Windows Network Neighborhood, we will see a single file share entitled data, as shown in Figure. This share has read/write access, so files can be copied to or from it.
The initial data share on PIGEON
Disk Share Configuration Options
Figure lists the basic Samba configuration options previously introduced for disk shares.
This option, which has the synonym directory, indicates the absolute pathname for the root of the shared directory or printer. You can choose any directory on the Samba server. If the connected user is unable to change to the directory due to a lack of appropriate permissions or because it does not exist, Samba refuses the user's connection request.
The comment option allows you to enter a free-form string that is transmitted to the client when it attempts to browse the share. A user can see the comment by using the Details view on the share folder or with the net view command at a Windows command prompt. For example, here is how you might insert a comment for a share:
[network] comment = Software installation drive (I:) path = /export/smb/software
Be sure not to confuse the comment option, which documents a Samba server's shares, with the global server string option, which documents the server itself.
This option allows you to specify the volume name of the share, which would otherwise default to the name of the share given in the smb.conf file.
Some software installation programs check the volume name of the distribution CD-ROM to make sure that the correct CD-ROM is in the drive before attempting to install from it. If you copy the contents of the CD-ROM into a network share and wish to install from there, you can use this option to make sure the installation program sees the correct volume name:
[software] comment = Software installation drive (I:) path = /export/smb/software volume = ASVP-102-RTYUIKA
read only, writable
The options read only and writable (also called writeable or write ok) are inverse Boolean options. Both default to enforcing read-only behavior on a file share but in a logically opposite fashion. If you want to be able to write data to a share, you must explicitly specify one of the following options in the configuration file for each share:
read only = no writable = yes
Samba treats both parameters as the same feature. If you specify more than one occurrence of either or both options, Samba adheres to the last value it encounters for the share.