xref: /netbsd-src/sbin/mount_nfs/mount_nfs.8 (revision 4391d5e9d4f291db41e3b3ba26a01b5e51364aae)
1.\"	$NetBSD: mount_nfs.8,v 1.43 2012/07/11 18:33:14 dholland Exp $
2.\"
3.\" Copyright (c) 1992, 1993, 1994, 1995
4.\"	The Regents of the University of California.  All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\" 3. Neither the name of the University nor the names of its contributors
15.\"    may be used to endorse or promote products derived from this software
16.\"    without specific prior written permission.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28.\" SUCH DAMAGE.
29.\"
30.\"	@(#)mount_nfs.8	8.3 (Berkeley) 3/29/95
31.\"
32.Dd April 2, 2012
33.Dt MOUNT_NFS 8
34.Os
35.Sh NAME
36.Nm mount_nfs
37.Nd mount NFS file systems
38.Sh SYNOPSIS
39.Nm
40.Op Fl 23bCcdilPpqsTUX
41.Op Fl a Ar maxreadahead
42.Op Fl D Ar deadthresh
43.Op Fl g Ar maxgroups
44.Op Fl I Ar readdirsize
45.Op Fl L Ar leaseterm
46.Op Fl o Ar options
47.Op Fl R Ar retrycnt
48.Op Fl r Ar readsize
49.Op Fl t Ar timeout
50.Op Fl w Ar writesize
51.Op Fl x Ar retrans
52.Ar rhost:path node
53.Sh DESCRIPTION
54The
55.Nm
56command calls the
57.Xr mount 2
58system call to prepare and graft a remote
59.Tn NFS
60file system (rhost:path)
61on to the file system tree at the mount point
62.Ar node .
63The directory specified by
64.Ar node
65is converted to an absolute path before use.
66This command is normally executed by
67.Xr mount 8 .
68It implements the mount protocol as described in RFC 1094, Appendix A and
69.%T "NFS: Network File System Version 3 Protocol Specification" ,
70Appendix I.
71.Pp
72The options are:
73.Bl -tag -width indent
74.It Fl 2
75Use the
76.Tn NFS
77Version 2 protocol.
78.It Fl 3
79Use the
80.Tn NFS
81Version 3 protocol.
82The default is to try version 3 first, and
83fall back to version 2 if the mount fails.
84.It Fl a Ar maxreadahead
85Set the read-ahead count to the specified value.
86This may be in the range of 0 - 4, and determines how many blocks
87will be read ahead when a large file is being read sequentially.
88Trying a value greater than 1 for this is suggested for
89mounts with a large bandwidth * delay product.
90.It Fl b
91If an initial attempt to contact the server fails, fork off a child to keep
92trying the mount in the background.
93Useful for
94.Xr fstab 5 ,
95where the filesystem mount is not critical to multiuser operation.
96.It Fl C
97For
98.Tn UDP
99mount points, do a
100.Xr connect 2 .
101Although this flag increases the efficiency of
102.Tn UDP
103mounts it cannot
104be used for servers that do not reply to requests from the
105standard
106.Tn NFS
107port number 2049, or for servers with multiple network interfaces.
108In these cases if the socket is connected and the server
109replies from a different port number or a different network interface
110the client will get ICMP port unreachable and the mount will hang.
111.It Fl c
112For
113.Tn UDP
114mount points, do not do a
115.Xr connect 2 .
116This flag is deprecated and connectionless
117.Tn UDP
118mounts are the default.
119.It Fl D Ar deadthresh
120Set the
121.Dq "dead server threshold"
122to the specified number of round trip timeout intervals.
123After a
124.Dq "dead server threshold"
125of retransmit timeouts,
126.Dq "not responding"
127message is printed to a tty.
128.It Fl d
129Turn off the dynamic retransmit timeout estimator.
130This may be useful for
131.Tn UDP
132mounts that exhibit high retry rates,
133since it is possible that the dynamically estimated timeout interval is too
134short.
135.It Fl g Ar maxgroups
136Set the maximum size of the group list for the credentials to the
137specified value.
138This should be used for mounts on old servers that cannot handle a
139group list size of 16, as specified in RFC 1057.
140Try 8, if users in a lot of groups cannot get response from the mount
141point.
142.It Fl I Ar readdirsize
143Set the readdir read size to the specified value.
144The value should normally
145be a multiple of
146.Dv DIRBLKSIZ
147that is \*[Le] the read size for the mount.
148.It Fl i
149Make the mount interruptible, which implies that file system calls that
150are delayed due to an unresponsive server will fail with
151.Er EINTR
152when a
153termination signal is posted for the process.
154.It Fl L Ar leaseterm
155Ignored.
156It used to be
157.Tn NQNFS
158lease term.
159.It Fl l
160Used with
161.Tn NFS
162Version 3 to specify that the
163.Fn ReaddirPlus
164.Tn RPC
165should be used.
166This option reduces
167.Tn RPC
168traffic for cases such as
169.Ic "ls -l" ,
170but tends to flood the attribute and name caches with prefetched entries.
171Try this option and see whether performance improves or degrades.
172Probably most useful for client to server network
173interconnects with a large bandwidth times delay product.
174.It Fl o Ar options
175Options are specified with a
176.Fl o
177flag followed by a comma separated string of options.
178See the
179.Xr mount 8
180man page for possible options and their meanings.
181.Pp
182The following
183.Tn NFS
184specific options are also available:
185.Bl -tag -width indent
186.It Cm bg
187Same as
188.Fl b .
189.It Cm conn
190Same as
191.Fl C .
192.It Cm deadthresh Ns = Ns Aq Ar deadthresh
193Same as
194.Fl D Ar deadthresh .
195.It Cm dumbtimer
196Same as
197.Fl d .
198.It Cm intr
199Same as
200.Fl i .
201.It Cm leaseterm Ns = Ns Aq Ar leaseterm
202Same as
203.Fl L Ar leaseterm .
204.It Cm maxgrps Ns = Ns Aq Ar maxgroups
205Same as
206.Fl g Ar maxgroups .
207.It Cm mntudp
208Same as
209.Fl U .
210.It Cm nfsv2
211Same as
212.Fl 2 .
213.It Cm nfsv3
214Same as
215.Fl 3 .
216.It Cm noresport
217Same as
218.Fl p .
219.It Cm nqnfs
220Same as
221.Fl q .
222.It Cm port Ns = Ns Aq Ar portnumber
223Use the specified port number for
224.Tn NFS
225requests.
226The default is to query the portmapper for the
227.Tn NFS
228port.
229.It Cm rdirplus
230Same as
231.Fl l .
232.It Cm readahead Ns = Ns Aq Ar maxreadahead
233Same as
234.Fl a Ar maxreadahead .
235.It Cm rsize Ns = Ns Aq Ar readsize
236Same as
237.Fl -r Ar readsize .
238.It Cm soft
239Same as
240.Fl s .
241.It Cm tcp
242Same as
243.Fl T .
244.It Cm timeo Ns = Ns Aq Ar timeout
245Same as
246.Fl t Ar timeout .
247.It Cm wsize Ns = Ns Aq Ar writesize
248Same as
249.Fl w Ar writesize .
250.El
251.It Fl P
252Use a reserved socket port number.
253This is the default, and available
254for backwards compatibility purposes only.
255.It Fl p
256Do not use a reserved port number for RPCs.
257This option is provided only to be able to mimic the old
258default behavior of not using a reserved port, and should rarely be useful.
259.It Fl q
260A synonym of
261.Fl 3 .
262It used to specify
263.Tn NQNFS .
264.It Fl R Ar retrycnt
265Set the retry count for doing the mount to the specified value.
266The default is 10000.
267.It Fl r Ar readsize
268Set the read data size to the specified value in bytes.
269It should normally be a power of 2 greater than or equal to 1024.
270.Pp
271This should be used for
272.Tn UDP
273mounts when the
274.Dq "fragments dropped after timeout"
275value is getting large while actively using a mount point.
276Use
277.Xr netstat 1
278with the
279.Fl s
280option to see what the
281.Dq "fragments dropped after timeout"
282value is.
283See the
284.Nm
285.Fl w
286option also.
287.It Fl s
288A soft mount, which implies that file system calls will fail
289after
290.Ar retrans
291round trip timeout intervals.
292.It Fl T
293Use
294.Tn TCP
295transport instead of
296.Tn UDP .
297This is recommended for servers that are not on the same physical network as
298the client.
299Not all
300.Tn NFS
301servers, especially not old ones, support this.
302.It Fl t Ar timeout
303Set the initial retransmit timeout to the specified value in 0.1 seconds.
304May be useful for fine tuning
305.Tn UDP
306mounts over internetworks
307with high packet loss rates or an overloaded server.
308Try increasing the interval if
309.Xr nfsstat 1
310shows high retransmit rates while the file system is active or reducing the
311value if there is a low retransmit rate but long response delay observed.
312Normally, the -d option should be specified when using this option to manually
313tune the timeout
314interval.
315The default is 3 seconds.
316.It Fl U
317Force the mount protocol to use
318.Tn UDP
319transport, even for
320.Tn TCP
321.Tn NFS
322mounts.
323This is necessary for some old
324.Bx
325servers.
326.It Fl w Ar writesize
327Set the write data size to the specified value in bytes.
328.Pp
329The same logic applies for use of this option as with the
330.Nm
331.Fl r
332option, but using the
333.Dq "fragments dropped after timeout"
334value on the
335.Tn NFS
336server instead of the client.
337Note that both the
338.Fl r
339and
340.Fl w
341options should only be used as a last ditch effort at improving performance
342when mounting servers that do not support
343.Tn TCP
344mounts.
345.It Fl X
346Perform 32 \*[Lt]-\*[Gt] 64 bit directory cookie translation for version 3 mounts.
347This may be need in the case of a server using the upper 32 bits of
348version 3 directory cookies, and when you are running emulated binaries
349that access such a filesystem.
350Native
351.Nx
352binaries will never need this option.
353This option introduces some overhead.
354.It Fl x Ar retrans
355Set the retransmit timeout count for soft mounts to the specified value.
356The default is 10.
357.El
358.Sh EXAMPLES
359The simplest way to invoke
360.Nm
361is with a command like:
362.Pp
363.Dl "mount -t nfs remotehost:/filesystem /localmountpoint"
364.Pp
365It is also possible to automatically mount filesystems at boot from your
366.Pa /etc/fstab
367by using a line like:
368.Pp
369.Dl "remotehost:/home /home nfs rw 0 0"
370.Sh PERFORMANCE
371As can be derived from the comments accompanying the options, performance
372tuning of
373.Tn NFS
374can be a non-trivial task.
375Here are some common points
376to watch:
377.Bl -bullet -offset indent
378.It
379Increasing the read and write size with the
380.Fl r
381and
382.Fl w
383options respectively will increase throughput if the network
384interface can handle the larger packet sizes.
385.Pp
386The default size for
387.Tn NFS
388version 2 is 8K when
389using
390.Tn UDP ,
39164K when using
392.Tn TCP .
393.Pp
394The default size for
395.Tn NFS
396version 3 is platform dependent:
397on
398.Nx Ns /amd64
399and
400.Nx Ns /i386 ,
401the default is 32K, for other platforms it is 8K.
402Values over 32K are only supported for
403.Tn TCP ,
404where 64K is the maximum.
405.Pp
406Any value over 32K is unlikely to get you more performance, unless
407you have a very fast network.
408.It
409If the network interface cannot handle larger packet sizes or a
410long train of back to back packets, you may see low performance
411figures or even temporary hangups during
412.Tn NFS
413activity.
414.Pp
415This can especially happen with older
416.Tn Ethernet
417network interfaces.
418What happens is that either the receive buffer on the network
419interface on the client side is overflowing, or that similar events
420occur on the server, leading to a lot of dropped packets.
421.Pp
422In this case, decreasing the read and write size, using
423.Tn TCP ,
424or a combination of both will usually lead to better throughput.
425Should you need to decrease the read and write size for all your
426.Tn NFS
427mounts because of a slow
428.Tn Ethernet
429network interface
430.Pq e.g. a USB 1.1 to 10/100 Tn Ethernet network interface ,
431you can use
432.Pp
433.Bl -ohang -compact
434.It Cd options NFS_RSIZE=value
435.It Cd options NFS_WSIZE=value
436.El
437.Pp
438in your kernel
439.Xr config 1
440file to avoid having do specify the sizes for all mounts.
441.It
442For connections that are not on the same
443.Tn LAN ,
444and/or may experience packet loss, using
445.Tn TCP
446is strongly recommended.
447.El
448.Sh ERRORS
449Some common problems with
450.Nm
451can be difficult for first time users to understand.
452.Pp
453.Dl "mount_nfs: can't access /foo: Permission denied"
454.Pp
455This message means that the remote host is either not exporting
456the filesystem you requested, or is not exporting it to your host.
457If you believe the remote host is indeed exporting a filesystem to you,
458make sure the
459.Xr exports 5
460file is exporting the proper directories.
461.Pp
462A common mistake is that
463.Xr mountd 8
464will not export a filesystem with the
465.Fl alldirs
466option, unless it
467is a mount point on the exporting host.
468It is not possible to remotely
469mount a subdirectory of an exported mount, unless it is exported with the
470.Fl alldirs
471option.
472.Pp
473The following error:
474.Pp
475.Dl "NFS Portmap: RPC: Program not registered"
476.Pp
477means that the remote host is not running
478.Xr mountd 8 .
479The program
480.Xr rpcinfo 8
481can be used to determine if the remote host is running nfsd, and mountd by issuing
482the command:
483.Pp
484.Dl rpcinfo -p remotehostname
485.Pp
486If the remote host is running nfsd, and mountd, it would display:
487.Pp
488.Dl "100005    3   udp    719  mountd"
489.Dl "100005    1   tcp    720  mountd"
490.Dl "100005    3   tcp    720  mountd"
491.Dl "100003    2   udp   2049  nfs"
492.Dl "100003    3   udp   2049  nfs"
493.Dl "100003    2   tcp   2049  nfs"
494.Dl "100003    3   tcp   2049  nfs"
495.Pp
496The error:
497.Pp
498.Dl "mount_nfs: can't get net id for host"
499.Pp
500indicates that
501.Nm
502cannot resolve the name of the remote host.
503.Sh SEE ALSO
504.Xr nfsstat 1 ,
505.Xr mount 2 ,
506.Xr unmount 2 ,
507.Xr options 4 ,
508.Xr exports 5 ,
509.Xr fstab 5 ,
510.Xr mount 8 ,
511.Xr mountd 8 ,
512.Xr rpcinfo 8
513.Rs
514.%R RFC 1094
515.%D March 1989
516.%T "NFS: Network File System Protocol specification"
517.Re
518.Rs
519.%R RFC 2623
520.%D June 1999
521.%T "NFS Version 2 and Version 3 Security Issues and the NFS Protocol's Use of RPCSEC_GCC and Kerberos V5"
522.Re
523.Rs
524.%R RFC 2624
525.%D June 1999
526.%T "NFS Version 4 Design Considerations"
527.Re
528.Rs
529.%R RFC 2695
530.%D September 1999
531.%T "Authentication Mechanisms for ONC RPC"
532.Re
533.Sh CAVEATS
534An NFS server should not mount its own exported file systems
535.Pq loopback fashion
536because doing so is fundamentally prone to deadlock.
537