xref: /freebsd/usr.sbin/nfsd/nfsd.8 (revision 148a8da8)
1.\" Copyright (c) 1989, 1991, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\" 3. Neither the name of the University nor the names of its contributors
13.\"    may be used to endorse or promote products derived from this software
14.\"    without specific prior written permission.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26.\" SUCH DAMAGE.
27.\"
28.\"	@(#)nfsd.8	8.4 (Berkeley) 3/29/95
29.\" $FreeBSD$
30.\"
31.Dd February 14, 2019
32.Dt NFSD 8
33.Os
34.Sh NAME
35.Nm nfsd
36.Nd remote
37.Tn NFS
38server
39.Sh SYNOPSIS
40.Nm
41.Op Fl ardute
42.Op Fl n Ar num_servers
43.Op Fl h Ar bindip
44.Op Fl p Ar pnfs_setup
45.Op Fl m Ar mirror_level
46.Op Fl V Ar virtual_hostname
47.Op Fl Fl maxthreads Ar max_threads
48.Op Fl Fl minthreads Ar min_threads
49.Sh DESCRIPTION
50The
51.Nm
52utility runs on a server machine to service
53.Tn NFS
54requests from client machines.
55At least one
56.Nm
57must be running for a machine to operate as a server.
58.Pp
59Unless otherwise specified, eight servers per CPU for
60.Tn UDP
61transport are started.
62.Pp
63The following options are available:
64.Bl -tag -width Ds
65.It Fl r
66Register the
67.Tn NFS
68service with
69.Xr rpcbind 8
70without creating any servers.
71This option can be used along with the
72.Fl u
73or
74.Fl t
75options to re-register NFS if the rpcbind server is restarted.
76.It Fl d
77Unregister the
78.Tn NFS
79service with
80.Xr rpcbind 8
81without creating any servers.
82.It Fl V Ar virtual_hostname
83Specifies a hostname to be used as a principal name, instead of
84the default hostname.
85.It Fl n Ar threads
86Specifies how many servers to create.  This option is equivalent to specifying
87.Fl Fl maxthreads
88and
89.Fl Fl minthreads
90with their respective arguments to
91.Ar threads .
92.It Fl Fl maxthreads Ar threads
93Specifies the maximum servers that will be kept around to service requests.
94.It Fl Fl minthreads Ar threads
95Specifies the minimum servers that will be kept around to service requests.
96.It Fl h Ar bindip
97Specifies which IP address or hostname to bind to on the local host.
98This option is recommended when a host has multiple interfaces.
99Multiple
100.Fl h
101options may be specified.
102.It Fl a
103Specifies that nfsd should bind to the wildcard IP address.
104This is the default if no
105.Fl h
106options are given.
107It may also be specified in addition to any
108.Fl h
109options given.
110Note that NFS/UDP does not operate properly when
111bound to the wildcard IP address whether you use -a or do not use -h.
112.It Fl p Ar pnfs_setup
113Enables pNFS support in the server and specifies the information that the
114daemon needs to start it.
115This option can only be used on one server and specifies that this server
116will be the MetaData Server (MDS) for the pNFS service.
117This can only be done if there is at least one FreeBSD system configured
118as a Data Server (DS) for it to use.
119.Pp
120The
121.Ar pnfs_setup
122string is a set of fields separated by ',' characters:
123.Bl -tag -width Ds
124Each of these fields specifies one DS.
125It consists of a server hostname, followed by a ':'
126and the directory path where the DS's data storage file system is mounted on
127this MDS server.
128This can optionally be followed by a '#' and the mds_path, which is the
129directory path for an exported file system on this MDS.
130If this is specified, it means that this DS is to be used to store data
131files for this mds_path file system only.
132If this optional component does not exist, the DS will be used to store data
133files for all exported MDS file systems.
134The DS storage file systems must be mounted on this system before the
135.Nm
136is started with this option specified.
137.br
138For example:
139.sp
140nfsv4-data0:/data0,nfsv4-data1:/data1
141.sp
142would specify two DS servers called nfsv4-data0 and nfsv4-data1 that comprise
143the data storage component of the pNFS service.
144These two DSs would be used to store data files for all exported file systems
145on this MDS.
146The directories
147.Dq /data0
148and
149.Dq /data1
150are where the data storage servers exported
151storage directories are mounted on this system (which will act as the MDS).
152.br
153Whereas, for the example:
154.sp
155nfsv4-data0:/data0#/export1,nfsv4-data1:/data1#/export2
156.sp
157would specify two DSs as above, however nfsv4-data0 will be used to store
158data files for
159.Dq /export1
160and nfsv4-data1 will be used to store data files for
161.Dq /export2 .
162.El
163.sp
164When using IPv6 addresses for DSs
165be wary of using link local addresses.
166The IPv6 address for the DS is sent to the client and there is no scope
167zone in it.
168As such, a link local address may not work for a pNFS client to DS
169TCP connection.
170When parsed,
171.Nm
172will only use a link local address if it is the only address returned by
173.Xr getaddrinfo 3
174for the DS hostname.
175.It Fl m Ar mirror_level
176This option is only meaningful when used with the
177.Fl p
178option.
179It specifies the
180.Dq mirror_level ,
181which defines how many of the DSs will
182have a copy of a file's data storage file.
183The default of one implies no mirroring of data storage files on the DSs.
184The
185.Dq mirror_level
186would normally be set to 2 to enable mirroring, but
187can be as high as NFSDEV_MAXMIRRORS.
188There must be at least
189.Dq mirror_level
190DSs for each exported file system on the MDS, as specified in the
191.Fl p
192option.
193This implies that, for the above example using "#/export1" and "#/export2",
194mirroring cannot be done.
195There would need to be two DS entries for each of "#/export1" and "#/export2"
196in order to support a
197.Dq mirror_level
198of two.
199.Pp
200If mirroring is enabled, the server must use the Flexible File
201layout.
202If mirroring is not enabled, the server will use the File layout
203by default, but this default can be changed to the Flexible File layout if the
204.Xr sysctl 1
205vfs.nfsd.default_flexfile
206is set non-zero.
207.It Fl t
208Serve
209.Tn TCP NFS
210clients.
211.It Fl u
212Serve
213.Tn UDP NFS
214clients.
215.It Fl e
216Ignored; included for backward compatibility.
217.El
218.Pp
219For example,
220.Dq Li "nfsd -u -t -n 6"
221serves
222.Tn UDP
223and
224.Tn TCP
225transports using six daemons.
226.Pp
227A server should run enough daemons to handle
228the maximum level of concurrency from its clients,
229typically four to six.
230.Pp
231The
232.Nm
233utility listens for service requests at the port indicated in the
234.Tn NFS
235server specification; see
236.%T "Network File System Protocol Specification" ,
237RFC1094,
238.%T "NFS: Network File System Version 3 Protocol Specification" ,
239RFC1813,
240.%T "Network File System (NFS) Version 4 Protocol" ,
241RFC3530 and
242.%T "Network File System (NFS) Version 4 Minor Version 1 Protocol" ,
243RFC5661.
244.Pp
245If
246.Nm
247detects that
248.Tn NFS
249is not loaded in the running kernel, it will attempt
250to load a loadable kernel module containing
251.Tn NFS
252support using
253.Xr kldload 2 .
254If this fails, or no
255.Tn NFS
256KLD is available,
257.Nm
258will exit with an error.
259.Pp
260If
261.Nm
262is to be run on a host with multiple interfaces or interface aliases, use
263of the
264.Fl h
265option is recommended.
266If you do not use the option NFS may not respond to
267UDP packets from the same IP address they were sent to.
268Use of this option
269is also recommended when securing NFS exports on a firewalling machine such
270that the NFS sockets can only be accessed by the inside interface.
271The
272.Nm ipfw
273utility
274would then be used to block nfs-related packets that come in on the outside
275interface.
276.Pp
277If the server has stopped servicing clients and has generated a console message
278like
279.Dq Li "nfsd server cache flooded..." ,
280the value for vfs.nfsd.tcphighwater needs to be increased.
281This should allow the server to again handle requests without a reboot.
282Also, you may want to consider decreasing the value for
283vfs.nfsd.tcpcachetimeo to several minutes (in seconds) instead of 12 hours
284when this occurs.
285.Pp
286Unfortunately making vfs.nfsd.tcphighwater too large can result in the mbuf
287limit being reached, as indicated by a console message
288like
289.Dq Li "kern.ipc.nmbufs limit reached" .
290If you cannot find values of the above
291.Nm sysctl
292values that work, you can disable the DRC cache for TCP by setting
293vfs.nfsd.cachetcp to 0.
294.Pp
295The
296.Nm
297utility has to be terminated with
298.Dv SIGUSR1
299and cannot be killed with
300.Dv SIGTERM
301or
302.Dv SIGQUIT .
303The
304.Nm
305utility needs to ignore these signals in order to stay alive as long
306as possible during a shutdown, otherwise loopback mounts will
307not be able to unmount.
308If you have to kill
309.Nm
310just do a
311.Dq Li "kill -USR1 <PID of master nfsd>"
312.Sh EXIT STATUS
313.Ex -std
314.Sh SEE ALSO
315.Xr nfsstat 1 ,
316.Xr kldload 2 ,
317.Xr nfssvc 2 ,
318.Xr nfsv4 4 ,
319.Xr pnfs 4 ,
320.Xr pnfsserver 4 ,
321.Xr exports 5 ,
322.Xr stablerestart 5 ,
323.Xr gssd 8 ,
324.Xr ipfw 8 ,
325.Xr mountd 8 ,
326.Xr nfsiod 8 ,
327.Xr nfsrevoke 8 ,
328.Xr nfsuserd 8 ,
329.Xr rpcbind 8
330.Sh HISTORY
331The
332.Nm
333utility first appeared in
334.Bx 4.4 .
335.Sh BUGS
336If
337.Nm
338is started when
339.Xr gssd 8
340is not running, it will service AUTH_SYS requests only. To fix the problem
341you must kill
342.Nm
343and then restart it, after the
344.Xr gssd 8
345is running.
346.Pp
347If mirroring is enabled via the
348.Fl m
349option and there are Linux clients doing NFSv4.1 mounts, those clients
350need to be patched to support the
351.Dq tightly coupled
352variant of
353the Flexible File layout or the
354.Xr sysctl 1
355vfs.nfsd.flexlinuxhack
356must be set to one on the MDS as a workaround.
357