Documentation update
[nbd.git] / nbd-server.5.sgml
1 <!doctype refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN" [
2
3 <!-- Process this file with docbook-to-man to generate an nroff manual
4      page: `docbook-to-man manpage.sgml > manpage.1'.  You may view
5      the manual page with: `docbook-to-man manpage.sgml | nroff -man |
6      less'.  A typical entry in a Makefile or Makefile.am is:
7
8 manpage.1: manpage.sgml
9         docbook-to-man $< > $@
10   -->
11
12   <!-- Fill in your name for FIRSTNAME and SURNAME. -->
13   <!ENTITY dhfirstname "<firstname>Wouter</firstname>">
14   <!ENTITY dhsurname   "<surname>Verhelst</surname>">
15   <!-- Please adjust the date whenever revising the manpage. -->
16   <!ENTITY dhdate      "<date>$Date: 2006-10-18 15:01:57 +0200 (wo, 18 okt 2006) $</date>">
17   <!-- SECTION should be 1-8, maybe w/ subsection other parameters are
18        allowed: see man(7), man(1). -->
19   <!ENTITY dhsection   "<manvolnum>5</manvolnum>">
20   <!ENTITY dhemail     "<email>wouter@debian.org</email>">
21   <!ENTITY dhusername  "Wouter Verhelst">
22   <!ENTITY dhucpackage "<refentrytitle>NBD-SERVER</refentrytitle>">
23   <!ENTITY dhpackage   "/etc/nbd-server/config">
24
25   <!ENTITY debian      "<productname>Debian GNU/Linux</productname>">
26   <!ENTITY gnu         "<acronym>GNU</acronym>">
27 ]>
28
29 <refentry>
30   <refentryinfo>
31     <address>
32       &dhemail;
33     </address>
34     <author>
35       &dhfirstname;
36       &dhsurname;
37     </author>
38     <copyright>
39       <year>2006</year>
40       <holder>&dhusername;</holder>
41     </copyright>
42     &dhdate;
43   </refentryinfo>
44   <refmeta>
45     &dhucpackage;
46
47     &dhsection;
48   </refmeta>
49   <refnamediv>
50     <refname>&dhpackage;</refname>
51
52     <refpurpose>configuration file for nbd-server</refpurpose>
53   </refnamediv>
54   <refsynopsisdiv>
55     <cmdsynopsis>
56       <command>&dhpackage; </command>
57
58     </cmdsynopsis>
59   </refsynopsisdiv>
60   <refsect1>
61     <title>DESCRIPTION</title>
62
63     <para><command>&dhpackage;</command> allows to configure the
64     nbd-server.</para>
65
66     <para>While
67       <filename>@sysconfdir@/nbd-server/config</filename> is the default
68       configuration file, this can be varied with the <option>-C</option>
69       option to <command>nbd-server</command>(1).
70     </para>
71     <para>
72       The configuration file consists of section header lines, comment
73       lines, and option lines.
74     </para>
75     <para>
76       A section header is a unique name that
77       is enclosed in square brackets ("[" and "]"). A section header
78       denotes the beginning of a section; a section continues until
79       the next section or the end of the file, whichever is first. The
80       first section in the configuration file must be called
81       <option>generic</option>, and is used for global options that
82       apply to more than one export. This section must always be
83       present, even if it holds no options. Every other section
84       defines one export; the names of these sections are not
85       important, except that you should take care to make sure that
86       each section name is unique (future versions of
87       <command>nbd-server</command> may use the section name to refer
88       to an export)
89     </para>
90     <para>
91       A comment line is a line that starts with optional whitespace,
92       followed by a pound sign ("#"), and continues until the end of
93       the line. Comments may <emphasis>not</emphasis> be used on
94       option lines or section header lines.
95     </para>
96     <para>
97       An option line is a line that starts with an option name,
98       followed by an equals sign ("="), followed by the option
99       value. An option can be of type string, of type integer, or of
100       type boolean. The value of a boolean option can be denoted with
101       either true or false (so not yes, no, on, off, 1, or 0). All
102       booleans default to false unless specified otherwise. No value
103       may be quoted (always enter it directly). For a string option,
104       leading whitespace is stripped (but trailing whitespace is not).
105     </para>
106
107   </refsect1>
108   <refsect1>
109     <title>OPTIONS FOR SECTION [generic]</title>
110
111     <!-- These are in alphabetical order, please keep it that way -->    
112     <variablelist>
113       <varlistentry>
114         <term><option>group</option></term>
115         <listitem>
116           <para>
117             Optional; string.
118           </para>
119           <para>
120             The name of the group this server must run as. If this
121             parameter is not specified, then nbd-server will not
122             attempt to change its GID (so the GID it runs as will be
123             the primary group of the user who starts nbd-server). If
124             it is specified, then nbd-server will change its GID after
125             opening ports, but before accepting connections or opening
126             files.
127           </para>
128         </listitem>
129       </varlistentry>
130       <varlistentry>
131         <term><option>user</option></term>
132         <listitem>
133           <para>
134             Optional; string.
135           </para>
136           <para>
137             The name of the user this server must run as. If this
138             parameter is not specified, then nbd-server will not
139             attempt to change its UID (so the UID it runs as will be
140             the user who starts nbd-server). If it is specified, then
141             nbd-server will change its UID after opening ports, but
142             before accepting connections or opening files.
143           </para>
144         </listitem>
145       </varlistentry>
146       <varlistentry>
147         <term><option>oldstyle</option></term>
148         <listitem>
149           <para>
150             Optional; boolean
151           </para>
152           <para>
153             If this option is set to true, nbd-server will export all
154             exports on a separate port with the old (pre-2.9.17)
155             handshake protocol. In that case, the 'port' option for
156             individual exports is mandatory.
157           </para>
158           <para>
159             If the option is set to false, the 'port' option for
160             individual exports is optional (and will be ignored if
161             specified). The server will only export devices on the
162             standard port.
163           </para>
164         </listitem>
165       </varlistentry>
166       <varlistentry>
167         <term><option>listenaddr</option></term>
168         <listitem>
169           <para>
170             Optional; string
171           </para>
172           <para>If this option is set, it should contain the local IP
173           address on which we should listen to
174           <command>nbd-client</command>(8) connections. If it is not
175             set, <command>nbd-server</command> will listen to all
176           local IPv4 and IPv6 addresses. To limit to IPv6, specify the
177           address as "::". To limit to IPv4, specify as "0.0.0.0". It
178           is not possible to specify more than one IP address
179           here.</para>
180         </listitem>
181       </varlistentry
182     </variablelist>
183   </refsect1>
184   <refsect1>
185     <title>OPTIONS FOR EXPORT SECTIONS</title>
186
187     <!-- These are in alphabetical order, please keep it that way -->
188     <variablelist>
189       <varlistentry>
190         <term><option>authfile</option></term>
191         <listitem>
192           <para>
193             Optional; string; default
194             <filename>@sysconfdir@/nbd-server/allow</filename>.
195           </para>
196           <para>
197             The name of the authorization file for this export. This
198             file should contain one line per IP-address, or per
199             network (which must be specified in CIDR-style
200             <option><replaceable>network</replaceable>/<replaceable>masklen</replaceable></option>)
201             and must not contain empty lines. If the file
202             does not exist, everyone is allowed to connect. If the
203             file exists but is empty, nobody is allowed to
204             connect. Otherwise, <command>nbd-server</command> will
205             only allow clients to connect whose IP-adres is listed in
206             this file.
207           </para>
208           <para>Corresponds to the <option>-l</option> option on the
209           command line</para>
210         </listitem>
211       </varlistentry>
212       <varlistentry>
213         <term><option>copyonwrite</option></term>
214         <listitem>
215           <para>
216             Optional; boolean.
217           </para>
218           <para>
219             Whether this is a copy-on-write export. If it is, then any
220             writes to this export will not be written to the master
221             file, but to a separate file which will be removed upon
222             disconnect. The result of using this option is that
223             nbd-server will be slower, and that any writes will be
224             lost upon disconnect.
225           </para>
226           <para>Corresponds to the <option>-c</option> option on the
227             command line</para>
228         </listitem>
229       </varlistentry>
230       <varlistentry>
231         <term><option>exportname</option></term>
232         <listitem>
233           <para>Required; string.</para>
234           <para>
235             The name of the file (or block device) that will be
236             exported. This must be a fully-qualified path and filename;
237             relative paths are not allowed.
238           </para>
239           <para>
240             Note that <command>nbd-server</command> will only try to
241             find and open the exported file when a client actually
242             connects; as a result, <command>nbd-server</command> must
243             be able to open and read this file
244             <emphasis>after</emphasis> changing to the user and group
245             that have been specified by use of the
246             <option>user</option> and <option>group</option> options;
247             also, <command>nbd-server</command> will only detect
248             errors in this option upon connection of a client.
249           </para>
250           <para>When specified on the command line, this should be the
251             second argument.
252           </para>
253         </listitem>
254       </varlistentry>
255       <varlistentry>
256         <term><option>filesize</option></term>
257         <listitem>
258           <para>Optional; integer; default autodetected.</para>
259           <para>
260             Disable autodetection of file or block device size, and
261             forcibly specify a size. Sizes must be specified in
262             bytes. If the <option>multifile</option> option is in
263             effect, this option specifies the size of the
264             <emphasis>entire</emphasis> export, not of individual
265             files.
266           </para>
267           <para>When specified on the command line, this should be the
268             third argument.
269           </para>
270         </listitem>
271       </varlistentry>
272       <varlistentry>
273         <term>listenaddr</term>
274         <listitem>
275           <para>
276             Optional; string
277           </para>
278           <para>
279             If the 'oldstyle' global parameter is specified, works
280             similarly to the global listenaddr parameter, but for the
281             individual port of this particular export. If the 'oldstyle'
282             parameter is not set, this parameter is ignored.
283           </para>
284         </listitem>
285       </varlistentry>
286       <varlistentry>
287         <term><option>multifile</option></term>
288         <listitem>
289           <para>Optional; boolean.</para>
290           <para>
291             If this option is set to true, then
292             <command>nbd-server</command> will search for files of the
293             form
294             <replaceable>exportname</replaceable>.<replaceable>integer</replaceable>,
295             with <replaceable>exportname</replaceable> being the
296             filename that would otherwise have been used (after name
297             transformation for virtualization, if any, has been
298             performed) and <replaceable>integer</replaceable> an
299             integer number, starting with 0 and ending when no more
300             files can be found.
301           </para>
302           <para>
303             The size of the individual files will be autodetected,
304             <emphasis>even</emphasis> if the <option>filesize</option>
305             option has been specified. See the documentation for the
306             <option>multifile</option> for details.
307           </para>
308           <para>
309             Corresponds to the <option>-m</option> option on the
310             command line.
311           </para>
312         </listitem>
313       </varlistentry>
314       <varlistentry>
315         <term><option>port</option></term>
316         <listitem>
317           <para>Required if 'oldstyle' global parameter is set; integer.</para>
318           <para>
319             The port on which this export is to be served. Currently
320             it is not possible to export multiple block devices on the
321             same port unless virtualization is used; future versions
322             of <command>nbd-server</command> may add this
323             functionality.
324           </para>
325           <para>
326             When specified on the command line, this should be the
327             first argument.
328           </para>
329         </listitem>
330       </varlistentry>
331       <varlistentry>
332         <term><option>readonly</option></term>
333         <listitem>
334           <para>Optional; boolean.</para>
335           <para>
336             Disallow writes to the device. If this option is
337             specified, <command>nbd-server</command> will issue an
338             error to any client that tries to write to the device.
339           </para>
340           <para>
341             Use of this option in conjunction with
342             <option>copyonwrite</option> is possible, but silly.
343           </para>
344           <para>Corresponds to the <option>-r</option> option on the
345           command line.</para>
346         </listitem>
347       </varlistentry>
348       <varlistentry>
349         <term><option>sdp</option></term>
350         <listitem>
351           <para>Optional; boolean.</para>
352           <para>
353             When this option is enabled, <command>nbd-server</command>
354             will use the Socket Direct Protocol (SDP) to serve the
355             export, rather than just IP. This is faster, but requires
356             special hardware (usually something like InfiniBand) and
357             support in the kernel.
358           </para>
359           <para>
360             Additionally, support for this option must be enabled at
361             compile time, using the <option>--enable-sdp</option> option
362             to the <command>configure</command> script. If this option
363             is found in a configuration file and
364             <command>nbd-server</command> does not have support for SDP,
365             then <command>nbd-server</command> will exit with an error
366             message.
367           </para>
368         </listitem>
369       </varlistentry>
370       <varlistentry>
371         <term><option>sync</option></term>
372         <listitem>
373           <para>Optional; boolean.</para>
374           <para>When this option is enabled,
375             <command>nbd-server</command> will call an fsync() after every
376             write to the backend storage. Calling fsync() increases
377             reliability in case of an unclean shutdown of nbd-server; but,
378             depending on the file system used on the nbd-server side, may
379             degrade performance. The use of this option isn't always
380             necessary; e.g., on ext3 filesystems, it is recommended that
381             it is <emphasis>not</emphasis> enabled, since it seriously
382             reduces performance on ext3 filesystems while not
383             importantly impacting reliability.
384           </para>
385         </listitem>
386       </varlistentry>
387       <varlistentry>
388         <term><option>sparse_cow</option></term>
389         <listitem>
390           <para>Optional; boolean.</para>
391           <para>
392             When this option is enabled, <command>nbd-server</command>
393             will use sparse files to implement the copy-on-write
394             option; such files take up less space then they appear to,
395             which allows <command>nbd-server</command> to handle the
396             file as if it was just as large as the block device it's
397             for.
398           </para>
399           <para>
400             If this option is disabled, <command>nbd-server</command>
401             will map every newly written block to the end of the
402             copy-on-write file, which means that
403             <command>nbd-server</command> will have to lseek(2) to the
404             right position after every 4096-byte block.
405           </para>
406           <para>
407             Using this option may be faster when much is being written
408             during a connection.
409           </para>
410         </listitem>
411       </varlistentry>
412       <varlistentry>
413         <term><option>timeout</option></term>
414         <listitem>
415           <para>Optional; integer; default 0</para>
416           <para>
417             How many seconds a connection may be idle for this
418             export. When a connection is idle for a longer time,
419             <command>nbd-server</command> will forcibly disconnect the
420             connection. If you specify 0 (the default), then a
421             connection may be idle forever.
422           </para>
423           <para>
424             Corresponds to the <option>-a</option> option on the
425             command line
426           </para>
427         </listitem>
428       </varlistentry>
429       <varlistentry>
430         <term><option>virtstyle</option></term>
431         <listitem>
432           <para>Optional; string; default "ipliteral"</para>
433           <para>
434             Defines the style of virtualization. Virtualization allows
435             one to create one export that will serve a different file
436             depending on the IP address that is connecting. When
437             virtualization is There are three types of virtualization
438             that <command>nbd-server</command> supports:
439           </para>
440           <variablelist>
441             <varlistentry>
442               <term><option>none</option></term>
443               <listitem>
444                 <para>
445                   No virtualization. Will attempt to open the filename
446                   as it was written, even if it contains '%s' in the
447                   name.
448                 </para>
449               </listitem>
450             </varlistentry>
451             <varlistentry>
452               <term><option>ipliteral</option></term>
453               <listitem>
454                 <para>
455                   <command>nbd-server</command> will look for the
456                   literal string '%s' in the
457                   <option>exportname</option>, and replace it by the
458                   address of the connecting host. The string that
459                   results from this transformation will be used as an
460                   absolute pathname that <command>nbd-server</command>
461                   will attempt to open. As an example, if a client
462                   connects from 192.168.1.100 and
463                   <option>exportname</option> is specified as
464                   <filename>/export/%s</filename>, then nbd-server
465                   will attempt to serve
466                   <filename>/export/192.168.1.100</filename>
467                 </para>
468               </listitem>
469             </varlistentry>
470             <varlistentry>
471               <term><option>iphash</option></term>
472               <listitem>
473                 <para>
474                   Same as above, except that
475                   <command>nbd-server</command> will replace the dots
476                   in the IP address by forward slashes ('/'); in the
477                   same example, <command>nbd-server</command> would
478                   open <filename>/export/192/168/1/100</filename>
479                   instead.
480                 </para>
481                 <para>
482                   Since there are no dots in most IPv6 addresses, the
483                   effect of using this option when IPv6 is in use is
484                   indistinguishable from the ipliteral option.
485                 </para>
486               </listitem>
487             </varlistentry>
488             <varlistentry>
489               <term><option>cidrhash</option></term>
490               <listitem>
491                 <para>
492                   This option requires one to add a space and a number
493                   after it. <command>nbd-server</command> will use the
494                   number as a network mask in CIDR style, and use that
495                   as a hash cutoff point. In the above example, if
496                   <option>virtstyle</option> has been specified as
497                   <constant>cidrhash 16</constant>, then
498                   <command>nbd-server</command> will try to open
499                   <filename>/export/192.168.0.0/192.168.1.100</filename>;
500                   if <option>virtstyle</option> were specified as
501                   <constant>cidrhash 26</constant>, then
502                   <command>nbd-server</command> will try to open
503                   <filename>/export/192.168.1.64/192.168.1.100</filename>.
504                 </para>
505                 <para>This option works as expected for IPv6.</para>
506               </listitem>
507             </varlistentry>
508           </variablelist>
509         </listitem>
510       </varlistentry>
511       <varlistentry>
512         <term><option>prerun</option></term>
513         <listitem>
514           <para>Optional; string</para>
515           <para>
516             If specified, then this command will be ran after a
517             client has connected to the server (and has been
518             accepted), but before the server starts serving. If
519             the command contains the literal string '%s', then
520             this string will be replaced by the filename of the
521             file which nbd-server wants to export.
522           </para>
523           <para>
524             This is useful to create export files on the fly, or
525             to verify that a file can be used for export, to
526             write something to a log file, or similar.
527           </para>
528           <para>
529             If the command runs with a non-zero exit status,
530             then nbd-server will assume the export will fail,
531             and refuse to serve it.
532           </para>
533         </listitem>
534       </varlistentry>
535       <varlistentry>
536         <term><option>postrun</option></term>
537         <listitem>
538           <para>Optional; string</para>
539           <para>
540             If specified, then it is assumed to be a command
541             that will be ran when a client has
542             disconnected. This can be useful to clean up
543             whatever <option>prerun</option> has set up, to log
544             something, or similar.
545           </para>
546           <para>
547             If the literal string '%s' is present in the
548             command, it will be replaced by the file name that
549             has just been closed.
550           </para>
551           <para>
552             In contrast to the <option>prerun</option> option,
553             the exit state of <option>postrun</option> is
554             <emphasis>ignored</emphasis>.
555           </para>
556         </listitem>
557       </varlistentry>
558     </variablelist>
559     
560   </refsect1>
561   <refsect1>
562     <title>SEE ALSO</title>
563
564     <para>nbd-server (1), nbd-client (8),
565       http://nbd.sourceforge.net/roadmap.html</para>
566
567   </refsect1>
568   <refsect1>
569     <title>AUTHOR</title>
570     <para>The NBD kernel module and the NBD tools were originally
571       written by Pavel Machek (pavel@ucw.cz)</para>
572
573     <para>The Linux kernel module is now maintained by Paul Clements
574       (Paul.Clements@steeleye.com), while the userland tools are
575       maintained by &dhusername; (&dhemail;)</para>
576
577     <para>On The Hurd there is a regular translator available to perform the
578       client side of the protocol, and the use of
579       <command>nbd-client</command> is not required. Please see the
580       relevant documentation for more information.</para>
581
582     <para>This manual page was written by &dhusername; (&dhemail;) for
583       the &debian; system (but may be used by others).  Permission is
584       granted to copy, distribute and/or modify this document under
585       the terms of the <acronym>GNU</acronym> General Public License,
586       version 2, as published by the Free Software Foundation.</para>
587
588   </refsect1>
589   <refsect1>
590     <title>EXAMPLES</title>
591     <para>A simple <command>nbd-server</command> configuration file
592       would look like this:</para>
593     <programlisting>
594       [generic]
595       [export]
596           exportname = /export/blkdev
597           port = 12345
598     </programlisting>
599     <para>For increased security, one might want to create an
600       authorization file, and set the UID and GID to run as:</para>
601     <programlisting>
602       [generic]
603           user = nbd
604           group = nbd
605       [export]
606           exportname = /export/blkdev
607           port = 12345
608           authfile = /etc/nbd-server/allow
609     </programlisting>
610     <para>With /etc/nbd-server/allow containing the following:</para>
611     <programlisting>
612       127.0.0.1
613       192.168.0.0/8
614       192.168.1.1
615     </programlisting>
616   </refsect1>
617 </refentry>
618
619 <!-- Keep this comment at the end of the file
620 Local variables:
621 mode: sgml
622 sgml-omittag:t
623 sgml-shorttag:t
624 sgml-minimize-attributes:nil
625 sgml-always-quote-attributes:t
626 sgml-indent-step:2
627 sgml-indent-data:t
628 sgml-parent-document:nil
629 sgml-default-dtd-file:nil
630 sgml-exposed-tags:nil
631 sgml-local-catalogs:nil
632 sgml-local-ecat-files:nil
633 End:
634 -->