NFSv4

From ArchWiki
Revision as of 06:32, 12 October 2010 by Mustard (Talk | contribs) (Exports: changed 'seens' to 'seems')

Jump to: navigation, search

Template:I18n links start Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n links end

Merge-arrows-2.pngThis article or section is a candidate for merging with Nfs.Merge-arrows-2.png

Notes: please use the second argument of the template to provide more detailed indications. (Discuss in Talk:NFSv4#)

NFSv4, network file system version 4, is the new version of NFS (for setting up the older NFSv3, see Nfs) with new features like strong authentication and integrity via Kerberos and SPKM-3, improved performance, safe file caching, lock migration, UTF-8, ACLs and better support for Windows file sharing semantics.

This article covers installing and configuring NFSv4.

Installing

Both client and servers require the Template:Package Official package. Install with pacman:

# pacman -S nfs-utils

Configuring

Server

The server configuration is very thorough.

Exports

First we'll need to edit our exports in Template:Filename. A typical NFSv4 export would look like this:

/export    192.168.0.12(rw,fsid=0,no_subtree_check,async,no_root_squash)
/export/music 192.168.0.12(rw,no_subtree_check,async,no_root_squash)
Note: To allow ranges of addresses, the old-style 192.168.0.*-Scheme is no longer supported with nfs4. Use 192.168.0.0/24 or somesuch to specify such exports. (This did work with non-nfs4-exports, and no longer does. The error reported is "no such file or directory" when mounting, which makes troubleshooting a pain.)

/export is the NFS root here (due to the Template:Codeline entry). Everything else that you want to be shared over NFS must be accessible under /export.

Note: Settings a NFS root seems to be required.

For exporting directories outside the NFS root, see below.

Note: The Template:Codeline option means that root on the client is also considered root on the server. This is of course a security risk. Remove it if you don't need it.
Exporting directories outside your NFS root

To do this, you'll need to use bind mounts. For example, to bind /home/john to /export/john:

# mount --bind /home/john /export/john

Then, /export/john needs to be added to Template:Filename:

/export    192.168.0.12(rw,fsid=0,no_subtree_check,async,no_root_squash)
/export/music 192.168.0.12(rw,no_subtree_check,async,no_root_squash)
/export/john 192.168.0.12(rw,no_subtree_check,async,no_root_squash,nohide)

The Template:Codeline option is required, because the kernel NFS server automatically hides mounted directories. To add the bind mount to Template:Filename:

/home/john    /export/john    none    bind  0 0

ID mapping

Then, Template:Filename needs to be edited. You'll need to at the very least specify your Domain there. Example:

[General]

Verbosity = 1
Pipefs-Directory = /var/lib/nfs/rpc_pipefs
Domain = archlinux.org

[Mapping]

Nobody-User = nobody
Nobody-Group = nobody

Starting the server

To start the NFS server, just do:

# /etc/rc.d/rpcbind start
# /etc/rc.d/nfs-common start
# /etc/rc.d/nfs-server start

If you want to tweak the configuration, feel free to edit Template:Filename to fit your needs.

Client

The client configuration is more simple.

Client ID mapping

Template:Filename needs to be edited on all clients and the Domain entry should be identical to the one on the server. Example:

[General]

Verbosity = 1
Pipefs-Directory = /var/lib/nfs/rpc_pipefs
Domain = archlinux.org

[Mapping]

Nobody-User = nobody
Nobody-Group = nobody

[Translation]
Method = nsswitch
Note: On a client only setup make sure rpc.idmapd is running. The nfs-common daemon usually auto-detects whether rpc.idmapd has to be started, but it might fail if there aren't any nfs4 mount entries in Template:Filename or if Template:Filename is empty (which both might be the case if you are using autofs to mount the nfs4 shares). In this case set NEED_IDMAPD="yes" in Template:Filename.

Mounting the partitions on the client

On the client, to mount the NFSv4 partition: Make sure that nfs module is loaded. (lsmod | grep nfs). If not execute the next command "modprobe nfs"

# /etc/rc.d/rpcbind start
# /etc/rc.d/nfs-common start
# mount -t nfs4 server:/ /mnt/server/
# mount -t nfs4 server:/music /mnt/music/
# mount -t nfs4 server:/john /mnt/john

Replacing 'server' with the hostname or IP address of your NFS server and of course 'server', 'music' and 'john' with the names of whatever directories you exported on the server.

Note: the root of the path on the server is the NFS root specified; all paths must be specified relative to it.

If you want the NFS volumes to mount automatically on bootup, add them to Template:Filename.

Client & Server: Time Synchronization

In order for NFS to function properly, both server and client must have closely matching time values. If the clocks on the clients differ from the server too much, then basic functions like file copy operations may hang for a very long time leaving the system unusable until they resume. The clocks do not have to match to micro/nano second accuracies, but ideally they should be within 1 second of each other.

The NTP system is recommended to sync both the server and the clients to the highly accurate NTP servers available on the Internet. For a small system like a home network, the ntpdate utility may be used to sync both servers and clients to the same time. For a larger installation, it may be desirable to install an OpenNTP server (see NTP) onto the same machine acting as the NFS server, and then all clients on the network would sync time values from the server. This has the advantage of lowering the stress on the external NTP servers, and in assuring that the NFS clients will use the exact time that the NFS server has, even if the NFS server experiences some drift.

Troubleshooting

Common problems and how to overcome them

messages.log contains "nfsdopenone: Opening /proc/net/rpc/nfs4.nametoid/channel failed: errno 2 (No such file or directory)"

Add 'nfsd' to /etc/rc.conf modules array (NOTE: you may need to add "Verbosity = 3" to /etc/idmapd.conf and restart the services above to receive the error)

exportfs: /etc/exports:2: syntax error: bad option list

Delete all space from the option list in /etc/exports

mount.nfs4: No such device

Check that you have loaded nfs module

lsmod | grep nfs

and if previous returns empty or only nfsd-stuff, do

modprobe nfs

mount.nfs4: access denied by server while mounting

Check that the permissions on your client's folder are correct ('755' worked for me --Zenlord 12:01, 7 May 2010 (EDT))