/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 filesystem

+

/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.

</nowiki>}}

</nowiki>}}

Users need-not open the share to the entire subnet; one can specify a single IP address or hostname as well.

Users need-not open the share to the entire subnet; one can specify a single IP address or hostname as well.

+

+

See {{ic|man exports}} for detailed settings information.

{{Note|The {{ic|1=fsid=0}} is required for the root file system being exported. {{ic|/srv/nfs4}} is the NFS root here (due to the {{ic|1=fsid=0}} entry). Everything else that you want to be shared over NFS must be accessible under {{ic|/srv/nfs4}}. Setting an NFS root is required. For exporting directories outside the NFS root, see below.}}

{{Note|The {{ic|1=fsid=0}} is required for the root file system being exported. {{ic|/srv/nfs4}} is the NFS root here (due to the {{ic|1=fsid=0}} entry). Everything else that you want to be shared over NFS must be accessible under {{ic|/srv/nfs4}}. Setting an NFS root is required. For exporting directories outside the NFS root, see below.}}

For more information about all available options see {{ic|man 5 exports}}.

For more information about all available options see {{ic|man 5 exports}}.

−

===== Modifying /etc/exports =====

+

If you modify {{ic|/etc/exports}} while the server is running, you must reexport them for changes to take effect:

−

If you modify {{ic|/etc/exports}} while the server is running, you can reexport them:

+

{{bc|# exportfs -ra}}

{{bc|# exportfs -ra}}

Line 77:

Line 78:

Start them and configure them to start at boot. Read [[Daemons]] for more details.

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.

+

Note that these units require others, which are launched automatically by [[systemd]].

===Client===

===Client===

−

No special setup is required on the client-side when connecting to NFS 4 servers.

+

Clients need {{Pkg|nfs-utils}} to connect, but no special setup is required when connecting to NFS 4 servers.

−

For NFS 2 or 3 servers see [[NFSv3|the NFSv3 article]].

+

====Mounting from Linux====

−

+

−

==Mounting from Linux==

+

Show the server's exported filesystems:

Show the server's exported filesystems:

{{bc|$ showmount -e servername}}

{{bc|$ showmount -e servername}}

Line 91:

Line 90:

{{bc|# mount -t nfs4 servername:/music /mountpoint/on/client}}

{{bc|# mount -t nfs4 servername:/music /mountpoint/on/client}}

−

===Using fstab===

+

=====/etc/fstab Settings=====

Using [[fstab]] is useful for a server which is always on, and the NFS shares are available whenever the client boots up. Edit {{ic|/etc/fstab}} file, and add an appropriate line reflecting the setup.

Using [[fstab]] is useful for a server which is always on, and the NFS shares are available whenever the client boots up. Edit {{ic|/etc/fstab}} file, and add an appropriate line reflecting the setup.

{{hc|/etc/fstab|<nowiki>

{{hc|/etc/fstab|<nowiki>

Line 110:

Line 109:

The {{ic|intr}} option allows signals to interrupt the file operation if a major timeout occurs for a hard-mounted share.

The {{ic|intr}} option allows signals to interrupt the file operation if a major timeout occurs for a hard-mounted share.

−

===Using autofs===

+

=====Using autofs=====

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.

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.

−

== Troubleshooting ==

+

==== Mounting from Windows ====

−

+

−

{{Note|Dedicated article: [[NFS Troubleshooting]].}}

+

−

+

−

== Mounting from Windows ==

+

{{Warning|Serious performance issues may occur (it randomly takes 30-60 seconds to display a folder, 2 MB/s file copy speed on gigabit LAN, ...) to which Microsoft does not have a solution yet.[https://social.technet.microsoft.com/Forums/en-CA/w7itpronetworking/thread/40cc01e3-65e4-4bb6-855e-cef1364a60ac]}}

{{Warning|Serious performance issues may occur (it randomly takes 30-60 seconds to display a folder, 2 MB/s file copy speed on gigabit LAN, ...) to which Microsoft does not have a solution yet.[https://social.technet.microsoft.com/Forums/en-CA/w7itpronetworking/thread/40cc01e3-65e4-4bb6-855e-cef1364a60ac]}}

{{note|Only the Ultimate and Enterprise editions of Windows 7 and the Enterprise edition of Windows 8 include "Client for NFS"}}

{{note|Only the Ultimate and Enterprise editions of Windows 7 and the Enterprise edition of Windows 8 include "Client for NFS"}}

Line 127:

Line 122:

{{Warning|Under Windows the share is addressed by its full path on the server, not just the path relative to the nfsroot! If in doubt run {{ic|showmount -e servername}} from '''cmd.exe'''}}

{{Warning|Under Windows the share is addressed by its full path on the server, not just the path relative to the nfsroot! If in doubt run {{ic|showmount -e servername}} from '''cmd.exe'''}}

−

== Mounting from OS X ==

+

==== Mounting from OS X ====

{{note|OS X by default uses an insecure (>1024) port to mount a share.}}

{{note|OS X by default uses an insecure (>1024) port to mount a share.}}

Either export the share with the {{ic|insecure}} flag, and mount using Finder:

Either export the share with the {{ic|insecure}} flag, and mount using Finder:

Line 137:

Line 132:

{{Warning|Under OS X the share is addressed by its full path on the server, not just the path relative to the nfsroot! If in doubt run {{ic|showmount -e servername}} from the terminal}}

{{Warning|Under OS X the share is addressed by its full path on the server, not just the path relative to the nfsroot! If in doubt run {{ic|showmount -e servername}} from the terminal}}

File system

Note: For security reasons, it is recommended to use an NFS export root which will keep users limited to that mount point only. The following example illustrates this concept.

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 /mnt/music.

# 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 fstab:

/etc/fstab

/mnt/music /srv/nfs4/music none bind 0 0

Exports

Add directories to be shared and an ip address or hostname(s) of client machines that will be allowed to mount them in exports:

/etc/exports

/srv/nfs4/ 192.168.0.1/24(rw,fsid=0,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.

See man exports for detailed settings information.

Note: The fsid=0 is required for the root file system being exported. /srv/nfs4 is the NFS root here (due to the fsid=0 entry). Everything else that you want to be shared over NFS must be accessible under /srv/nfs4. Setting an NFS root is required. For exporting directories outside the NFS root, see below.

For more information about all available options see man 5 exports.

If you modify /etc/exports while the server is running, you must reexport them for changes to take effect:

# exportfs -ra

Starting the server

The services for the NFS server are rpc-idmapd.service and rpc-mountd.service.

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.

Client

Clients need nfs-utils to 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:/music /mountpoint/on/client

/etc/fstab Settings

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.

Note: Additional mount options can be specified here. Consult the NFS man page for further information.

Some additional mount options to consider are include:

rsize=8192 and wsize=8192

timeo=14

intr

The 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.

The 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.

The intr option allows signals to interrupt the file operation if a major timeout occurs for a hard-mounted share.

Using autofs

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

Warning: Serious performance issues may occur (it randomly takes 30-60 seconds to display a folder, 2 MB/s file copy speed on gigabit LAN, ...) to which Microsoft does not have a solution yet.[1]

Note: Only the Ultimate and Enterprise editions of Windows 7 and the Enterprise edition of Windows 8 include "Client for NFS"

NFS shares can be mounted from windows if the "Client for NFS" service is actived (which it is not by default).
To install the service go to "Programs and features" either through the control panel or by typing it in the search box from the start menu and click on "Turn Windows features on or off". Locate the "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 clicking on the client->properties.

Warning: Under Windows the share is addressed by its full path on the server, not just the path relative to the nfsroot! If in doubt run showmount -e servername from cmd.exe

Mounting from OS X

Note: OS X by default uses an insecure (>1024) port to mount a share.

Either export the share with the insecure flag, and mount using Finder:

Go > Connect to Server > nfs://servername/

Or, mount the share using a secure port using the terminal:

# sudo mount -t nfs -o resvport servername:/ /Volumes/servername/

Warning: Under OS X the share is addressed by its full path on the server, not just the path relative to the nfsroot! If in doubt run showmount -e servername from the terminal