NFS

From Segfault
Jump to: navigation, search

Linux

Client

apt-get install nfs-common                 # Debian, Ubuntu
yum install nfs-utils                      # Fedora
zypper install nfs-client                  # openSUSE

Add file systems to mount to /etc/fstab:

host1:/mnt/foo    /mnt/foo      nfs4    nodev,nosuid,noexec,bg,intr,sec=sys,rw,_netdev  0 0
host2:/mnt/bar    /mnt/bar      nfs4    nodev,nosuid,noexec,bg,intr,sec=sys,ro,_netdev  0 0

Note: the _netdev mount option[1] is a hint to be used by the startup scripts:

The filesystem resides on a device that requires network access (used to prevent the system
from attempting to mount these filesystems until  the  network has been enabled on the system).

For Gentoo, make sure that the nfsmount service is started:

sudo rc-update add nfsmount default

Adjust /etc/default/nfs-common as needed:

STATDOPTS="--port 4000 --outgoing-port 4001"

Note: this can be done in /etc/sysconfig/nfs on Fedora or openSUSE systems.

Server

apt-get install nfs-kernel-server          # Debian, Ubuntu
yum install nfs-utils                      # Fedora

Add file systems to be exported to /etc/exports:

/mnt/foo               10.0.0.0/24(rw,async,no_subtree_check,sec=sys)
/mnt/bar               10.0.0.3/32(ro,async,no_subtree_check,all_squash,anonuid=0,anongid=0,sec=sys)
/home                  10.0.1.0/24(rw,no_subtree_check,async,root_squash,sec=sys)

Adjust /etc/default/nfs-common as needed:

STATDOPTS="--port 4000 --outgoing-port 4001"

Adjust /etc/default/nfs-kernel-server as needed:

RPCNFSDCOUNT=16
RPCMOUNTDOPTS="--manage-gids --port 4003"

Note: this can be done in /etc/sysconfig/nfs on Fedora or openSUSE systems.

BSD

tbd...

MacOS X

Client

...

Server

NFS exports are configured via /etc/exports, though its format might be a different from other NFS implementations:

$ cat /etc/exports 
/Volumes/scratch      -maproot=root
/Volumes/data         -ro

To restart the NFS service:

$ launchctl stop  com.apple.nfsd
$ launchctl start com.apple.nfsd

Solaris

Client

We're using NFSv3:

$ grep ^NFS_CLIENT_VERSMAX /etc/default/nfs
NFS_CLIENT_VERSMAX=3

or, via sharectl(1M) (for Solaris 5.11):

sharectl set -p client_versmax=3 nfs

...otherwise we might get:

nfs mount: mount: <mountpoint>:  Not owner
nfs mount: server:/share /mnt: No such file or directory

To automatically mount NFS shares:

$ grep nfs /etc/vfstab
nfsserver:/data     -       /data           nfs     -       yes      ro
 
$ svcadm enable svc:/network/nfs/status svc:/network/nfs/nlockmgr svc:/network/nfs/client

Also, if the NFS-Server is running Linux, its exports have to specifiy the security mode:

$ grep share /etc/exports
/share      10.0.0.0/255.255.255.0(rw,no_subtree_check,async,root_squash,sec=sys)

Server

TBD...

Links

References