From owner-freebsd-current Sun Sep 21 03:50:55 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id DAA25556 for current-outgoing; Sun, 21 Sep 1997 03:50:55 -0700 (PDT) Received: from sax.sax.de (sax.sax.de [193.175.26.33]) by hub.freebsd.org (8.8.7/8.8.7) with SMTP id DAA25551; Sun, 21 Sep 1997 03:50:46 -0700 (PDT) Received: (from uucp@localhost) by sax.sax.de (8.6.12/8.6.12-s1) with UUCP id MAA23812; Sun, 21 Sep 1997 12:50:44 +0200 Received: (from j@localhost) by uriah.heep.sax.de (8.8.7/8.8.5) id MAA08389; Sun, 21 Sep 1997 12:26:11 +0200 (MET DST) Message-ID: <19970921122611.AG59280@uriah.heep.sax.de> Date: Sun, 21 Sep 1997 12:26:11 +0200 From: j@uriah.heep.sax.de (J Wunsch) To: stable@freebsd.org Cc: current@freebsd.org Subject: Re: rc.shutdown [was: Another NFS bogon in 2.2-stable?] References: <199709210751.RAA24163@godzilla.zeta.org.au> X-Mailer: Mutt 0.60_p2-3,5,8-9 Mime-Version: 1.0 X-Phone: +49-351-2012 669 X-PGP-Fingerprint: DC 47 E6 E4 FF A6 E9 8F 93 21 E0 7D F9 12 D6 4E Reply-To: joerg_wunsch@uriah.heep.sax.de (Joerg Wunsch) Sender: owner-freebsd-current@freebsd.org X-Loop: FreeBSD.org Precedence: bulk As Bruce Evans wrote: > >Did anybody else notice that shutting down a 2.2-stable machine that > >has NFS file systems mounted never yields a clean shutdown? My 2.2 > > I notice it in -current for a nfs-mounted /usr. It is caused by > some daemons holding nfs files open and taking too long to die. > I use `umount -Af -t nfs' before rebooting. This tends to kill > the daemons early when their fd's go away. (Since you confirm it for -current, too, i've moved the discussion there. Please respect the reply-to.) In my case, it's probably the daemons running off the NFS-mounted /usr/local then. Should we ship an /etc/rc.shutdown by default, that kills off the daemons and unmounts NFS file systems? At least daemons that properly recorded their PID in /var/run/*pid could be killed easily. The following looks like a pretty good default rc.shutdown to me. The idea behind it is also that you can shutdown to single-user, and get an as clean as possible environment. (I didn't make up my mind about non-NFS filesystems, however. This might cause some LKMs to remain busy.) The mess to umount NFS filesystems could be replaced by `umount -Af -t nfs' in -current, but the -A option isn't available yet in 2.2-stable. Does -A correctly handle /etc/fstab reverse order, IOW, would it work if e.g. both /usr, and /usr/local were NFS-mounted? For some unknown reason, this script isn't really run on my 2.2 test machine when doing a `shutdown -h/-r', albeit it is run when doing a plain shutdown to single-user, as well as when typing Ctrl-Alt-Del. Looks like intention, but is IMHO bogus. If i type `shutdown -r', i expect it do perform a clean reboot. (This is the only way to do it when not sitting on the physical console.) Would anybody mind me committing the following script? #!/bin/sh stty status '^T' HOME=/; export HOME PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin export PATH echo -n "Stopping system daemons:" # # Stop by reverse PID order. Not ideal. for file in /var/run/*.pid; do if [ "$file" = "/var/run/*.pid" ]; then break fi pid=$(head -1 "$file") # sendmail needs head -1 name=$(expr "$file" : '/var/run/\(.*\)\.pid') pidlist="$pidlist$pid $name " done echo "$pidlist" | sort -n -r | while read pid name; do if [ "$pid" = "" ]; then break fi echo -n " $name" kill -TERM $pid && rm -f /var/run/$name.pid done echo '.' echo -n "Unloading kernel modules:" modstat | ( read junk # headline while read type id off loadaddr size info rev name; do echo -n " $name" modunload -i $id done ) echo '.' echo -n "Unmounting NFS filesystems:" nfslist=$( mount -t nfs | while read resource on mntpoint junk; do echo "$resource $mntpoint" done ) echo "$nfslist" | while read resource mntpoint; do if [ "$mntpoint" = ""]; then break fi echo -n " $resource" umount -f "$mntpoint" done echo '.' echo -n "Bringing down network interfaces:" ifconfig -a | while read line; do if iface=$(expr "$line" : '\([a-z][a-z]*[0-9][0-9]*\):'); then echo -n " $iface" ifconfig $iface down ifface="$iface" fi if ipaddr=$(expr "$line" : ' *inet \([0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\)' then echo -n " $ipaddr" ifconfig $ifface $ipaddr delete fi done echo '.' -- cheers, J"org joerg_wunsch@uriah.heep.sax.de -- http://www.sax.de/~joerg/ -- NIC: JW11-RIPE Never trust an operating system you don't have sources for. ;-)