5 PATH=$PATH:/sbin:/usr/sbin
7 # XXX needs error handling like ifup/dhclient-script
10 exec > /tmp/nfsroot.$1.$$.out
11 exec 2>> /tmp/nfsroot.$1.$$.out
15 # root is in the form root=nfs[4]:server:path:[options]
19 nfsver=${root%%:*}; root=${root#*:}
20 nfsserver=${root%%:*}; root=${root#*:}
24 # look through the flags and see if any are overridden by the command line
25 # Append a , so we know we terminate
27 while [ -n "$flags" ]; do
33 if [ "$f" = "ro" -o "$f" = "rw" ]; then
37 if [ "$f" = "lock" -o "$f" = "nolock" ]; then
41 nfsflags=${nfsflags+$nfsflags,}$f
46 nfsflags=${nfsflags+$nfsflags,}${nfsrw}
48 # Load the modules so the filesystem type is there
49 modprobe nfs || exit 1
51 # XXX don't forget to move /var/lib/nfs/rpc_pipefs to new /
53 # Start rpcbind and rpc.statd as mount won't let us use locks on a NFSv4
54 # filesystem without talking to them, even though they are unneeded
55 # XXX occasionally saw 'rpcbind: fork failed: No such device' -- why?
56 [ -n "$(pidof rpcbind)" ] || rpcbind
57 [ -n "$(pidof rpc.statd)" ] || rpc.statd
59 # XXX should I do rpc.idmapd here, or wait and start in the new root
60 # XXX waiting assumes root can read everything it needs right up until
63 # XXX really, want to retry in a loop I think, but not here...
65 if [ "$nfsver" = "nfs4" ]; then
66 # XXX really needed? Do we need non-root users before we start it in
67 # XXX the real root image?
68 if [ -z "$(pidof rpc.idmapd)" ]; then
72 # NFSv4 does locks internally
73 exec mount -t nfs4 -o${nfsflags}${nfslock+,$nfslock} \
74 $nfsserver:$nfspath $NEWROOT
77 # NFSv{2,3} doesn't support using locks as it requires a helper to transfer
78 # the rpcbind state to the new root
80 [ -z "$nfslock" -o "$nfslock" = "lock" ] &&
81 echo "Locks unsupported on NFSv{2,3}, using nolock" 1>&2
82 exec mount -t nfs -onolock,$nfsflags $nfsserver:$nfspath $NEWROOT