Nfs4
Install
- for server:
apt-get install nfs-kernel-server
- for client:
apt-get install nfs-common
Common Setup
- In /etc/default/nfs-common set:
NEED_IDMAPD=yes NEED_GSSD=no
- Edit /etc/idmapd.conf:
Domain = mydomain.com
- Restart the nfs-common service:
sudo /etc/init.d/nfs-common restart
Server Setup
- In /etc/default/nfs-kernel-server set:
NEED_SVCGSSD=no
- Edit /etc/exports to look something like this:
/export/nfs \ 123.45.67.12(rw,sync,insecure,no_subtree_check,anonuid=65534,anongid=65534,fsid=0) \ 123.45.67.13(rw,sync,insecure,no_subtree_check,anonuid=65534,anongid=65534,fsid=0) \ ...
- Export options: http://linux.die.net/man/5/exports
- sync vs async - Always use sync. This asks the server to write data immediately, important when crashes are possible
- restart the services:
/etc/init.d/nfs-kernel-server restart /etc/init.d/nfs-common restart
- Allow clients to access TCP port 2049. Example:
iptables -A INPUT --protocol tcp --dport 2049 --source 123.45.67.89 -m state --state NEW -j ACCEPT
Important Note
There is a problem with the NFS server under Ubuntu versions before 9.04 (Jaunty). Whenever the file server gets rebooted, you need to immediately log in and restart the nfs-common service:
sudo /etc/init.d/nfs-common restart
Client Setup
- Create the mounting directory:
mkdir /nfs
- For a static mount, add something like this to /etc/fstab:
123.45.67.10:/ /nfs nfs4 rw,hard,intr,proto=tcp,port=2049 0 0
Automounting on the client
Follow the instructions at autofs.
Troubleshooting
- https://help.ubuntu.com/community/NFSv4Howto
- Did you add an exception to the firewall?
- If user/group id's are showing up as nobody on the client, you need to restart the nfs-common service on the server:
sudo /etc/init.d/nfs-common restart
- User and group ids must be the same on both client and server. This may be achieved either through passwd/group files or through LDAP.
- Both client and server should be using ntp to sync clocks.
- Use these commands to monitor NFS activity:
rpcinfo -p netstat -tupa
- Check NFS mount options by viewing
/proc/mounts
. - You can get a "Stale NFS file handle" error if the NFS server goes down for awhile. The best solution is to completely unmount and remount, but if you can't unmount, just remount over the existing mount anyway.