3 # nfs This shell script takes care of starting and stopping
7 # description: NFS is a popular protocol for file sharing across TCP/IP \
8 # networks. This service provides NFS server functionality, \
9 # which is configured via the /etc/exports file.
11 # config: /etc/sysconfig/nfsd
13 # Source function library.
14 . /etc/rc.d/init.d/functions
16 # Source networking configuration.
17 if [ ! -f /etc/sysconfig/network ]; then
21 . /etc/sysconfig/network
23 # Check that networking is up.
24 [ ${NETWORKING} = "no" ] && exit 0
26 [ -x /usr/sbin/rpc.nfsd ] || exit 0
27 [ -x /usr/sbin/rpc.mountd ] || exit 0
28 [ -x /usr/sbin/exportfs ] || exit 0
29 [ -s /etc/exports ] || exit 0
31 # Check for and source configuration file otherwise set defaults
32 # TUNE_QUEUE: controls whether to up the size of input queues
33 NFSDCFG=/etc/sysconfig/nfsd
34 if [ -f "$NFSDCFG" ]; then
35 # Tune nfs server settings
40 # Default to NFS version 3.
44 # Number of servers to be started by default
45 [ -z "$RPCNFSDCOUNT" ] && RPCNFSDCOUNT=8
48 [ -z "$RQUOTAD" ] && RQUOTAD=`type -path rpc.rquotad`
50 # Get the initial values for the input sock queues
51 # at the time of running the script.
52 if [ "$TUNE_QUEUE" = "yes" ]; then
53 RMEM_DEFAULT=`/sbin/sysctl -n net.core.rmem_default`
54 RMEM_MAX=`/sbin/sysctl -n net.core.rmem_max`
55 WMEM_DEFAULT=`/sbin/sysctl -n net.core.wmem_default`
56 WMEM_MAX=`/sbin/sysctl -n net.core.wmem_max`
57 # 256kb recommended minimum size based on SPECsfs NFS benchmarks
58 [ -z "$NFS_QS" ] && NFS_QS=262144
61 # See how we were called.
65 # Apply input queue increase for nfs server
66 if [ "$TUNE_QUEUE" = "yes" ]; then
67 /sbin/sysctl -w net.core.rmem_default=$NFSD_QS >/dev/null 2>&1
68 /sbin/sysctl -w net.core.rmem_max=$NFSD_QS >/dev/null 2>&1
69 /sbin/sysctl -w net.core.wmem_default=$NFSD_QS >/dev/null 2>&1
70 /sbin/sysctl -w net.core.wmem_max=$NFSD_QS >/dev/null 2>&1
72 action "Starting NFS services: " /usr/sbin/exportfs -r
73 if [ -n "$RQUOTAD" -a "$RQUOTAD" != "no" ]; then
74 echo -n "Starting NFS quotas: "
78 echo -n "Starting NFS daemon: "
79 daemon rpc.nfsd $RPCNFSDCOUNT
82 if [ -z "$RPCMOUNTDOPTS" ]; then
83 # Let's see if we support NFS version 3.
84 /usr/sbin/rpcinfo -u localhost nfs 3 &>/dev/null
86 RPCMOUNTDOPTS="--no-nfs-version 3"
90 echo -n "Starting NFS mountd: "
91 daemon rpc.mountd $RPCMOUNTDOPTS
93 touch /var/lock/subsys/nfs
94 # reset input queue for rest of network services
95 if [ "$TUNE_QUEUE" = "yes" ]; then
96 /sbin/sysctl -w net.core.rmem_default=$RMEM_DEFAULT >/dev/null 2>&1
97 /sbin/sysctl -w net.core.rmem_max=$RMEM_MAX >/dev/null 2>&1
98 /sbin/sysctl -w net.core.wmem_default=$WMEM_DEFAULT >/dev/null 2>&1
99 /sbin/sysctl -w net.core.wmem_max=$WMEM_MAX >/dev/null 2>&1
104 echo -n "Shutting down NFS mountd: "
107 echo -n "Shutting down NFS daemon: "
110 if [ -n "$RQUOTAD" ]; then
111 echo -n "Shutting down NFS quotas: "
115 # Do it the last so that clients can still access the server
116 # when the server is running.
117 action "Shutting down NFS services: " /usr/sbin/exportfs -au
118 rm -f /var/lock/subsys/nfs
123 if [ -n "$RQUOTAD" ]; then
132 /usr/sbin/exportfs -r
133 touch /var/lock/subsys/nfs
136 if [ ! -f /var/lock/subsys/nfs ] ; then
139 /sbin/pidof rpc.mountd >/dev/null 2>&1; MOUNTD="$?"
140 /sbin/pidof nfsd >/dev/null 2>&1; NFSD="$?"
141 if [ $MOUNTD = 1 -o $NFSD = 1 ] ; then
144 if [ /etc/exports -nt /var/lock/subsys/nfs ] ; then
149 echo "Usage: nfs {start|stop|status|restart|reload}"