Wednesday, June 18, 2014

Setting up NFSv4

This is a short how to for setting up NFS version 4.

NFSv4 can handle several connections via one port (2049), this is much simpler to enable in firewall, than several ports for NFSv3. It has a bit different approach for how to setup exports.



First thing (optional) is to tell nfsd to run only in version 4. Change following line in /etc/nfsmount.conf:
Nfsvers=4
Then setup /etc/exports (export folders will be created in the next step):
/mnt/nfs4_common krisko(ro,sync,fsid=0,no_subtree_check) 172.16.0.5(ro,sync,fsid=0,no_subtree_check)
/mnt/nfs4_common/transmission-data krisko(rw,sync,no_subtree_check,nohide)
/mnt/nfs4_common/transmission-data 172.16.0.5(rw,sync,no_subtree_check,nohide)
Notice the first line, where all hosts have to be added in order to mount nfs exports. Important directive is the fsid=0.

Exports folders:
According to the above example, we need to create /mnt/nfs4_common/transmission-data, where nfs4_common is "root" for other mount points.
Now you need to mount transmission's data folder to transmission-data:
mount -o bind /mnt/transmission /mnt/nfs4_common/transmission-data
or in fstab: 
/mnt/transmission    /mnt/nfs4_common/transmission-data          none  bind,noauto   0  0
Start nfs services on server (rpc-mountd) and mount transmission-data folder on client:
mount -o soft rasppi:transmission-data /mnt/transmission

Troubleshooting:
Using command df -h on mounted NFS shows  nfsMachine://nfs_mountpoint. Notice the double //. This could be caused by wrong mountpoint setup. Check if you have mounted some folder into your mount point (mount -o bind some_folder /mnt/nfs4_common/nfs_mountpoint).

If you need to mount NFS mounts as root, you have to specify anonuid and anongid options in /etc/exports file (anonuid=0,anongid=0).

No comments:

Post a Comment