zh-CN:NFS Template:Article summary start Template:Article summary text Template:Article summary heading Template:Article summary wiki - Dedicated article for common problems and solutions. Template:Article summary wiki - Deprecated v3 format. Template:Article summary end From Wikipedia: Network File System (NFS) is a distributed file system protocol originally developed by Sun Microsystems in 1984, allowing a user on a client computer to access files over a network in a manner similar to how local storage is accessed.
This article covers the installation of NFSv4.
Both client and server only require the installation of the package.
/etc/idmapd.conf and set the
Domain field to your domain name.
[General] Verbosity = 1 Pipefs-Directory = /var/lib/nfs/rpc_pipefs Domain = atomic [Mapping] Nobody-User = nobody Nobody-Group = nobody
Define any NFS shares in
/etc/exports which are relative to the NFS root. In this example, the NFS root will be
/srv/nfs4 and we will be sharing
# mkdir -p /srv/nfs4/music
Read/Write permissions must be set on the music directory so clients may write to it.
Now mount the actual target share,
/mnt/music to the NFS share via the mount command:
# mount --bind /mnt/music /srv/nfs4/music
To make it stick across server reboots, add the bind mount to
/mnt/music /srv/nfs4/music none bind 0 0
Add directories to be shared and an ip address or hostname(s) of client machines that will be allowed to mount them in
/srv/nfs4/ 192.168.0.1/24(rw,no_subtree_check) /srv/nfs4/music 192.168.0.1/24(rw,no_subtree_check,nohide) # note the nohide option which is applied to mounted directories on the file system.
Users need-not open the share to the entire subnet; one can specify a single IP address or hostname as well.
man exports for detailed settings information.
For more information about all available options see
man 5 exports.
If you modify
/etc/exports while the server is running, you must re-export them for changes to take effect:
# exportfs -ra
Starting the server
The services for the NFS server are
Start them and configure them to start at boot. Read Daemons for more details.
Note that these units require others, which are launched automatically by systemd.
Clients needto connect, but no special setup is required when connecting to NFS 4 servers.
Mounting from Linux
Show the server's exported filesystems:
$ showmount -e servername
Then just mount as normal:
# mount -t nfs4 servername:/srv/nfs4/music /mountpoint/on/client
Using fstab is useful for a server which is always on, and the NFS shares are available whenever the client boots up. Edit
/etc/fstab file, and add an appropriate line reflecting the setup.
servername:/srv/nfs4/music /mountpoint/on/client nfs4 rsize=8192,wsize=8192,timeo=14,intr 0 0
Some additional mount options to consider are include:
rsize value is the number of bytes used when reading from the server. The
wsize value is the number of bytes used when writing to the server. The default for both is 1024, but using higher values such as 8192 can improve throughput. This is not universal. It is recommended to test after making this change.
timeo value is the amount of time, in tenths of a second, to wait before resending a transmission after an RPC timeout. After the first timeout, the timeout value is doubled for each retry for a maximum of 60 seconds or until a major timeout occurs. If connecting to a slow server or over a busy network, better performance can be achieved by increasing this timeout value.
intr option allows signals to interrupt the file operation if a major timeout occurs for a hard-mounted share.
Using autofs is useful when multiple machines want to connect via NFS; they could both be clients as well as servers. The reason this method is preferable over the earlier one is that if the server is switched off, the client will not throw errors about being unable to find NFS shares. See autofs#NFS Network mounts for details.
Mounting from Windows
NFS shares can be mounted from Windows if the "Client for NFS" service is activated (which it is not by default). To install the service go to "Programs and features" in the Control Panel and click on "Turn Windows features on or off". Locate "Services for NFS" and activate it as well as both subservices ("Administrative tools" and "Client for NFS").
Some global options can be set by opening the "Services for Network File System" (locate it with the search box) and right click on client->properties.
To mount a share using Explorer:
Map network drive >
Mounting from OS X
Either export the share with the
insecure flag, and mount using Finder:
Connect to Server >
Or, mount the share using a secure port using the terminal:
# sudo mount -t nfs -o resvport servername:/srv/nfs4 /Volumes/servername
There is a dedicated article NFS Troubleshooting.