Date: Fri, 27 Sep 2002 16:54:03 +0300 From: Petri Riihikallio <Petri.Riihikallio@Metis.fi> To: "Brian T. Schellenberger" <bts@babbleon.org>, questions@FreeBSD.ORG Subject: Re: How to shut down cleanly by killing power Message-ID: <a05111b01b9ba0d215041@[192.168.0.2]> In-Reply-To: <200209270829.51463.bts@babbleon.org> References: <a05111b04b9b9eae5d18f@[192.168.0.2]> <200209270829.51463.bts@babbleon.org>
next in thread | previous in thread | raw e-mail | index | archive | help
>The fact of the matter is that if the timing is *just* wrong you >probably can't automatically recover. How likely is that to happen? Power outages are rare and short around here. I remember one that lasted for an hour in the last five years. It made headlines. My UPS is good for ca. 15 min. It is mainly intended for a safe shutdown rather than keeping the system up. The runtime is roughly the same as a "typical" power shortage. It takes a while for the power company to notice the outage, locate the reason, isolate it, and start supplying power some other route. This makes the deadlock look possible. On the other hand, my system usually shuts down quite quickly: 15 - 20 seconds. Only if there are some stuck processes it could take over a minute when init kindly waits for the processes to die before it uses violence. I have no data about the distribution of the outages, but the likeliness could be of the order of one out of ten or twenty. Considering the heated debates about the lengths of the encryption keys and other security measures in FreeBSD, this should be solved in a reasonable way. >But, if you want to be "super safe," then you should be able to >"shutdown" rather than than "shutdown -h" or "shutdown -p." This >should do most of the steps of shutdown and get all the users off to >make partitions non-busy. It may even umount all the partitions; I >can't quite recall. > >Then it will start up /bin/sh. > >I can't recall whether /bin/sh will run any of the 'normal' startup >scripts under this circumstance, but even if it does not you can >replace it with a munged one that does . . . > >But the idea would be that on power-down you set a special >"powering-down" file just before you issue the "shutdown." > >The /bin/csh startup scripts check and if that is set, they go into >"shutdown mode", which umounts all but the root partition, remount the >root partition read-only, and then the simply sleep for 120 seconds or >so, and then "shutdown -r now." (Of course it should remove that >special marker file before it does anything else lest the system go >into a loop.) > >Now, one of two things happens: either you really *did* power off, in >which case the "sleep" never wakes up, because without power it can't >go on. Then when you get power back, the BIOS does its thing and you >reboot. Or the power never went off, in which after two minutes >everything reboots. This is a novel idea! I'll have to do some reaseach. I thought about sending init the TERM signal, which puts it in single user mode, but my script wouldn't survive it. I couldn't figure out how to continue the shutdown script. The powering-down flag is already available. Both NUT and apcupsd create such a file automatically for themselves. -- 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?a05111b01b9ba0d215041>