2009-10-09 01:11:09 +00:00
|
|
|
# NFS filesystem mounting -*- shell-script -*-
|
|
|
|
|
|
|
|
# FIXME This needs error checking
|
|
|
|
|
|
|
|
retry_nr=0
|
|
|
|
|
2010-11-10 22:22:48 +00:00
|
|
|
# parse nfs bootargs and mount nfs
|
2009-10-09 01:11:09 +00:00
|
|
|
do_nfsmount()
|
|
|
|
{
|
|
|
|
|
|
|
|
configure_networking
|
|
|
|
|
|
|
|
# get nfs root from dhcp
|
|
|
|
if [ "x${NFSROOT}" = "xauto" ]; then
|
|
|
|
# check if server ip is part of dhcp root-path
|
|
|
|
if [ "${ROOTPATH#*:}" = "${ROOTPATH}" ]; then
|
|
|
|
NFSROOT=${ROOTSERVER}:${ROOTPATH}
|
|
|
|
else
|
|
|
|
NFSROOT=${ROOTPATH}
|
|
|
|
fi
|
|
|
|
|
|
|
|
# nfsroot=[<server-ip>:]<root-dir>[,<nfs-options>]
|
|
|
|
elif [ -n "${NFSROOT}" ]; then
|
|
|
|
# nfs options are an optional arg
|
|
|
|
if [ "${NFSROOT#*,}" != "${NFSROOT}" ]; then
|
|
|
|
NFSOPTS="-o ${NFSROOT#*,}"
|
|
|
|
fi
|
|
|
|
NFSROOT=${NFSROOT%%,*}
|
|
|
|
if [ "${NFSROOT#*:}" = "$NFSROOT" ]; then
|
|
|
|
NFSROOT=${ROOTSERVER}:${NFSROOT}
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "${NFSOPTS}" ]; then
|
|
|
|
NFSOPTS="-o retrans=10"
|
|
|
|
fi
|
|
|
|
|
|
|
|
[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/nfs-premount"
|
|
|
|
run_scripts /scripts/nfs-premount
|
|
|
|
[ "$quiet" != "y" ] && log_end_msg
|
|
|
|
|
|
|
|
if [ ${readonly} = y ]; then
|
|
|
|
roflag="-o ro"
|
|
|
|
else
|
|
|
|
roflag="-o rw"
|
|
|
|
fi
|
|
|
|
|
|
|
|
nfsmount -o nolock ${roflag} ${NFSOPTS} ${NFSROOT} ${rootmnt}
|
|
|
|
}
|
|
|
|
|
|
|
|
# NFS root mounting
|
|
|
|
mountroot()
|
|
|
|
{
|
|
|
|
[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/nfs-top"
|
|
|
|
run_scripts /scripts/nfs-top
|
|
|
|
[ "$quiet" != "y" ] && log_end_msg
|
|
|
|
|
|
|
|
modprobe nfs
|
|
|
|
# For DHCP
|
|
|
|
modprobe af_packet
|
|
|
|
|
|
|
|
wait_for_udev 10
|
|
|
|
|
|
|
|
# Default delay is around 180s
|
2010-11-10 22:22:48 +00:00
|
|
|
delay=${ROOTDELAY:-180}
|
2009-10-09 01:11:09 +00:00
|
|
|
|
2010-11-10 22:22:48 +00:00
|
|
|
# loop until nfsmount succeeds
|
|
|
|
do_nfsmount
|
2009-10-09 01:11:09 +00:00
|
|
|
while [ ${retry_nr} -lt ${delay} ] && [ ! -e ${rootmnt}${init} ]; do
|
|
|
|
[ "$quiet" != "y" ] && log_begin_msg "Retrying nfs mount"
|
2010-11-10 22:22:48 +00:00
|
|
|
/bin/sleep 1
|
2009-10-09 01:11:09 +00:00
|
|
|
do_nfsmount
|
|
|
|
retry_nr=$(( ${retry_nr} + 1 ))
|
2010-11-10 22:22:48 +00:00
|
|
|
[ "$quiet" != "y" ] && log_end_msg
|
2009-10-09 01:11:09 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/nfs-bottom"
|
|
|
|
run_scripts /scripts/nfs-bottom
|
|
|
|
[ "$quiet" != "y" ] && log_end_msg
|
|
|
|
}
|