- 1 Installing
- 2 Configuring
- 3 Mounting from Windows
- 4 Mounting from OS X
- 5 Troubleshooting
Both client and server only require thepackage.
The NTP system is recommended to sync both the server and the clients to the highly accurate NTP servers available on the Internet.
/etc/idmapd.conf and define a Domain.
[General] Verbosity = 1 Pipefs-Directory = /var/lib/nfs/rpc_pipefs Domain = atomic [Mapping] Nobody-User = nobody Nobody-Group = nobody
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
# mkdir -p /srv/nfs4/music
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:
/srv/nfs4/ 192.168.0.0/24(rw,fsid=0,no_subtree_check) /srv/nfs4/music 192.168.0.0/24(rw,no_subtree_check,nohide) # note the nohide option which is applied to mounted directories on the filesystem
Users need-not open the share to the entire subnet; one can specify a single IP address or hostname as well.
fsid=0is required for the root filesystem being exported.
/srv/nfs4is the NFS root here (due to the
fsid=0entry). 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.
Starting the Server
To start the NFS server, use:
# systemctl start nfsd.service rpc-idmapd.service rpc-mountd.service rpcbind.service
The client configuration only involves the
/etc/idmapd.conf and define the same Domain specified in the server's config:
[General] Verbosity = 1 Pipefs-Directory = /var/lib/nfs/rpc_pipefs Domain = atomic [Mapping] Nobody-User = nobody Nobody-Group = nobody [Translation] Method = nsswitch
Starting the client
To start the NFS client:
# systemctl start nfsd.service rpc-idmapd.service
Show the server's exported filesystems:
showmount -e servername
Then just mount as normal:
# mount -t nfs4 servername:/music /mountpoint/on/client
Consult the Systemd/RemoteFilesystem page and make sure to enable rpc-idmapd.service for user id mapping.
After adding the daemons, auto mounting of NFS shares can be handled in one of two ways:
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 setup.
servername:/music /mountpoint/on/client nfs4 defaults 0 0
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 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.
showmount -e servernamefrom cmd.exe
Mounting from OS X
Either export the share with the
insecure flag, and mount using Finder:
- Go > Connect to Server >
Or, mount the share using a secure port using the terminal:
# sudo mount -t nfs -o resvport server:/ /Volumes/server/
exportfs: /etc/exports:2: syntax error: bad option list
Delete all space from the option list in
mount.nfs4: No such device
Check that you have loaded the
lsmod | grep nfs
and if previous returns empty or only nfsd-stuff, do
mount.nfs4: access denied by server while mounting
Check that the permissions on your client's folder are correct. Try using 755.
If you find that you cannot set the permissions on files properly, make sure the user/group you are chowning are on both the client and server.
If that does not help, try modifying these lines in
# /etc/conf.d/nfs-common.conf # Do you want to start the statd daemon? It is not needed for NFSv4. NEED_STATD="no" # Do you want to start the idmapd daemon? It is only needed for NFSv4. NEED_IDMAPD="yes"
Restart the nfs-common daemon for the changes to take effect. I restarted all the other daemons as well, just to be sure.
group/gid permissions issues
If NFS shares mount fine, and are fully accessible to the owner, but not to group members; check the number of groups that user belongs to. NFS has a limit of 16 on the number of groups a user can belong to. If you have users with more then this, you need to enable the
--manage-gids start-up flag for
rpc.mountd on the NFS server.
/etc/conf.d/nfs-server.conf # Options for rpc.mountd. # If you have a port-based firewall, you might want to set up # a fixed port here using the --port option. # See rpc.mountd(8) for more details. MOUNTD_OPTS="--manage-gids"
If you got error such as this:
mount.nfs: rpc.statd is not running but is required for remote locking. mount.nfs: Either use '-o nolock' to keep locks local, or start statd. mount.nfs: an incorrect mount option was specified
To fix this, you need to change the "NEED_STATD" value in:
Remember to start all the services - nfsd.service rpc-idmapd.service rpc-mountd.service rpcbind.service, not just the nfsd.