From owner-freebsd-questions Fri Sep 27 12:48:21 2002 Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E282337B401 for ; Fri, 27 Sep 2002 12:48:19 -0700 (PDT) Received: from posti.pp.htv.fi (posti.pp.htv.fi [212.90.64.50]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9638C43E3B for ; Fri, 27 Sep 2002 12:48:18 -0700 (PDT) (envelope-from Petri.Riihikallio@Metis.fi) Received: from [192.168.0.2] ([212.90.71.47]) by posti.pp.htv.fi (8.11.1/8.11.1) with ESMTP id g8RJmFU04890 for ; Fri, 27 Sep 2002 22:48:15 +0300 (EETDST) Mime-Version: 1.0 X-Sender: metis@pop.clinet.fi Message-Id: Date: Fri, 27 Sep 2002 22:48:13 +0300 To: questions@FreeBSD.ORG From: Petri Riihikallio Subject: Re: How to shut down cleanly by killing power Content-Type: text/plain; charset="us-ascii" ; format="flowed" Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Thanks for your reply! >"sync" is pretty much useless, it doesn't buy you anything. >Particularly, it won't mark your filesystems clean (so fsck >will still have to run on the next boot), and it does not >guarantee that there's no unwritten data left in memory. Yes, this I found out by testing. Still many shutdown scripts include "sync ; sync ; sync" as a mantra. >No. Upon shutdown, the scripts will be executed in reverse >ASCII order. You should rather call it something like >"%%%whatever". There's never a guarantee, however, that >some clever port tries to install a "%%%%%%foo" script in >order to get there first ... Thanks for pointing that out! 'man rc' says just: "The scripts within each directory are executed in lexicographical order." I know the source IS the doc, but it is so slow way to find something, when you don't know what your looking for. >So, maybe the best thing is to add your script at the end >of /etc/rc.shutdown directly. > - - - - >Yes, exactly. This should do: > >umount -f -A >mount -u -o ro / >mount -o ro /usr OK. Any need for 'mount -f -u -o ro /' ? (The -f forces the switch to ro even if files are open for writing) Is there any reason to signal the system daemon processes (syslog, sshd, adjkrntz & co)? The Linux scripts do this with killall5. It sends a signal to all processes except the processes in its own session, so it won't kill the shell that is running the script it was called from. >That's documented in /usr/src/sbin/init/init.c. :-] "The source IS the doc" I studied /usr/src/sys/kern/kern_shutdown.c but I couldn't find where the scripts were called. It is init calling the scripts and then calling kern_shutdown. -- Cheers, Petri Metis / Petri Riihikallio GSM: +358 400 505 939 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message