Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 2555 - netmount hangs if portmap is missing
Summary: netmount hangs if portmap is missing
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: x86 All
: High normal (vote)
Assignee: Martin Schlemmer (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-05-07 17:20 UTC by Jim C. Nasby
Modified: 2003-02-04 19:42 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jim C. Nasby 2002-05-07 17:20:14 UTC
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...
Comment 1 Martin Schlemmer (RETIRED) gentoo-dev 2002-05-14 17:35:46 UTC
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
Comment 2 Markus Krainer 2002-05-16 14:20:33 UTC
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-
Comment 3 Martin Schlemmer (RETIRED) gentoo-dev 2002-05-20 16:04:17 UTC
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.
Comment 4 Markus Krainer 2002-05-21 01:19:58 UTC
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-
Comment 5 Markus Krainer 2002-05-21 12:29:12 UTC
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-



Comment 6 Martin Schlemmer (RETIRED) gentoo-dev 2002-05-21 14:46:22 UTC
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.
Comment 7 Markus Krainer 2002-05-21 22:09:44 UTC
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-
Comment 8 Martin Schlemmer (RETIRED) gentoo-dev 2002-05-26 14:26:44 UTC
I fixed it in a somewhat different way.