decibel@decigen2 init.d $ sudo ./netmount stop * Unmounting network filesystems... and there it sits until I kill it from another process (^C/^Z had no effect). fstab entry: rhome.nfs.ud.com:/rhome /rhome nfs rw,nosuid,bg,intr,soft Shouldn't runscript check to see if portmap actually exists before attempting to do the mount? The netmount script on my machine does have use portmap in the depends() section...
Yes, but use means portmap should be added to the default runlevel .... check that you have it added. For more info, run any rc-script in /etc/init.d/ without arguments, or checkout: http://www.gentoo.org/doc/rc-scripts.html
Same here. I think the reason that netmount hangs is because nfs needs rpc.statd running. When mounting nfs partitions with /etc/init.d/nfsmount it works perfectly. So as there is a rc-script for nfs of it's own, I think it's best to remove nfs from /etc/init.d/netmount. -Markus-
Since this comes up so many times, and nobody with enouth nfs experience have come forward to help fix the netmount script, I think this will be the best solution ... Ill ask around, and let you guys know.
So I tried to integrate nfsmount into netmount with further enhancements (mount only those filesystems where an entry in /etc/fstab exists) The following script should completly eliminate the need for /etc/init.d/nfsmount. NOTE: This is not very well tested (have no more time now) but I will make more tests in the late evening (GMT +2) Maybe someone can make some tests in the meantime, too. // ----- BEGIN /etc/init.d/netmount ----------------- #!/sbin/runscript # Copyright 1999-2002 Gentoo Technologies, Inc. # Distributed under the terms of the GNU General Public License, v2 or later # $Header: /home/cvsroot/gentoo-src/rc-scripts/init.d/netmount,v 1.11 2002/03/10 22:57:28 azarah Exp $ depend() { need net use portmap } start_statd() { # Don't start rpc.statd if already started by init.d/nfs killall -0 rpc.statd &>/dev/null && return 0 ebegin "Starting NFS statd" start-stop-daemon --start --quiet --exec /sbin/rpc.statd 1>&2 eend $? "Error starting NFS statd" } stop_statd() { # Don't stop rpc.statd if it's in use by init.d/nfs killall -0 nfsd &>/dev/null && return 0 # Make sure it's actually running killall -0 rpc.statd &>/dev/null || return 0 # Okay, all tests passed, stop rpc.statd ebegin "Stopping NFS statd" start-stop-daemon --stop --quiet --exec /sbin/rpc.statd 1>&2 eend $? "Error stopping NFS statd" } start() { ebegin "Mounting network filesystems" local ftypes="$(grep -v -E "^\s*(#|$)" /etc/fstab | awk '{print $3}' |\ sort -u | grep -E ^'nfs|quota|smbfs|ncpfs' | \ awk '{printf $1" "}')" for i in ${ftypes} do # start rpc.statd for nfs if [ "${i}"="NFS" -o "${i}"="nfs" ] ; then start_statd fi mount -a -t ${i} >/dev/null done #mount -at coda,nfs,ncpfs,smbfs >/dev/null eend $? } stop() { # umount -art $fstypes doesn't seem to work, so... # NB: we have to check if any network filesystems is mounted, # else mount do not exit cleanly local sig retry local remaining="$(cat /proc/mounts | awk '{ print $3 " " $2 }' | \ grep -E ^'coda|nfs|ncpfs|smbfs' | awk '{ print $2 }' |sort -r)" # just keep things nice and uniform if [ -z "${remaining}" ] then ebegin "Unmounting network filesystems" eend 0 else sig= retry=3 while [ -n "${remaining}" -a "${retry}" -gt 0 ] do if [ "${retry}" -lt 3 ] then ebegin "Unmounting network filesystems (retry)" umount ${remaining} &>/dev/null eend $? "Failed to unmount filesystems this retry" else ebegin "Unmounting network filesystems" umount ${remaining} &>/dev/null eend $? "Failed to unmount filesystems" fi remaining="$(cat /proc/mounts | awk '{ print $3 " " $2 }' | \ grep -E ^'coda|nfs|ncpfs|smbfs' | awk '{ print $2 }' |sort -r)" [ -z "${remaining}" ] && break /bin/fuser -k -m ${sig} ${remaining} &>/dev/null sleep 5 retry=$((${retry} -1)) sig=-9 done fi } // ----- END /etc/init.d/netmount ----------------- -Markus-
Sorry guys, I was completely wrong!! I found out that the only reason that netmount hangs is, that portmap doesen't get started before netmount, because depend() only has "use portmap". If you simply change this to "need portmap" all works fine (at least for me)! -Markus-
OK, here is the difference between USE and NEED: need : will start the service in the need line if not started use : will start the service in the use line if, and only if it is added to the boot or current (for most this is the "default" runlevel) runlevel. Thus, change it back to "use portmap" and do: # rc-update add portmap default then see if it is fixed. The reason why we do not have portmap as a "need", is because not everybody use nfs mounts, and thus do not have portmap installed. "use" is thus a "weak" type of "need", as it functions the same, except that the admin have to add it to the boot or current ("default" for most) runlevel if he is going to use that feature.
Thanks for this detailed explanation - now it works! However, as I think a lot of people will stumble over this, I think it's better to remove nfs from netmount (as stated in comment #2). Another possibility would be to enhance the dependencies with a "need if" directive. In our case this could look smth like: depend() { need net need portmap if (grep -E -v ^'\s*(#|$)' /etc/fstab | awk '{print $3}' | grep -qi ^nfs) } -Markus-
I fixed it in a somewhat different way.