]> git.decadent.org.uk Git - nfs-utils.git/blob - utils/mount/nfs.man
nfs(5): document new [no]resvport option
[nfs-utils.git] / utils / mount / nfs.man
1 .\"@(#)nfs.5"
2 .TH NFS 5 "2 November 2007"
3 .SH NAME
4 nfs \- fstab format and options for the
5 .B nfs
6 and
7 .B nfs4
8 file systems
9 .SH SYNOPSIS
10 .I /etc/fstab
11 .SH DESCRIPTION
12 NFS is an Internet Standard protocol
13 created by Sun Microsystems in 1984. NFS was developed
14 to allow file sharing between systems residing
15 on a local area network.
16 The Linux NFS client supports three versions
17 of the NFS protocol:
18 NFS version 2 [RFC1094],
19 NFS version 3 [RFC1813],
20 and NFS version 4 [RFC3530].
21 .P
22 The
23 .BR mount (8)
24 command attaches a file system to the system's
25 name space hierarchy at a given mount point.
26 The
27 .I /etc/fstab
28 file describes how
29 .BR mount (8)
30 should assemble a system's file name hierarchy
31 from various independent file systems 
32 (including file systems exported by NFS servers).
33 Each line in the
34 .I /etc/fstab
35 file describes a single file system, its mount point,
36 and a set of default mount options for that mount point.
37 .P
38 For NFS file system mounts, a line in the
39 .I /etc/fstab
40 file specifies the server name,
41 the path name of the exported server directory to mount,
42 the local directory that is the mount point,
43 the type of file system that is being mounted,
44 and a list of mount options that control
45 the way the filesystem is mounted and
46 how the NFS client behaves when accessing
47 files on this mount point.
48 The fifth and sixth fields on each line are not used
49 by NFS, thus conventionally each contain the digit zero. For example:
50 .P
51 .SP
52 .NF
53 .TA 2.5i +0.75i +0.75i +1.0i
54         server:path     /mountpoint     fstype  option,option,...       0 0
55 .FI
56 .P
57 The server's hostname and export pathname
58 are separated by a colon, while
59 the mount options are separated by commas. The remaining fields 
60 are separated by blanks or tabs.
61 The server's hostname can be an unqualified hostname,
62 a fully qualified domain name,
63 or a dotted quad IPv4 address.
64 The
65 .I fstype
66 field contains either "nfs" (for version 2 or version 3 NFS mounts)
67 or "nfs4" (for NFS version 4 mounts).
68 The
69 .B nfs
70 and
71 .B nfs4
72 file system types share similar mount options,
73 which are described below. 
74 .SH "MOUNT OPTIONS"
75 Refer to 
76 .BR mount (8)
77 for a description of generic mount options
78 available for all file systems. If you do not need to 
79 specify any mount options, use the generic option 
80 .B defaults
81 in
82 .IR /etc/fstab .
83
84 .DT
85 .SS "Valid options for either the nfs or nfs4 file system type"
86 These options are valid to use when mounting either
87 .B nfs
88 or
89 .B nfs4
90 file system types.
91 They imply the same behavior
92 and have the same default for both file system types.
93 .TP 1.5i
94 .BR soft " / " hard
95 Determines the recovery behavior of the NFS client
96 after an NFS request times out.
97 If neither option is specified (or if the
98 .B hard
99 option is specified), NFS requests are retried indefinitely.
100 If the
101 .B soft
102 option is specified, then the NFS client fails an NFS request
103 after 
104 .B retrans
105 retransmissions have been sent,
106 causing the NFS client to return an error
107 to the calling application.
108 .IP
109 .I NB:
110 A so-called "soft" timeout can cause
111 silent data corruption in certain cases. As such, use the
112 .B soft
113 option only when client responsiveness
114 is more important than data integrity.
115 Using NFS over TCP or increasing the value of the
116 .B retrans
117 option may mitigate some of the risks of using the
118 .B soft
119 option.
120 .TP 1.5i
121 .BI timeo= n
122 The time (in tenths of a second) the NFS client waits for a 
123 response before it retries an NFS request. If this 
124 option is not specified, requests are retried every
125 60 seconds for NFS over TCP.
126 The NFS client does not perform any kind of timeout backoff
127 for NFS over TCP.
128 .IP
129 However, for NFS over UDP, the client uses an adaptive
130 algorithm to estimate an appropriate timeout value for frequently used
131 request types (such as READ and WRITE requests), but uses the 
132 .B timeo
133 setting for infrequently used request types (such as FSINFO requests).
134 If the
135 .B timeo
136 option is not specified,
137 infrequently used request types are retried after 1.1 seconds.
138 After each retransmission, the NFS client doubles the timeout for
139 that request,
140 up to a maximum timeout length of 60 seconds.
141 .TP 1.5i
142 .BI retrans= n
143 The number of times the NFS client retries a request before
144 it attempts further recovery action. If the 
145 .B retrans
146 option is not specified, the NFS client tries each request 
147 three times.
148 .IP
149 The NFS client generates a "server not responding" message
150 after 
151 .B retrans
152 retries, then attempts further recovery (depending on whether the
153 .B hard
154 mount option is in effect).
155 .TP 1.5i
156 .BI rsize= n
157 The maximum number of bytes in each network READ request
158 that the NFS client can receive when reading data from a file
159 on an NFS server.
160 The actual data payload size of each NFS READ request is equal to
161 or smaller than the
162 .B rsize
163 setting. The largest read payload supported by the Linux NFS client
164 is 1,048,576 bytes (one megabyte).
165 .IP
166 The
167 .B rsize
168 value is a positive integral multiple of 1024.
169 Specified 
170 .B rsize
171 values lower than 1024 are replaced with 4096; values larger than
172 1048576 are replaced with 1048576. If a specified value is within the supported
173 range but not a multiple of 1024, it is rounded down to the nearest 
174 multiple of 1024.
175 .IP
176 If an
177 .B rsize
178 value is not specified, or if the specified 
179 .B rsize 
180 value is larger than the maximum that either client or server can support,
181 the client and server negotiate the largest
182 .B rsize
183 value that they can both support. 
184 .IP
185 The
186 .B rsize
187 mount option as specified on the
188 .BR mount (8)
189 command line appears in the
190 .I /etc/mtab
191 file. However, the effective
192 .B rsize
193 value negotiated by the client and server is reported in the
194 .I /proc/mounts
195 file.
196 .TP 1.5i
197 .BI wsize= n
198 The maximum number of bytes per network WRITE request
199 that the NFS client can send when writing data to a file
200 on an NFS server. The actual data payload size of each 
201 NFS WRITE request is equal to
202 or smaller than the
203 .B wsize
204 setting. The largest write payload supported by the Linux NFS client
205 is 1,048,576 bytes (one megabyte).
206 .IP
207 Similar to
208 .B rsize
209 , the
210 .B wsize 
211 value is a positive integral multiple of 1024.
212 Specified 
213 .B wsize
214 values lower than 1024 are replaced with 4096; values larger than
215 1048576 are replaced with 1048576. If a specified value is within the supported
216 range but not a multiple of 1024, it is rounded down to the nearest 
217 multiple of 1024.
218 .IP
219 If a
220 .B wsize
221 value is not specified, or if the specified 
222 .B wsize 
223 value is larger than the maximum that either client or server can support,
224 the client and server negotiate the largest
225 .B wsize
226 value that they can both support.
227 .IP
228 The
229 .B wsize
230 mount option as specified on the
231 .BR mount (8)
232 command line appears in the
233 .I /etc/mtab
234 file. However, the effective
235 .B wsize
236 value negotiated by the client and server is reported in the
237 .I /proc/mounts
238 file. 
239 .TP 1.5i
240 .BR ac " / " noac
241 Selects whether the client may cache file attributes. If neither  
242 option is specified (or if 
243 .B ac
244 is specified), the client caches file  
245 attributes.  
246 .IP
247 To improve performance, NFS clients cache file  
248 attributes. Every few seconds, an NFS client checks the server's version of each  
249 file's attributes for updates.  Changes that occur on the server in  
250 those small intervals remain undetected until the client checks the  
251 server again. The 
252 .B noac
253 option prevents clients from caching file  
254 attributes so that applications can more quickly detect file changes  
255 on the server.
256 .IP
257 In addition to preventing the client from caching file attributes,  
258 the 
259 .B noac
260 option forces application writes to become synchronous so  
261 that local changes to a file become visible on the server  
262 immediately.  That way, other clients can quickly detect recent  
263 writes when they check the file's attributes.
264 .IP
265 Using the
266 .B noac
267 option provides greater cache coherence among NFS clients
268 accessing the same files,
269 but it extracts a significant performance penalty.
270 As such, judicious use of file locking is encouraged instead.
271 The DATA AND METADATA COHERENCE section contains a detailed discussion
272 of these trade-offs.
273 .TP 1.5i
274 .BI acregmin= n
275 The minimum time (in seconds) that the NFS client caches
276 attributes of a regular file before it requests
277 fresh attribute information from a server.
278 If this option is not specified, the NFS client uses
279 a 3-second minimum.
280 .TP 1.5i
281 .BI acregmax= n
282 The maximum time (in seconds) that the NFS client caches
283 attributes of a regular file before it requests
284 fresh attribute information from a server.
285 If this option is not specified, the NFS client uses
286 a 60-second maximum.
287 .TP 1.5i
288 .BI acdirmin= n
289 The minimum time (in seconds) that the NFS client caches
290 attributes of a directory before it requests
291 fresh attribute information from a server.
292 If this option is not specified, the NFS client uses
293 a 30-second minimum.
294 .TP 1.5i
295 .BI acdirmax= n
296 The maximum time (in seconds) that the NFS client caches
297 attributes of a directory before it requests
298 fresh attribute information from a server.
299 If this option is not specified, the NFS client uses
300 a 60-second maximum.
301 .TP 1.5i
302 .BI actimeo= n
303 Using
304 .B actimeo
305 sets all of
306 .BR acregmin ,
307 .BR acregmax ,
308 .BR acdirmin ,
309 and
310 .B acdirmax
311 to the same value.
312 If this option is not specified, the NFS client uses
313 the defaults for each of these options listed above.
314 .TP 1.5i
315 .BR bg " / " fg
316 Determines how the
317 .BR mount (8)
318 command behaves if an attempt to mount an export fails.
319 The
320 .B fg
321 option causes
322 .BR mount (8)
323 to exit with an error status if any part of the mount request
324 times out or fails outright.
325 This is called a "foreground" mount,
326 and is the default behavior if neither the
327 .B fg
328 nor
329 .B bg
330 mount option is specified.
331 .IP
332 If the
333 .B bg
334 option is specified, a timeout or failure causes the
335 .BR mount (8)
336 command to fork a child which continues to attempt
337 to mount the export.
338 The parent immediately returns with a zero exit code.
339 This is known as a "background" mount.
340 .IP
341 If the local mount point directory is missing, the
342 .BR mount (8)
343 command acts as if the mount request timed out.
344 This permits nested NFS mounts specified in
345 .I /etc/fstab
346 to proceed in any order during system initialization,
347 even if some NFS servers are not yet available.
348 Alternatively these issues can be addressed
349 using an automounter (refer to
350 .BR automount (8)
351 for details).
352 .TP 1.5i
353 .BI retry= n
354 The number of minutes that the
355 .BR mount (8)
356 command retries an NFS mount operation
357 in the foreground or background before giving up.
358 If this option is not specified, the default value for foreground mounts
359 is 2 minutes, and the default value for background mounts is 10000 minutes (80 minutes shy of one week).
360 .TP 1.5i
361 .BI sec= mode
362 The RPCGSS security flavor to use for accessing files on this mount point.
363 If the
364 .B sec
365 option is not specified, or if
366 .B sec=sys
367 is specified, the NFS client uses the AUTH_SYS security flavor
368 for all NFS requests on this mount point.
369 Valid security flavors are
370 .BR none ,
371 .BR sys ,
372 .BR krb5 ,
373 .BR krb5i ,
374 .BR krb5p ,
375 .BR lkey ,
376 .BR lkeyi ,
377 .BR lkeyp ,
378 .BR spkm ,
379 .BR spkmi ,
380 and
381 .BR spkmp .
382 Refer to the SECURITY CONSIDERATIONS section for details.
383 .TP 1.5i
384 .BR sharecache " / " nosharecache
385 Determines how the client's data cache and attribute cache are shared
386 when mounting the same export more than once concurrently.  Using the  
387 same cache reduces memory requirements on the client and presents  
388 identical file contents to applications when the same remote file is  
389 accessed via different mount points.
390 .IP
391 If neither option is specified, or if the 
392 .B sharecache
393 option is  
394 specified, then a single cache is used for all mount points that  
395 access the same export.  If the 
396 .B nosharecache
397 option is specified,  
398 then that mount point gets a unique cache.  Note that when data and  
399 attribute caches are shared, the mount options from the first mount  
400 point take effect for subsequent concurrent mounts of the same export.
401 .IP
402 As of kernel 2.6.18, the behavior specified by
403 .B nosharecache
404 is legacy caching behavior. This
405 is considered a data risk since multiple cached copies
406 of the same file on the same client can become out of sync
407 following a local update of one of the copies.
408 .TP 1.5i
409 .BR resvport " / " noresvport
410 Specifies whether the NFS client should use a privileged source port
411 when communicating with an NFS server for this mount point.
412 If this option is not specified, or the
413 .B resvport
414 option is specified, the NFS client uses a privileged source port.
415 If the
416 .B noresvport
417 option is specified, the NFS client uses a non-privileged source port.
418 This option is supported in kernels 2.6.28 and later.
419 .IP
420 Using non-privileged source ports helps increase the maximum number of
421 NFS mount points allowed on a client, but NFS servers must be configured
422 to allow clients to connect via non-privileged source ports.
423 .IP
424 Refer to the SECURITY CONSIDERATIONS section for important details.
425 .SS "Valid options for the nfs file system type"
426 Use these options, along with the options in the above subsection,
427 for mounting the
428 .B nfs
429 file system type.
430 .TP 1.5i
431 .BI proto= transport
432 The transport the NFS client uses
433 to transmit requests to the NFS server for this mount point.
434 .I transport
435 can be either
436 .B udp
437 or
438 .BR tcp .
439 Each transport uses different default
440 .B retrans
441 and
442 .B timeo
443 settings; refer to the description of these two mount options for details.
444 .IP
445 In addition to controlling how the NFS client transmits requests to
446 the server, this mount option also controls how the
447 .BR mount (8)
448 command communicates with the server's rpcbind and mountd services.
449 Specifying 
450 .B proto=tcp
451 forces all traffic from the 
452 .BR mount (8)
453 command and the NFS client to use TCP.
454 Specifying
455 .B proto=udp
456 forces all traffic types to use UDP.
457 .IP
458 If the
459 .B proto
460 mount option is not specified, the
461 .BR mount (8)
462 command discovers which protocols the server supports
463 and chooses an appropriate transport for each service.
464 Refer to the TRANSPORT METHODS section for more details.
465 .TP 1.5i
466 .B udp
467 The
468 .B udp
469 option is an alternative to specifying
470 .BR proto=udp.
471 It is included for compatibility with other operating systems.
472 .TP 1.5i
473 .B tcp
474 The
475 .B tcp
476 option is an alternative to specifying
477 .BR proto=tcp.
478 It is included for compatibility with other operating systems.
479 .TP 1.5i
480 .BI port= n
481 The numeric value of the server's NFS service port.
482 If the server's NFS service is not available on the specified port,
483 the mount request fails.
484 .IP
485 If this option is not specified, or if the specified port value is 0,
486 then the NFS client uses the NFS service port number
487 advertised by the server's rpcbind service.
488 The mount request fails if the server's rpcbind service is not available,
489 the server's NFS service is not registered with its rpcbind service,
490 or the server's NFS service is not available on the advertised port.
491 .TP 1.5i
492 .BI mountport= n
493 The numeric value of the server's mountd port.
494 If the server's mountd service is not available on the specified port,
495 the mount request fails.
496 .IP
497 If this option is not specified,
498 or if the specified port value is 0, then the
499 .BR mount (8)
500 command uses the mountd service port number
501 advertised by the server's rpcbind service.
502 The mount request fails if the server's rpcbind service is not available,
503 the server's mountd service is not registered with its rpcbind service,
504 or the server's mountd service is not available on the advertised port.
505 .IP
506 This option can be used when mounting an NFS server
507 through a firewall that blocks the rpcbind protocol.
508 .TP 1.5i
509 .BI mountproto= transport
510 The transport the NFS client uses
511 to transmit requests to the NFS server's mountd service when performing
512 this mount request, and when later unmounting this mount point.
513 .I transport
514 can be either
515 .B udp
516 or
517 .BR tcp .
518 .IP
519 This option can be used when mounting an NFS server
520 through a firewall that blocks a particular transport.
521 When used in combination with the
522 .B proto
523 option, different transports for mountd requests and NFS requests
524 can be specified.
525 If the server's mountd service is not available via the specified
526 transport, the mount request fails.
527 Refer to the TRANSPORT METHODS section for more on how the
528 .B mountproto
529 mount option interacts with the
530 .B proto
531 mount option.
532 .TP 1.5i
533 .BI mounthost= name
534 The hostname of the host running mountd.
535 If this option is not specified, the
536 .BR mount (8)
537 command assumes that the mountd service runs
538 on the same host as the NFS service.
539 .TP 1.5i
540 .BI mountvers= n
541 The RPC version number used to contact the server's mountd.
542 If this option is not specified, the client uses a version number
543 appropriate to the requested NFS version.
544 This option is useful when multiple NFS services
545 are running on the same remote server host.
546 .TP 1.5i
547 .BI namlen= n
548 The maximum length of a pathname component on this mount.
549 If this option is not specified, the maximum length is negotiated
550 with the server. In most cases, this maximum length is 255 characters.
551 .IP
552 Some early versions of NFS did not support this negotiation.
553 Using this option ensures that
554 .BR pathconf (3)
555 reports the proper maximum component length to applications
556 in such cases.
557 .TP 1.5i
558 .BI nfsvers= n
559 The NFS protocol version number used to contact the server's NFS service.
560 The Linux client supports version 2 and version 3 of the NFS protocol
561 when using the file system type
562 .BR nfs .
563 If the server does not support the requested version,
564 the mount request fails.
565 If this option is not specified, the client attempts to use version 3,
566 but negotiates the NFS version with the server if version 3 support
567 is not available.
568 .TP 1.5i
569 .BI vers= n
570 This option is an alternative to the
571 .B nfsvers
572 option.
573 It is included for compatibility with other operating systems.
574 .TP 1.5i
575 .BR lock " / " nolock
576 Selects whether to use the NLM sideband protocol to lock files on the server.
577 If neither option is specified (or if 
578 .B lock 
579 is specified), NLM locking is used for this mount point. 
580 When using the
581 .B nolock
582 option, applications can lock files,
583 but such locks provide exclusion only against other applications
584 running on the same client.
585 Remote applications are not affected by these locks.
586 .IP
587 NLM locking must be disabled with the
588 .B nolock
589 option when using NFS to mount
590 .I /var
591 because
592 .I /var
593 contains files used by the NLM implementation on Linux.
594 Using the
595 .B nolock
596 option is also required when mounting exports on NFS servers
597 that do not support the NLM protocol.
598 .TP 1.5i
599 .BR intr " / " nointr
600 Selects whether to allow signals to interrupt file operations
601 on this mount point. If neither option 
602 is specified (or if 
603 .B nointr
604 is specified),
605 signals do not interrupt NFS file operations. If
606 .B intr 
607 is specified, system calls return EINTR if an in-progress NFS operation is interrupted by 
608 a signal.
609 .IP
610 Using the
611 .B intr
612 option is preferred to using the
613 .B soft
614 option because it is significantly less likely to result in data corruption.
615 .IP
616 The
617 .BR intr " / " nointr
618 mount option is deprecated after kernel 2.6.25.
619 Only SIGKILL can interrupt a pending NFS operation on these kernels,
620 and if specified, this mount option is ignored to provide backwards
621 compatibility with older kernels.
622 .TP 1.5i
623 .BR cto " / " nocto
624 Selects whether to use close-to-open cache coherence semantics.
625 If neither option is specified (or if 
626 .B cto
627 is specified), the client uses close-to-open
628 cache coherence semantics. If the 
629 .B nocto 
630 option is specified, the client uses a non-standard heuristic to determine when
631 files on the server have changed. 
632 .IP
633 Using the
634 .B nocto
635 option may improve performance for read-only mounts,
636 but should be used only if the data on the server changes only occasionally.
637 The DATA AND METADATA COHERENCE section discusses the behavior
638 of this option in more detail.
639 .TP 1.5i
640 .BR acl " / " noacl
641 Selects whether to use the NFSACL sideband protocol on this mount point.
642 The NFSACL sideband protocol is a proprietary protocol
643 implemented in Solaris that manages Access Control Lists. NFSACL was never 
644 made a standard part of the NFS protocol specification.
645 .IP
646 If neither 
647 .B acl
648 nor 
649 .B noacl 
650 option is specified,
651 the NFS client negotiates with the server
652 to see if the NFSACL protocol is supported,
653 and uses it if the server supports it.
654 Disabling the NFSACL sideband protocol may be necessary
655 if the negotiation causes problems on the client or server.
656 Refer to the SECURITY CONSIDERATIONS section for more details.
657 .TP 1.5i
658 .BR rdirplus " / " nordirplus
659 Selects whether to use NFS version 3 READDIRPLUS requests.
660 If this option is not specified, the NFS client uses READDIRPLUS requests
661 on NFS version 3 mounts to read small directories.
662 Some applications perform better if the client uses only READDIR requests
663 for all directories.  
664 .SS "Valid options for the nfs4 file system type"
665 Use these options, along with the options in the first subsection above,
666 for mounting the
667 .B nfs4
668 file system type.
669 .TP 1.5i
670 .BI proto= transport
671 The transport the NFS client uses
672 to transmit requests to the NFS server for this mount point.
673 .I transport
674 can be either
675 .B udp
676 or
677 .BR tcp .
678 All NFS version 4 servers are required to support TCP,
679 so if this mount option is not specified, the NFS version 4 client 
680 uses the TCP transport protocol. 
681 Refer to the TRANSPORT METHODS section for more details.
682 .TP 1.5i
683 .BI port= n
684 The numeric value of the server's NFS service port.
685 If the server's NFS service is not available on the specified port,
686 the mount request fails.
687 .IP
688 If this mount option is not specified,
689 the NFS client uses the standard NFS port number of 2049
690 without first checking the server's rpcbind service.
691 This allows an NFS version 4 client to contact an NFS version 4
692 server through a firewall that may block rpcbind requests.
693 .IP
694 If the specified port value is 0,
695 then the NFS client uses the NFS service port number
696 advertised by the server's rpcbind service.
697 The mount request fails if the server's rpcbind service is not available,
698 the server's NFS service is not registered with its rpcbind service,
699 or the server's NFS service is not available on the advertised port.
700 .TP 1.5i
701 .BR intr " / " nointr
702 Selects whether to allow signals to interrupt file operations
703 on this mount point. If neither option is specified (or if 
704 .B intr 
705 is specified), system calls return EINTR if an in-progress NFS operation  
706 is interrupted by a signal.  If 
707 .B nointr
708 is specified, signals do not  
709 interrupt NFS operations.
710 .IP
711 Using the
712 .B intr
713 option is preferred to using the
714 .B soft
715 option because it is significantly less likely to result in data corruption.
716 .IP
717 The
718 .BR intr " / " nointr
719 mount option is deprecated after kernel 2.6.25.
720 Only SIGKILL can interrupt a pending NFS operation on these kernels,
721 and if specified, this mount option is ignored to provide backwards
722 compatibility with older kernels.
723 .TP 1.5i
724 .BR cto " / " nocto
725 Selects whether to use close-to-open cache coherence semantics
726 for NFS directories on this mount point.
727 If neither
728 .B cto
729 nor
730 .B nocto 
731 is specified,
732 the default is to use close-to-open cache coherence
733 semantics for directories.
734 .IP
735 File data caching behavior is not affected by this option.
736 The DATA AND METADATA COHERENCE section discusses
737 the behavior of this option in more detail.
738 .TP 1.5i
739 .BI clientaddr= n.n.n.n
740 Specifies  a  single  IPv4  address  (in dotted-quad form) 
741 that the NFS client advertises to allow servers 
742 to perform NFS version 4 callback requests against 
743 files on this mount point. If  the  server is unable to 
744 establish callback connections to clients, performance 
745 may degrade, or accesses to files may temporarily hang.
746 .IP
747 If this option is not specified, the
748 .BR mount (8)
749 command attempts to discover an appropriate callback address automatically.
750 The automatic discovery process is not perfect, however.
751 In the presence of multiple client network interfaces,
752 special routing policies,
753 or atypical network topologies,
754 the exact address to use for callbacks may be nontrivial to determine. 
755 .SH EXAMPLES
756 To mount an export using NFS version 2,
757 use the
758 .B nfs
759 file system type and specify the
760 .B nfsvers=2
761 mount option.
762 To mount using NFS version 3,
763 use the
764 .B nfs
765 file system type and specify the
766 .B nfsvers=3
767 mount option.
768 To mount using NFS version 4,
769 use the
770 .B nfs4
771 file system type.
772 The
773 .B nfsvers
774 mount option is not supported for the
775 .B nfs4
776 file system type.
777 .P
778 The following example from an
779 .I /etc/fstab
780 file causes the mount command to negotiate
781 reasonable defaults for NFS behavior.
782 .P
783 .NF
784 .TA 2.5i +0.7i +0.7i +.7i
785         server:/export  /mnt    nfs     defaults        0 0
786 .FI
787 .P
788 Here is an example from an /etc/fstab file for an NFS version 2 mount over UDP.
789 .P
790 .NF
791 .TA 2.5i +0.7i +0.7i +.7i
792         server:/export  /mnt    nfs     nfsvers=2,proto=udp     0 0
793 .FI
794 .P
795 Try this example to mount using NFS version 4 over TCP
796 with Kerberos 5 mutual authentication.
797 .P
798 .NF
799 .TA 2.5i +0.7i +0.7i +.7i
800         server:/export  /mnt    nfs4    sec=krb5        0 0
801 .FI
802 .P
803 This example can be used to mount /usr over NFS.
804 .P
805 .NF
806 .TA 2.5i +0.7i +0.7i +.7i
807         server:/export  /usr    nfs     ro,nolock,nocto,actimeo=3600    0 0
808 .FI
809 .SH "TRANSPORT METHODS"
810 NFS clients send requests to NFS servers via
811 Remote Procedure Calls, or
812 .IR RPCs .
813 The RPC client discovers remote service endpoints automatically,
814 handles per-request authentication,
815 adjusts request parameters for different byte endianness on client and server,
816 and retransmits requests that may have been lost by the network or server.
817 RPC requests and replies flow over a network transport.
818 .P
819 In most cases, the
820 .BR mount (8)
821 command, NFS client, and NFS server
822 can automatically negotiate proper transport
823 and data transfer size settings for a mount point.
824 In some cases, however, it pays to specify
825 these settings explicitly using mount options.
826 .P
827 Traditionally, NFS clients used the UDP transport exclusively for  
828 transmitting requests to servers.  Though its implementation is  
829 simple, NFS over UDP has many limitations that prevent smooth  
830 operation and good performance in some common deployment  
831 environments.  Even an insignificant packet loss rate results in the  
832 loss of whole NFS requests; as such, retransmit timeouts are usually  
833 in the subsecond range to allow clients to recover quickly from  
834 dropped requests, but this can result in extraneous network traffic  
835 and server load.
836 .P
837 However, UDP can be quite effective in specialized settings where  
838 the network’s MTU is large relative to NFS’s data transfer size (such  
839 as network environments that enable jumbo Ethernet frames).  In such  
840 environments, trimming the 
841 .B rsize 
842 and 
843 .B wsize 
844 settings so that each  
845 NFS read or write request fits in just a few network frames (or even  
846 in  a single  frame) is advised.  This reduces the probability that  
847 the loss of a single MTU-sized network frame results in the loss of  
848 an entire large read or write request.
849 .P
850 TCP is the default transport protocol used for all modern NFS 
851 implementations.  It performs well in almost every conceivable
852 network environment and provides excellent guarantees against data 
853 corruption caused by network unreliability.  TCP is often a  
854 requirement for mounting a server through a network firewall.
855 .P
856 Under normal circumstances, networks drop packets much more
857 frequently than NFS servers drop requests.  As such, an aggressive
858 retransmit timeout  setting for NFS over TCP is unnecessary. Typical
859 timeout settings for NFS over TCP are between one and ten minutes.
860 After  the client exhausts its retransmits (the value of the
861 .B retrans
862 mount option), it assumes a network partition has occurred,
863 and attempts to reconnect to the server on a fresh socket. Since
864 TCP itself makes network data transfer reliable, 
865 .B rsize
866 and 
867 .B wsize
868 can safely be allowed to default to the largest values supported by  
869 both client and server, independent of the network's MTU size.
870 .SS "Using the mountproto mount option"
871 This section applies only to NFS version 2 and version 3 mounts
872 since NFS version 4 does not use a separate protocol for mount
873 requests.
874 .P
875 The Linux NFS client can use a different transport for
876 contacting an NFS server's rpcbind service, its mountd service,
877 its Network Lock Manager (NLM) service, and its NFS service.
878 The exact transports employed by the Linux NFS client for
879 each mount point depends on the settings of the transport
880 mount options, which include
881 .BR proto ,
882 .BR mountproto ,
883 .BR udp ", and " tcp .
884 .P
885 The client sends Network Status Manager (NSM) notifications
886 via UDP no matter what transport options are specified, but
887 listens for server NSM notifications on both UDP and TCP.
888 The NFS Access Control List (NFSACL) protocol shares the same
889 transport as the main NFS service.
890 .P
891 If no transport options are specified, the Linux NFS client
892 uses UDP to contact the server's mountd service, and TCP to
893 contact its NLM and NFS services by default.
894 .P
895 If the server does not support these transports for these services, the
896 .BR mount (8)
897 command attempts to discover what the server supports, and then retries
898 the mount request once using the discovered transports.
899 If the server does not advertise any transport supported by the client
900 or is misconfigured, the mount request fails.
901 If the
902 .B bg
903 option is in effect, the mount command backgrounds itself and continues
904 to attempt the specified mount request.
905 .P
906 When the
907 .B proto
908 option, the
909 .B udp
910 option, or the
911 .B tcp
912 option is specified but the
913 .B mountproto
914 option is not, the specified transport is used to contact
915 both the server's mountd service and for the NLM and NFS services.
916 .P
917 If the
918 .B mountproto
919 option is specified but none of the
920 .BR proto ", " udp " or " tcp
921 options are specified, then the specified transport is used for the
922 initial mountd request, but the mount command attempts to discover
923 what the server supports for the NFS protocol, preferring TCP if
924 both transports are supported.
925 .P
926 If both the
927 .BR mountproto " and " proto
928 (or
929 .BR udp " or " tcp )
930 options are specified, then the transport specified by the
931 .B mountproto
932 option is used for the initial mountd request, and the transport
933 specified by the
934 .B proto
935 option (or the
936 .BR udp " or " tcp " options)"
937 is used for NFS, no matter what order these options appear.
938 No automatic service discovery is performed if these options are
939 specified.
940 .P
941 If any of the
942 .BR proto ", " udp ", " tcp ", "
943 or
944 .B mountproto
945 options are specified more than once on the same mount command line,
946 then the value of the rightmost instance of each of these options
947 takes effect.
948 .SH "DATA AND METADATA COHERENCE"
949 Some modern cluster file systems provide
950 perfect cache coherence among their clients.
951 Perfect cache coherence among disparate NFS clients
952 is expensive to achieve, especially on wide area networks.
953 As such, NFS settles for weaker cache coherence that 
954 satisfies the requirements of most file sharing types. Normally, 
955 file sharing is completely sequential:
956 first client A opens a file, writes something to it, then closes it;
957 then client B opens the same file, and reads the changes.
958 .DT
959 .SS "Close-to-open cache consistency"
960 When an application opens a file stored on an NFS server,
961 the NFS client checks that it still exists on the server
962 and is permitted to the opener by sending a GETATTR or ACCESS request.
963 When the application closes the file,
964 the NFS client writes back any pending changes
965 to the file so that the next opener can view the changes.
966 This also gives the NFS client an opportunity to report
967 any server write errors to the application
968 via the return code from
969 .BR close (2).
970 The behavior of checking at open time and flushing at close time
971 is referred to as close-to-open cache consistency.
972 .SS "Weak cache consistency"
973 There are still opportunities for a client's data cache
974 to contain stale data.
975 The NFS version 3 protocol introduced "weak cache consistency"
976 (also known as WCC) which provides a way of efficiently checking
977 a file's attributes before and after a single request.
978 This allows a client to help identify changes
979 that could have been made by other clients.
980 .P
981 When a client is using many concurrent operations
982 that update the same file at the same time
983 (for example, during asynchronous write behind),
984 it is still difficult to tell whether it was
985 that client's updates or some other client's updates
986 that altered the file.
987 .SS "Attribute caching"
988 Use the 
989 .B noac
990 mount option to achieve attribute cache coherence
991 among multiple clients.
992 Almost every file system operation checks
993 file attribute information.
994 The client keeps this information cached
995 for a period of time to reduce network and server load.
996 When
997 .B noac
998 is in effect, a client's file attribute cache is disabled,
999 so each operation that needs to check a file's attributes
1000 is forced to go back to the server.
1001 This permits a client to see changes to a file very quickly,
1002 at the cost of many extra network operations.
1003 .P
1004 Be careful not to confuse the
1005 .B noac
1006 option with "no data caching."
1007 The
1008 .B noac
1009 mount option prevents the client from caching file metadata,
1010 but there are still races that may result in data cache incoherence
1011 between client and server.
1012 .P
1013 The NFS protocol is not designed to support
1014 true cluster file system cache coherence
1015 without some type of application serialization.
1016 If absolute cache coherence among clients is required,
1017 applications should use file locking. Alternatively, applications 
1018 can also open their files with the O_DIRECT flag
1019 to disable data caching entirely.
1020 .SS "The sync mount option"
1021 The NFS client treats the
1022 .B sync
1023 mount option differently than some other file systems
1024 (refer to 
1025 .BR mount (8)
1026 for a description of the generic
1027 .B sync
1028 and
1029 .B async
1030 mount options).
1031 If neither
1032 .B sync
1033 nor
1034 .B async
1035 is specified (or if the 
1036 .B async 
1037 option is specified),
1038 the NFS client delays sending application
1039 writes to the server
1040 until any of these events occur: 
1041 .IP
1042 Memory pressure forces reclamation of system memory resources.
1043 .IP
1044 An application flushes file data explicitly with 
1045 .BR sync (2),
1046 .BR msync (2),
1047 or
1048 .BR fsync (3).
1049 .IP
1050 An application closes a file with
1051 .BR close (2).
1052 .IP
1053 The file is locked/unlocked via
1054 .BR fcntl (2).
1055 .P
1056 In other words, under normal circumstances,
1057 data written by an application may not immediately appear
1058 on the server that hosts the file.
1059 .P
1060 If the
1061 .B sync
1062 option is specified on a mount point,
1063 any system call that writes data to files on that mount point
1064 causes that data to be flushed to the server
1065 before the system call returns control to user space.
1066 This provides greater data cache coherence among clients,
1067 but at a significant performance cost.
1068 .P
1069 Applications can use the O_SYNC open flag to force application
1070 writes to individual files to go to the server immediately without
1071 the use of the
1072 .B sync 
1073 mount option.
1074 .SS "Using file locks with NFS"
1075 The Network Lock Manager protocol is a separate sideband protocol
1076 used to manage file locks in NFS version 2 and version 3.
1077 To support lock recovery after a client or server reboot,
1078 a second sideband protocol --
1079 known as the Network Status Manager protocol --
1080 is also required.
1081 In NFS version 4,
1082 file locking is supported directly in the main NFS protocol,
1083 and the NLM and NSM sideband protocols are not used.
1084 .P
1085 In most cases, NLM and NSM services are started automatically,
1086 and no extra configuration is required.
1087 Configure all NFS clients with fully-qualified domain names
1088 to ensure that NFS servers can find clients to notify them of server reboots.
1089 .P
1090 NLM supports advisory file locks only.
1091 To lock NFS files, use
1092 .BR fcntl (2)
1093 with the F_GETLK and F_SETLK commands.
1094 The NFS client converts file locks obtained via
1095 .BR flock (2)
1096 to advisory locks.
1097 .P
1098 When mounting servers that do not support the NLM protocol,
1099 or when mounting an NFS server through a firewall
1100 that blocks the NLM service port,
1101 specify the
1102 .B nolock
1103 mount option. NLM locking must be disabled with the
1104 .B nolock
1105 option when using NFS to mount
1106 .I /var
1107 because 
1108 .I /var 
1109 contains files used by the NLM implementation on Linux.
1110 .P
1111 Specifying the
1112 .B nolock
1113 option may also be advised to improve the performance
1114 of a proprietary application which runs on a single client
1115 and uses file locks extensively. 
1116 .SS "NFS version 4 caching features"
1117 The data and metadata caching behavior of NFS version 4
1118 clients is similar to that of earlier versions.
1119 However, NFS version 4 adds two features that improve
1120 cache behavior:
1121 .I change attributes
1122 and
1123 .IR "file delegation" .
1124 .P
1125 The
1126 .I change attribute
1127 is a new part of NFS file and directory metadata
1128 which tracks data changes.
1129 It replaces the use of a file's modification
1130 and change time stamps
1131 as a way for clients to validate the content
1132 of their caches.
1133 Change attributes are independent of the time stamp
1134 resolution on either the server or client, however.
1135 .P
1136 A
1137 .I file delegation
1138 is a contract between an NFS version 4 client
1139 and server that allows the client to treat a file temporarily
1140 as if no other client is accessing it.
1141 The server promises to notify the client (via a callback request) if another client
1142 attempts to access that file.
1143 Once a file has been delegated to a client, the client can
1144 cache that file's data and metadata aggressively without
1145 contacting the server.
1146 .P
1147 File delegations come in two flavors:
1148 .I read
1149 and
1150 .IR write .
1151 A
1152 .I read
1153 delegation means that the server notifies the client
1154 about any other clients that want to write to the file.
1155 A
1156 .I write
1157 delegation means that the client gets notified about
1158 either read or write accessors.
1159 .P
1160 Servers grant file delegations when a file is opened,
1161 and can recall delegations at any time when another
1162 client wants access to the file that conflicts with
1163 any delegations already granted.
1164 Delegations on directories are not supported.
1165 .P
1166 In order to support delegation callback, the server
1167 checks the network return path to the client during
1168 the client's initial contact with the server.
1169 If contact with the client cannot be established,
1170 the server simply does not grant any delegations to
1171 that client.
1172 .SH "SECURITY CONSIDERATIONS"
1173 NFS servers control access to file data,
1174 but they depend on their RPC implementation
1175 to provide authentication of NFS requests.
1176 Traditional NFS access control mimics
1177 the standard mode bit access control provided in local file systems.
1178 Traditional RPC authentication uses a number
1179 to represent each user
1180 (usually the user's own uid),
1181 a number to represent the user's group (the user's gid),
1182 and a set of up to 16 auxiliary group numbers
1183 to represent other groups of which the user may be a member.
1184 .P
1185 Typically, file data and user ID values appear unencrypted
1186 (i.e. "in the clear") on the network.
1187 Moreover, NFS versions 2 and 3 use
1188 separate sideband protocols for mounting,
1189 locking and unlocking files,
1190 and reporting system status of clients and servers.
1191 These auxiliary protocols use no authentication.
1192 .P
1193 In addition to combining these sideband protocols with the main NFS protocol,
1194 NFS version 4 introduces more advanced forms of access control,
1195 authentication, and in-transit data protection.
1196 The NFS version 4 specification mandates NFSv4 ACLs,
1197 RPCGSS authentication, and RPCGSS security flavors
1198 that provide per-RPC integrity checking and encryption.
1199 Because NFS version 4 combines the  
1200 function of the sideband protocols into the main NFS protocol,
1201 the new security features apply to all NFS version 4 operations
1202 including mounting, file locking, and so on.
1203 RPCGSS authentication can also be used with NFS versions 2 and 3,
1204 but does not protect their sideband protocols.
1205 .P
1206 The
1207 .B sec
1208 mount option specifies the RPCGSS security mode
1209 that is in effect on a given NFS mount point.
1210 Specifying
1211 .B sec=krb5
1212 provides cryptographic proof of a user's identity in each RPC request.
1213 This provides strong verification of the identity of users 
1214 accessing data on the server.
1215 Note that additional configuration besides adding this mount option
1216 is required in order to enable Kerberos security.
1217 Refer to the 
1218 .BR rpc.gssd (8)
1219 man page for details.
1220 .P
1221 Two additional flavors of Kerberos security are supported:
1222 .B krb5i
1223 and
1224 .BR krb5p .
1225 The
1226 .B krb5i
1227 security flavor provides a cryptographically strong guarantee
1228 that the data in each RPC request has not been tampered with.
1229 The
1230 .B krb5p
1231 security flavor encrypts every RPC request
1232 to prevent data exposure during network transit; however,
1233 expect some performance impact
1234 when using integrity checking or encryption.
1235 Similar support for other forms of cryptographic security (such as lipkey and SPKM3)
1236 is also available.
1237 .P
1238 The NFS version 4 protocol allows
1239 clients and servers to negotiate among multiple security flavors
1240 during mount processing.
1241 However, Linux does not yet implement such negotiation.
1242 The Linux client specifies a single security flavor at mount time
1243 which remains in effect for the lifetime of the mount.
1244 If the server does not support this flavor,
1245 the initial mount request is rejected by the server.
1246 .SS "Using non-privileged source ports"
1247 NFS clients usually communicate with NFS servers via network sockets.
1248 Each end of a socket is assigned a port value, which is simply a number
1249 between 1 and 65535 that distinguishes socket endpoints at the same
1250 IP address.
1251 A socket is uniquely defined by a tuple that includes the transport
1252 protocol (TCP or UDP) and the port values and IP addresses of both
1253 endpoints.
1254 .P
1255 The NFS client can choose any source port value for its sockets,
1256 but usually chooses a
1257 .I privileged
1258 port.
1259 A privileged port is a port value less than 1024.
1260 Only a process with root privileges may create a socket
1261 with a privileged source port.
1262 .P
1263 The exact range of privileged source ports that can be chosen is
1264 set by a pair of sysctls to avoid choosing a well-known port, such as
1265 the port used by ssh.
1266 This means the number of source ports available for the NFS client,
1267 and therefore the number of socket connections that can be used
1268 at the same time,
1269 is practically limited to only a few hundred.
1270 .P
1271 As described above, the traditional default NFS authentication scheme,
1272 known as AUTH_SYS, relies on sending local UID and GID numbers to identify
1273 users making NFS requests.
1274 An NFS server assumes that if a connection comes from a privileged port,
1275 the UID and GID numbers in the NFS requests on this connection have been
1276 verified by the client's kernel or some other local authority.
1277 This is an easy system to spoof, but on a trusted physical network between
1278 trusted hosts, it is entirely adequate.
1279 .P
1280 Roughly speaking, one socket is used for each NFS mount point.
1281 If a client could use non-privileged source ports as well,
1282 the number of sockets allowed,
1283 and thus the maximum number of concurrent mount points,
1284 would be much larger.
1285 .P
1286 Using non-privileged source ports may compromise server security somewhat,
1287 since any user on AUTH_SYS mount points can now pretend to be any other
1288 when making NFS requests.
1289 Thus NFS servers do not support this by default.
1290 They explicitly allow it usually via an export option.
1291 .P
1292 To retain good security while allowing as many mount points as possible,
1293 it is best to allow non-privileged client connections only if the server
1294 and client both require strong authentication, such as Kerberos.
1295 .SS "Mounting through a firewall"
1296 A firewall may reside between an NFS client and server,
1297 or the client or server may block some of its own ports via IP
1298 filter rules.
1299 It is still possible to mount an NFS server through a firewall,
1300 though some of the
1301 .BR mount (8)
1302 command's automatic service endpoint discovery mechanisms may not work; this 
1303 requires you to provide specific endpoint details via NFS mount options.
1304 .P
1305 NFS servers normally run a portmapper or rpcbind daemon to advertise
1306 their service endpoints to clients. Clients use the rpcbind daemon to determine: 
1307 .IP
1308 What network port each RPC-based service is using
1309 .IP
1310 What transport protocols each RPC-based service supports 
1311 .P
1312 The rpcbind daemon uses a well-known port number (111) to help clients find a service endpoint.
1313 Although NFS often uses a standard port number (2049),
1314 auxiliary services such as the NLM service can choose
1315 any unused port number at random.
1316 .P
1317 Common firewall configurations block the well-known rpcbind port.
1318 In the absense of an rpcbind service,
1319 the server administrator fixes the port number
1320 of NFS-related services so that the firewall
1321 can allow access to specific NFS service ports.
1322 Client administrators then specify the port number
1323 for the mountd service via the
1324 .BR mount (8)
1325 command's
1326 .B mountport
1327 option.
1328 It may also be necessary to enforce the use of TCP or UDP
1329 if the firewall blocks one of those transports.
1330 .SS "NFS Access Control Lists"
1331 Solaris allows NFS version 3 clients direct access
1332 to POSIX Access Control Lists stored in its local file systems.
1333 This proprietary sideband protocol, known as NFSACL,
1334 provides richer access control than mode bits.
1335 Linux implements this protocol
1336 for compatibility with the Solaris NFS implementation.
1337 The NFSACL protocol never became a standard part
1338 of the NFS version 3 specification, however.
1339 .P
1340 The NFS version 4 specification mandates a new version
1341 of Access Control Lists that are semantically richer than POSIX ACLs.
1342 NFS version 4 ACLs are not fully compatible with POSIX ACLs; as such, 
1343 some translation between the two is required
1344 in an environment that mixes POSIX ACLs and NFS version 4. 
1345 .SH FILES
1346 .TP 1.5i
1347 .I /etc/fstab
1348 file system table
1349 .SH BUGS
1350 The generic
1351 .B remount
1352 option is not fully supported.
1353 Generic options, such as
1354 .BR rw " and " ro
1355 can be modified using the
1356 .B remount
1357 option,
1358 but NFS-specific options are not all supported.
1359 The underlying transport or NFS version
1360 cannot be changed by a remount, for example.
1361 Performing a remount on an NFS file system mounted with the
1362 .B noac
1363 option may have unintended consequences.
1364 The
1365 .B noac
1366 option is a mixture of a generic option,
1367 .BR sync ,
1368 and an NFS-specific option
1369 .BR actimeo=0 .
1370 .P
1371 Before 2.4.7, the Linux NFS client did not support NFS over TCP.
1372 .P
1373 Before 2.4.20, the Linux NFS client used a heuristic
1374 to determine whether cached file data was still valid
1375 rather than using the standard close-to-open cache coherency method
1376 described above.
1377 .P
1378 Starting with 2.4.22, the Linux NFS client employs
1379 a Van Jacobsen-based RTT estimator to determine retransmit
1380 timeout values when using NFS over UDP.
1381 .P
1382 Before 2.6.0, the Linux NFS client did not support NFS version 4.
1383 .P
1384 Before 2.6.8, the Linux NFS client used only synchronous reads and writes
1385 when the
1386 .BR rsize " and " wsize
1387 settings were smaller than the system's page size.
1388 .P
1389 The Linux NFS client does not yet support
1390 certain optional features of the NFS version 4 protocol,
1391 such as security negotiation, server referrals, and named attributes.
1392 .SH "SEE ALSO"
1393 .BR fstab (5),
1394 .BR mount (8),
1395 .BR umount (8),
1396 .BR mount.nfs (5),
1397 .BR umount.nfs (5),
1398 .BR exports (5),
1399 .BR nfsd (8),
1400 .BR sm-notify (8),
1401 .BR rpc.statd (8),
1402 .BR rpc.idmapd (8),
1403 .BR rpc.gssd (8),
1404 .BR rpc.svcgssd (8),
1405 .BR kerberos (1)
1406 .sp
1407 RFC 768 for the UDP specification.
1408 .br
1409 RFC 793 for the TCP specification.
1410 .br
1411 RFC 1094 for the NFS version 2 specification.
1412 .br
1413 RFC 1813 for the NFS version 3 specification.
1414 .br
1415 RFC 1832 for the XDR specification.
1416 .br
1417 RFC 1833 for the RPC bind specification.
1418 .br
1419 RFC 2203 for the RPCSEC GSS API protocol specification.
1420 .br
1421 RFC 3530 for the NFS version 4 specification.