1<HTML> 2<HEAD> 3<TITLE> 4[Chapter 4] 4.5 Disk Share Configuration</title><META NAME="DC.title" CONTENT=""><META NAME="DC.creator" CONTENT=""><META NAME="DC.publisher" CONTENT="O'Reilly & Associates, Inc."><META NAME="DC.date" CONTENT="1999-11-05T21:32:13Z"><META NAME="DC.type" CONTENT="Text.Monograph"><META NAME="DC.format" CONTENT="text/html" SCHEME="MIME"><META NAME="DC.source" CONTENT="" SCHEME="ISBN"><META NAME="DC.language" CONTENT="en-US"><META NAME="generator" CONTENT="Jade 1.1/O'Reilly DocBook 3.0 to HTML 4.0"></head> 5<BODY BGCOLOR="#FFFFFF" TEXT="#000000" link="#990000" vlink="#0000CC"> 6<table BORDER="0" CELLPADDING="0" CELLSPACING="0" width="90%"> 7<tr> 8<td width="25%" valign="TOP"> 9<img hspace=10 vspace=10 src="gifs/samba.s.gif" 10alt="Using Samba" align=left valign=top border=0> 11</td> 12<td height="105" valign="TOP"> 13<br> 14<H2>Using Samba</H2> 15<font size="-1"> 16Robert Eckstein, David Collier-Brown, Peter Kelly 17<br>1st Edition November 1999 18<br>1-56592-449-5, Order Number: 4495 19<br>416 pages, $34.95 20</font> 21<p> <a href="http://www.oreilly.com/catalog/samba/">Buy the hardcopy</a> 22<p><a href="index.html">Table of Contents</a> 23</td> 24</tr> 25</table> 26<hr size=1 noshade> 27<!--sample chapter begins --> 28 29<center> 30<DIV CLASS="htmlnav"> 31<TABLE WIDTH="515" BORDER="0" CELLSPACING="0" CELLPADDING="0"> 32<TR> 33<TD ALIGN="LEFT" VALIGN="TOP" WIDTH="172"> 34<A CLASS="sect1" HREF="ch04_04.html" TITLE="4.4 Server Configuration"> 35<IMG SRC="gifs/txtpreva.gif" ALT="Previous: 4.4 Server Configuration" BORDER="0"></a></td><TD ALIGN="CENTER" VALIGN="TOP" WIDTH="171"> 36<B> 37<FONT FACE="ARIEL,HELVETICA,HELV,SANSERIF" SIZE="-1"> 38<A CLASS="chapter" REL="up" HREF="ch04_01.html" TITLE="4. Disk Shares "> 39Chapter 4<br> 40Disk Shares </a></font></b></td><TD ALIGN="RIGHT" VALIGN="TOP" WIDTH="172"> 41<A CLASS="sect1" HREF="ch04_06.html" TITLE="4.6 Networking Options with Samba"> 42<IMG SRC="gifs/txtnexta.gif" ALT="Next: 4.6 Networking Options with Samba" BORDER="0"></a></td></tr></table> <hr noshade size=1></center> 43</div> 44<blockquote> 45<div> 46<H2 CLASS="sect1"> 47<A CLASS="title" NAME="ch04-14274"> 484.5 Disk Share Configuration</a></h2><P CLASS="para">We mentioned in the previous section that there were no disk shares on the <CODE CLASS="literal"> 49hydra</code> server. Let's continue with the configuration file and create an empty disk share called [<CODE CLASS="literal">data</code>]. Here are the additions that will do it:</p><PRE CLASS="programlisting"> 50[global] 51 netbios name = HYDRA 52 server string = Samba %v on (%L) 53 workgroup = SIMPLE 54 55[data] 56 path = /export/samba/data 57 comment = Data Drive 58 volume = Sample-Data-Drive 59 writeable = yes 60 guest ok = yes</pre><P CLASS="para"> 61The <CODE CLASS="literal"> 62[data]</code> share is typical for a Samba disk share. The share maps to a directory on the Samba server: <I CLASS="filename"> 63/export/samba/data</i>. We've also provided a comment that describes the share as a <CODE CLASS="literal"> 64Data</code> <CODE CLASS="literal"> 65Drive</code>, as well as a volume name for the share itself.</p><P CLASS="para"> 66The share is set to writeable so that users can write data to it; the default with Samba is to create a read-only share. As a result, this option needs to be explicitly set for each disk share you wish to make writeable.</p><P CLASS="para"> 67You may have noticed that we set the <CODE CLASS="literal"> 68guest</code> <CODE CLASS="literal"> 69ok</code> parameter to <CODE CLASS="literal"> 70yes</code>. While this isn't very security-conscious, there are some password issues that we need to understand before setting up individual users and authentication. For the moment, this will sidestep those issues and let anyone connect to the share.</p><P CLASS="para"> 71Go ahead and make these additions to your configuration file. In addition, create the <I CLASS="filename"> 72/export/samba/data</i> directory as root on your Samba machine with the following commands:</p><PRE CLASS="programlisting"><B CLASS="emphasis.bold"><CODE CLASS="literal">#</code> mkdir /export/samba/data</b><B CLASS="emphasis.bold"> 73<CODE CLASS="literal"># </code>chmod 777 /export/samba/data</b></pre><P CLASS="para"> 74Now, if you connect to the <CODE CLASS="literal"> 75hydra</code> server again (you can do this by clicking on its icon in the Windows Network Neighborhood), you should see a single share listed entitled <CODE CLASS="literal"> 76data</code>, as shown in <A CLASS="xref" HREF="ch04_05.html#ch04-13866"> 77Figure 4.4</a>. This share should also have read/write access to it. Try creating or copying a file into the share. Or, if you're really feeling adventurous, you can even try mapping a network drive to it! </p><H4 CLASS="figure"> 78<A CLASS="title" NAME="ch04-13866"> 79Figure 4.4: The initial data share on the Samba server</a></h4><IMG CLASS="graphic" SRC="figs/sam.0404.gif" ALT="Figure 4.4"><DIV CLASS="sect2"> 80<H3 CLASS="sect2"> 81<A CLASS="title" NAME="ch04-pgfId-961433"> 824.5.1 Disk Share Configuration Options</a></h3><P CLASS="para">The basic Samba configuration options for disk shares previously introduced are listed in <A CLASS="xref" HREF="ch04_05.html#ch04-82964"> 83Table 4.4</a>. </p><br> 84<TABLE CLASS="table" BORDER="1" CELLPADDING="3"> 85<CAPTION CLASS="table"> 86<A CLASS="title" NAME="ch04-82964"> 87Table 4.4: Basic Share Configuration Options </a></caption><THEAD CLASS="thead"> 88<TR CLASS="row" VALIGN="TOP"> 89<TH CLASS="entry" ALIGN="LEFT" ROWSPAN="1" COLSPAN="1"> 90<P CLASS="para"> 91Option</p></th><TH CLASS="entry" ALIGN="LEFT" ROWSPAN="1" COLSPAN="1"> 92<P CLASS="para"> 93Parameters</p></th><TH CLASS="entry" ALIGN="LEFT" ROWSPAN="1" COLSPAN="1"> 94<P CLASS="para"> 95Function</p></th><TH CLASS="entry" ALIGN="LEFT" ROWSPAN="1" COLSPAN="1"> 96<P CLASS="para"> 97Default</p></th><TH CLASS="entry" ALIGN="LEFT" ROWSPAN="1" COLSPAN="1"> 98<P CLASS="para"> 99Scope</p></th></tr></thead><TBODY CLASS="tbody"> 100<TR CLASS="row" VALIGN="TOP"> 101<TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 102<P CLASS="para"> 103<CODE CLASS="literal"> 104path (directory)</code></p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 105<P CLASS="para"> 106string (fully-qualified pathname)</p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 107<P CLASS="para"> 108Sets the Unix directory that will be provided for a disk share or used for spooling by a printer share</p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 109<P CLASS="para"> 110<CODE CLASS="literal"> 111/tmp</code></p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 112<P CLASS="para"> 113Share</p></td></tr><TR CLASS="row" VALIGN="TOP"> 114<TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 115<P CLASS="para"> 116<CODE CLASS="literal"> 117guest ok (public)</code></p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 118<P CLASS="para"> 119boolean</p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 120<P CLASS="para"> 121If set to <CODE CLASS="literal"> 122yes</code>, authentication is not needed to access this share</p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 123<P CLASS="para"> 124<CODE CLASS="literal"> 125no</code></p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 126<P CLASS="para"> 127Share</p></td></tr><TR CLASS="row" VALIGN="TOP"> 128<TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 129<P CLASS="para"> 130<CODE CLASS="literal"> 131comment</code></p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 132<P CLASS="para"> 133string</p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 134<P CLASS="para"> 135Sets the comment that appears with the share</p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 136<P CLASS="para"> 137None</p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 138<P CLASS="para"> 139Share</p></td></tr><TR CLASS="row" VALIGN="TOP"> 140<TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 141<P CLASS="para"> 142<CODE CLASS="literal"> 143volume</code></p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 144<P CLASS="para"> 145string</p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 146<P CLASS="para"> 147Sets the volume name: the DOS name of the physical drive</p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 148<P CLASS="para"> 149Share name</p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 150<P CLASS="para"> 151Share</p></td></tr><TR CLASS="row" VALIGN="TOP"> 152<TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 153<P CLASS="para"> 154<CODE CLASS="literal"> 155read only</code></p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 156<P CLASS="para"> 157boolean</p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 158<P CLASS="para"> 159If <CODE CLASS="literal"> 160yes</code>, allows read only access to a share.</p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 161<P CLASS="para"> 162<CODE CLASS="literal"> 163yes</code></p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 164<P CLASS="para"> 165Share</p></td></tr><TR CLASS="row" VALIGN="TOP"> 166<TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 167<P CLASS="para"> 168<CODE CLASS="literal"> 169writeable (write ok)</code></p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 170<P CLASS="para"> 171boolean</p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 172<P CLASS="para"> 173If <CODE CLASS="literal"> 174no</code>, allows read only access to a share.</p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 175<P CLASS="para"> 176<CODE CLASS="literal"> 177no</code></p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 178<P CLASS="para"> 179Share</p></td></tr></tbody></table><DIV CLASS="sect3"> 180<H4 CLASS="sect3"> 181<A CLASS="title" NAME="ch04-pgfId-959473"> 1824.5.1.1 path</a></h4><P CLASS="para">This option, which has the synonym <CODE CLASS="literal"> 183directory</code>, indicates the pathname at the root of the file or printing share. You can choose any path on the Samba server, so long as the owner of the Samba process that is connecting has read and write access to that directory. If the path is for a printing share, it should point to a temporary directory where files can be written on the server before being spooled to the target printer (<I CLASS="filename">/tmp</i> and <I CLASS="filename"> 184/var/spool</i> are popular choices). If this path is for a disk share, the contents of the folder representing the share name on the client will match the content of the directory on the Samba server. For example, if we have the following disk share listed in our configuration file:</p><PRE CLASS="programlisting"> 185[network] 186 path = /export/samba/network 187 writable = yes 188<CODE CLASS="literal"> 189 guest ok = yes</code></pre><P CLASS="para"> 190And the contents of the directory <I CLASS="filename"> 191/usr/local/network</i> on the Unix side are:</p><PRE CLASS="programlisting"><B CLASS="emphasis.bold"><CODE CLASS="literal">$</code> ls -al /export/samba/network</b> 192</pre><PRE CLASS="programlisting"> 193drwxrwxrwx 9 root nobody 1024 Feb 16 17:17 . 194drwxr-xr-x 9 nobody nobody 1024 Feb 16 17:17 .. 195drwxr-xr-x 9 nobody nobody 1024 Feb 16 17:17 quicken 196drwxr-xr-x 9 nobody nobody 1024 Feb 16 17:17 tax98 197drwxr-xr-x 9 nobody nobody 1024 Feb 16 17:17 taxdocuments</pre><P CLASS="para"> 198Then we should see the equivalent of <A CLASS="xref" HREF="ch04_05.html#ch04-88746"> 199Figure 4.5</a> on the client side. </p><H4 CLASS="figure"> 200<A CLASS="title" NAME="ch04-88746"> 201Figure 4.5: Windows client view of a network filesystem specified by path</a></h4><IMG CLASS="graphic" SRC="figs/sam.0405.gif" ALT="Figure 4.5"></div><DIV CLASS="sect3"> 202<H4 CLASS="sect3"> 203<A CLASS="title" NAME="ch04-pgfId-943587"> 2044.5.1.2 guest ok</a></h4><P CLASS="para"> 205This option (which has an older synonym <CODE CLASS="literal"> 206public</code>) allows or prohibits guest access to a share. The default value is <CODE CLASS="literal"> 207no</code>. If set to <CODE CLASS="literal"> 208yes</code>, it means that no username or password will be needed to connect to the share. When a user connects, the access rights will be equivalent to the designated guest user. The default account to which Samba offers the share is <CODE CLASS="literal"> 209nobody</code>. However, this can be reset with the <CODE CLASS="literal"> 210guest</code> <CODE CLASS="literal"> 211account</code> configuration option. For example, the following lines allow guest user access to the <CODE CLASS="literal"> 212[accounting]</code> share with the permissions of the <EM CLASS="emphasis"> 213ftp</em> account:</p><PRE CLASS="programlisting"> 214[global] 215 guest account = ftp 216[accounting] 217 path = /usr/local/account 218 guest ok = yes</pre><P CLASS="para"> 219Note that users can still connect to the share using a valid username/password combination. If successful, they will hold the access rights granted by their own account and not the guest account. If a user attempts to log in and fails, however, he or she will default to the access rights of the guest account. You can mandate that every user who attaches to the share will be using the guest account (and will have the permissions of the guest) by setting the option <CODE CLASS="literal"> 220guest</code> <CODE CLASS="literal"> 221only</code> <CODE CLASS="literal"> 222=</code> <CODE CLASS="literal"> 223yes</code>.</p></div><DIV CLASS="sect3"> 224<H4 CLASS="sect3"> 225<A CLASS="title" NAME="ch04-pgfId-943593"> 2264.5.1.3 comment</a></h4><P CLASS="para"> 227The <CODE CLASS="literal"> 228comment</code> option allows you to enter a comment that will be sent to the client when it attempts to browse the share. The user can see the comment by listing Details on the share folder under the appropriate computer in the Windows Network Neighborhood, or type the command <CODE CLASS="literal"> 229NET</code> <CODE CLASS="literal"> 230VIEW</code> at an MS-DOS prompt. For example, here is how you might insert a comment for a <CODE CLASS="literal"> 231[network]</code> share:</p><PRE CLASS="programlisting"> 232[network] 233 comment = Network Drive 234 path = /export/samba/network</pre><P CLASS="para"> 235This yields a folder similar to <A CLASS="xref" HREF="ch04_05.html#ch04-34850"> 236Figure 4.6</a> on the client side. Note that with the current configuration of Windows, this comment will not be shown once a share is mapped to a Windows network drive. </p><H4 CLASS="figure"> 237<A CLASS="title" NAME="ch04-34850"> 238Figure 4.6: Windows client view of a share comment</a></h4><IMG CLASS="graphic" SRC="figs/sam.0406.gif" ALT="Figure 4.6"><P CLASS="para"> 239Be sure not to confuse the <CODE CLASS="literal"> 240comment</code> option, which documents a Samba server's shares, with the <CODE CLASS="literal"> 241server</code> <CODE CLASS="literal"> 242string</code> option, which documents the server itself.</p></div><DIV CLASS="sect3"> 243<H4 CLASS="sect3"> 244<A CLASS="title" NAME="ch04-pgfId-967445"> 2454.5.1.4 volume</a></h4><P CLASS="para"> 246This option allows you to specify the volume name of the share as reported by SMB. This normally resolves to the name of the share given in the <I CLASS="filename"> 247smb.conf</i> file. However, if you wish to name it something else (for whatever reason) you can do so with this option.</p><P CLASS="para"> 248For example, an installer program may check the volume name of a CD-ROM to make sure the right CD-ROM is in the drive before attempting to install 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 get around the issue:</p><PRE CLASS="programlisting"> 249[network] 250 comment = Network Drive 251 volume = ASVP-102-RTYUIKA 252 path = /home/samba/network</pre></div><DIV CLASS="sect3"> 253<H4 CLASS="sect3"> 254<A CLASS="title" NAME="ch04-pgfId-952861"> 2554.5.1.5 read only and writeable</a></h4><P CLASS="para"> 256The options <CODE CLASS="literal"> 257read</code> <CODE CLASS="literal"> 258only</code> and <CODE CLASS="literal"> 259writeable</code> (or <CODE CLASS="literal"> 260write</code> <CODE CLASS="literal"> 261ok</code>) are really two ways of saying the same thing, but approached from opposite ends. For example, you can set either of the following options in the <CODE CLASS="literal"> 262[global]</code> section or in an individual share:</p><PRE CLASS="programlisting"> 263read only = yes 264writeable = no</pre><P CLASS="para"> 265If either option is set as shown, data can be read from a share, but cannot be written to it. You might think you would need this option only if you were creating a read-only share. However, note that this read-only behavior is the <EM CLASS="emphasis"> 266default</em> action for shares; 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:</p><PRE CLASS="programlisting"> 267read only = no 268writeable = yes</pre><P CLASS="para"> 269Note that if you specify more than one occurrence of either option, Samba will adhere to the last value it encounters for the share. </p></div></div></div></blockquote> 270<div> 271<center> 272<hr noshade size=1><TABLE WIDTH="515" BORDER="0" CELLSPACING="0" CELLPADDING="0"> 273<TR> 274<TD ALIGN="LEFT" VALIGN="TOP" WIDTH="172"> 275<A CLASS="sect1" HREF="ch04_04.html" TITLE="4.4 Server Configuration"> 276<IMG SRC="gifs/txtpreva.gif" ALT="Previous: 4.4 Server Configuration" BORDER="0"></a></td><TD ALIGN="CENTER" VALIGN="TOP" WIDTH="171"> 277<A CLASS="book" HREF="index.html" TITLE=""> 278<IMG SRC="gifs/txthome.gif" ALT="" BORDER="0"></a></td><TD ALIGN="RIGHT" VALIGN="TOP" WIDTH="172"> 279<A CLASS="sect1" HREF="ch04_06.html" TITLE="4.6 Networking Options with Samba"> 280<IMG SRC="gifs/txtnexta.gif" ALT="Next: 4.6 Networking Options with Samba" BORDER="0"></a></td></tr><TR> 281<TD ALIGN="LEFT" VALIGN="TOP" WIDTH="172"> 2824.4 Server Configuration</td><TD ALIGN="CENTER" VALIGN="TOP" WIDTH="171"> 283<A CLASS="index" HREF="inx.html" TITLE="Book Index"> 284<IMG SRC="gifs/index.gif" ALT="Book Index" BORDER="0"></a></td><TD ALIGN="RIGHT" VALIGN="TOP" WIDTH="172"> 2854.6 Networking Options with Samba</td></tr></table><hr noshade size=1></center> 286</div> 287 288<!-- End of sample chapter --> 289<CENTER> 290<FONT SIZE="1" FACE="Verdana, Arial, Helvetica"> 291<A HREF="http://www.oreilly.com/"> 292<B>O'Reilly Home</B></A> <B> | </B> 293<A HREF="http://www.oreilly.com/sales/bookstores"> 294<B>O'Reilly Bookstores</B></A> <B> | </B> 295<A HREF="http://www.oreilly.com/order_new/"> 296<B>How to Order</B></A> <B> | </B> 297<A HREF="http://www.oreilly.com/oreilly/contact.html"> 298<B>O'Reilly Contacts<BR></B></A> 299<A HREF="http://www.oreilly.com/international/"> 300<B>International</B></A> <B> | </B> 301<A HREF="http://www.oreilly.com/oreilly/about.html"> 302<B>About O'Reilly</B></A> <B> | </B> 303<A HREF="http://www.oreilly.com/affiliates.html"> 304<B>Affiliated Companies</B></A><p> 305<EM>© 1999, O'Reilly & Associates, Inc.</EM> 306</FONT> 307</CENTER> 308</BODY> 309</html> 310