1.\" $NetBSD: mount_nfs.8,v 1.52 2021/03/14 02:56:51 rin 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 January 24, 2021 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 23AbCcdilPpqsTUuX 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 NFS file system (rhost:path) 59on to the file system tree at the mount point 60.Ar node . 61The directory specified by 62.Ar node 63is converted to an absolute path before use. 64This command is normally executed by 65.Xr mount 8 . 66It implements the mount protocol as described in RFC 1094, Appendix A and 67.%T "NFS: Network File System Version 3 Protocol Specification" , 68Appendix I. 69.Pp 70The options are: 71.Bl -tag -width indent 72.It Fl 2 73Use the NFS Version 2 protocol. 74.It Fl 3 75Use the NFS Version 3 protocol. 76The default is to try version 3 first, and 77fall back to version 2 if the mount fails. 78.It Fl A 79Disable the attribute cache in the client, making it consult the server 80for the current version of a given file's attributes every time the file 81is accessed. 82.Pp 83By default the attribute cache is enabled, making the client only consult 84the server every handful of seconds. 85This improves performance, however at the cost of the risk of a 86mid-air collision when changes are made simultaneously by different 87NFS clients and/or locally on the NFS server that affect the same file. 88In that case changes made elsewhere may be missed, leading to 89consistency issues. 90.It Fl a Ar maxreadahead 91Set the read-ahead count to the specified value. 92This may be in the range of 0 - 4, and determines how many blocks 93will be read ahead when a large file is being read sequentially. 94Trying a value greater than 1 for this is suggested for 95mounts with a large bandwidth * delay product. 96.It Fl b 97If an initial attempt to contact the server fails, fork off a child to keep 98trying the mount in the background. 99Useful for 100.Xr fstab 5 , 101where the filesystem mount is not critical to multiuser operation. 102.It Fl C 103For UDP mount points, do a 104.Xr connect 2 . 105Although this flag increases the efficiency of UDP mounts it cannot 106be used for servers that do not reply to requests from the 107standard NFS port 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 UDP mount points, do not do a 113.Xr connect 2 . 114This flag is deprecated and connectionless UDP mounts are the default. 115.It Fl D Ar deadthresh 116Set the 117.Dq "dead server threshold" 118to the specified number of round trip timeout intervals. 119After a 120.Dq "dead server threshold" 121of retransmit timeouts, 122.Dq "not responding" 123message is printed to a tty. 124.It Fl d 125Turn off the dynamic retransmit timeout estimator. 126This may be useful for UDP mounts that exhibit high retry rates, 127since it is possible that the dynamically estimated timeout interval is too 128short. 129.It Fl g Ar maxgroups 130Set the maximum size of the group list for the credentials to the 131specified value. 132This should be used for mounts on old servers that cannot handle a 133group list size of 16, as specified in RFC 1057. 134Try 8, if users in a lot of groups cannot get response from the mount 135point. 136.It Fl I Ar readdirsize 137Set the readdir read size to the specified value. 138The value should normally 139be a multiple of 140.Dv DIRBLKSIZ 141that is \*[Le] the read size for the mount. 142.It Fl i 143Make the mount interruptible, which implies that file system calls that 144are delayed due to an unresponsive server will fail with 145.Er EINTR 146when a 147termination signal is posted for the process. 148.It Fl L Ar leaseterm 149Ignored. 150It used to be NQNFS lease term. 151.It Fl l 152Used with NFS Version 3 to specify that the 153.Fn ReaddirPlus 154RPC should be used. 155This option reduces RPC traffic for cases such as 156.Ic "ls -l" , 157but tends to flood the attribute and name caches with prefetched entries. 158Try this option and see whether performance improves or degrades. 159Probably most useful for client to server network 160interconnects with a large bandwidth times delay product. 161.It Fl o Ar options 162Options are specified with a 163.Fl o 164flag followed by a comma separated string of options. 165See the 166.Xr mount 8 167man page for possible options and their meanings. 168.Pp 169The following NFS specific options are also available: 170.Bl -tag -width indent 171.It Cm bg 172Same as 173.Fl b . 174.It Cm conn 175Same as 176.Fl C . 177.It Cm deadthresh Ns = Ns Aq Ar deadthresh 178Same as 179.Fl D Ar deadthresh . 180.It Cm dumbtimer 181Same as 182.Fl d . 183.It Cm intr 184Same as 185.Fl i . 186.It Cm leaseterm Ns = Ns Aq Ar leaseterm 187Same as 188.Fl L Ar leaseterm . 189.It Cm maxgrps Ns = Ns Aq Ar maxgroups 190Same as 191.Fl g Ar maxgroups . 192.It Cm mntudp 193Same as 194.Fl U . 195.It Cm nfsv2 196Same as 197.Fl 2 . 198.It Cm nfsv3 199Same as 200.Fl 3 . 201.It Cm noac 202Same as 203.Fl A . 204.It Cm noresport 205Same as 206.Fl p . 207.It Cm nqnfs 208Same as 209.Fl q . 210.It Cm port Ns = Ns Aq Ar portnumber 211Use the specified port number for NFS requests. 212The default is to query the portmapper for the NFS port. 213.It Cm rdirplus 214Same as 215.Fl l . 216.It Cm readahead Ns = Ns Aq Ar maxreadahead 217Same as 218.Fl a Ar maxreadahead . 219.It Cm rsize Ns = Ns Aq Ar readsize 220Same as 221.Fl r Ar readsize . 222.It Cm soft 223Same as 224.Fl s . 225.It Cm tcp 226Same as 227.Fl T . 228.It Cm udp 229Same as 230.Fl u . 231.It Cm timeo Ns = Ns Aq Ar timeout 232Same as 233.Fl t Ar timeout . 234.It Cm wsize Ns = Ns Aq Ar writesize 235Same as 236.Fl w Ar writesize . 237.El 238.It Fl P 239Use a reserved socket port number. 240This is the default, and available 241for backwards compatibility purposes only. 242.It Fl p 243Do not use a reserved port number for RPCs. 244This option is provided only to be able to mimic the old 245default behavior of not using a reserved port, and should rarely be useful. 246.It Fl q 247A synonym of 248.Fl 3 . 249It used to specify NQNFS. 250.It Fl R Ar retrycnt 251Set the retry count for doing the mount to the specified value. 252The default is 10000. 253.It Fl r Ar readsize 254Set the read data size to the specified value in bytes. 255It should normally be a power of 2 greater than or equal to 1024. 256.Pp 257This should be used for UDP mounts when the 258.Dq "fragments dropped after timeout" 259value is getting large while actively using a mount point. 260Use 261.Xr netstat 1 262with the 263.Fl s 264option to see what the 265.Dq "fragments dropped after timeout" 266value is. 267See the 268.Nm 269.Fl w 270option also. 271.It Fl s 272A soft mount, which implies that file system calls will fail 273after 274.Ar retrans 275round trip timeout intervals. 276.It Fl T 277Use TCP transport instead of UDP. 278This is the default; 279the flag is maintained for backwards compatibility. 280.It Fl t Ar timeout 281Set the initial retransmit timeout to the specified value in 0.1 seconds. 282May be useful for fine tuning UDP mounts over internetworks 283with high packet loss rates or an overloaded server. 284Try increasing the interval if 285.Xr nfsstat 1 286shows high retransmit rates while the file system is active or reducing the 287value if there is a low retransmit rate but long response delay observed. 288Normally, the -d option should be specified when using this option to manually 289tune the timeout 290interval. 291The default is 3 seconds. 292.It Fl U 293Force the mount protocol to use UDP transport, even for TCP NFS mounts. 294This is necessary for some old 295.Bx 296servers. 297.It Fl u 298Use UDP transport instead of TCP. 299This may be necessary for some very old servers. 300.It Fl w Ar writesize 301Set the write data size to the specified value in bytes. 302.Pp 303The same logic applies for use of this option as with the 304.Nm 305.Fl r 306option, but using the 307.Dq "fragments dropped after timeout" 308value on the NFS server instead of the client. 309Note that both the 310.Fl r 311and 312.Fl w 313options should only be used as a last ditch effort at improving performance 314when mounting servers that do not support TCP mounts. 315.It Fl X 316Perform 32 <-> 64 bit directory cookie translation for version 3 mounts. 317This may be needed in the case of a server using the upper 32 bits of 318version 3 directory cookies, and when you are running emulated binaries 319that access such a filesystem. 320Native 321.Nx 322binaries will never need this option. 323This option introduces some overhead. 324.It Fl x Ar retrans 325Set the retransmit timeout count for soft mounts to the specified value. 326The default is 10. 327.El 328.Sh EXAMPLES 329The simplest way to invoke 330.Nm 331is with a command like: 332.Pp 333.Dl "mount -t nfs remotehost:/filesystem /localmountpoint" 334.Pp 335It is also possible to automatically mount filesystems at boot from your 336.Pa /etc/fstab 337by using a line like: 338.Pp 339.Dl "remotehost:/home /home nfs rw 0 0" 340.Sh PERFORMANCE 341As can be derived from the comments accompanying the options, performance 342tuning of NFS can be a non-trivial task. 343Here are some common points 344to watch: 345.Bl -bullet -offset indent 346.It 347Increasing the read and write size with the 348.Fl r 349and 350.Fl w 351options respectively will increase throughput if the network 352interface can handle the larger packet sizes. 353.Pp 354The default size for NFS version 2 is 8K when using UDP, 35564K when using TCP. 356.Pp 357The default size for NFS version 3 is platform dependent: 358on 359.Nx Ns /aarch64 , 360.Nx Ns /amd64 , 361and 362.Nx Ns /i386 , 363the default is 32K, for other platforms it is 8K. 364Values over 32K are only supported for TCP, 365where 64K is the maximum. 366.Pp 367Any value over 32K is unlikely to get you more performance, unless 368you have a very fast network. 369.It 370If the network interface cannot handle larger packet sizes or a 371long train of back to back packets, you may see low performance 372figures or even temporary hangups during NFS activity. 373.Pp 374This can especially happen with older Ethernet network interfaces. 375What happens is that either the receive buffer on the network 376interface on the client side is overflowing, or that similar events 377occur on the server, leading to a lot of dropped packets. 378.Pp 379In this case, decreasing the read and write size, using TCP, 380or a combination of both will usually lead to better throughput. 381Should you need to decrease the read and write size for all your NFS 382mounts because of a slow Ethernet network interface 383.Pq e.g. a USB 1.1 to 10/100 Ethernet network interface , 384you can use 385.Pp 386.Bl -ohang -compact 387.It Cd options NFS_RSIZE=value 388.It Cd options NFS_WSIZE=value 389.El 390.Pp 391in your kernel 392.Xr config 1 393file to avoid having do specify the sizes for all mounts. 394.It 395For connections that are not on the same LAN, 396and/or may experience packet loss, using TCP is strongly recommended. 397.El 398.Sh ERRORS 399Some common problems with 400.Nm 401can be difficult for first time users to understand. 402.Pp 403.Dl "mount_nfs: can't access /foo: Permission denied" 404.Pp 405This message means that the remote host is either not exporting 406the filesystem you requested, or is not exporting it to your host. 407If you believe the remote host is indeed exporting a filesystem to you, 408make sure the 409.Xr exports 5 410file is exporting the proper directories. 411.Pp 412A common mistake is that 413.Xr mountd 8 414will not export a filesystem with the 415.Fl alldirs 416option, unless it 417is a mount point on the exporting host. 418It is not possible to remotely 419mount a subdirectory of an exported mount, unless it is exported with the 420.Fl alldirs 421option. 422.Pp 423The following error: 424.Pp 425.Dl "NFS Portmap: RPC: Program not registered" 426.Pp 427means that the remote host is not running 428.Xr mountd 8 . 429The program 430.Xr rpcinfo 8 431can be used to determine if the remote host is running nfsd, and mountd by issuing 432the command: 433.Pp 434.Dl rpcinfo -p remotehostname 435.Pp 436If the remote host is running nfsd, and mountd, it would display: 437.Pp 438.Dl "100005 3 udp 719 mountd" 439.Dl "100005 1 tcp 720 mountd" 440.Dl "100005 3 tcp 720 mountd" 441.Dl "100003 2 udp 2049 nfs" 442.Dl "100003 3 udp 2049 nfs" 443.Dl "100003 2 tcp 2049 nfs" 444.Dl "100003 3 tcp 2049 nfs" 445.Pp 446The error: 447.Pp 448.Dl "mount_nfs: can't get net id for host" 449.Pp 450indicates that 451.Nm 452cannot resolve the name of the remote host. 453.Sh SEE ALSO 454.Xr nfsstat 1 , 455.Xr mount 2 , 456.Xr unmount 2 , 457.Xr options 4 , 458.Xr exports 5 , 459.Xr fstab 5 , 460.Xr mount 8 , 461.Xr mountd 8 , 462.Xr rpcinfo 8 463.Rs 464.%R RFC 1094 465.%D March 1989 466.%T "NFS: Network File System Protocol specification" 467.Re 468.Rs 469.%R RFC 2623 470.%D June 1999 471.%T "NFS Version 2 and Version 3 Security Issues and the NFS Protocol's Use of RPCSEC_GCC and Kerberos V5" 472.Re 473.Rs 474.%R RFC 2624 475.%D June 1999 476.%T "NFS Version 4 Design Considerations" 477.Re 478.Rs 479.%R RFC 2695 480.%D September 1999 481.%T "Authentication Mechanisms for ONC RPC" 482.Re 483.Sh HISTORY 484A version of the 485.Nm 486utility appeared in 487.Bx 4.4 . 488.Sh CAVEATS 489An NFS server should not mount its own exported file systems 490.Pq loopback fashion 491because doing so is fundamentally prone to deadlock. 492