shutdown but no power off

Timothy A. Seufert yellowdog-general@lists.terrasoftsolutions.com
Thu Sep 19 15:29:01 2002


At 4:10 PM -0400 9/19/02, Michael George wrote:
>We have the firmware in our XServe set to power up on AC power restore.
>However, this only seems to work if the power was lost with the machine
>running.  If we remove AC power after a shutdown -h, it will not boot w/
>power restoration.
>
>However, pull the plug on it, and it *will* boot.
>
>Seems rather useless to me for any system on on UPS, but what do I know?
>
>Anyway, is there a way I can have our system shutdown and halt but not do
>a power off?  It doesn't seem that shutdown itself allows this.  Even
>invoking "halt" as halt will do a power off.

Looking at the Linux kernel sources, there are two functions 
involved, machine_power_off() and machine_halt().  On most 
architectures these should do different things, but it would appear 
that the PowerMac implementation of machine_halt(), pmac_halt(), 
consists of a call to pmac_power_off().

If a halt without poweroff is important, you should ask the 
linuxppc-dev mailing list how to patch the kernel to accomplish this. 
It is probably as simple as commenting out the call to 
pmac_power_off() in pmac_halt().

>What's the cleanest solution to this?  I guess changing to single user
>runlevel and unmounting the filesystems and waiting for death might work,
>but I'm not even sure we could umount / with the system running...

You should be able to remount / as read-only in single user mode 
("mount -o remount,ro /"), which should get the FS into a safe state 
and flush all dirty buffers.  I just tried this and the only problem 
was that for some reason CUPS did not get stopped when I went from 
runlevel 3 to runlevel 1; I had to stop cupsd before I could 
successfully remount.  (Also, be warned that if you type "mount" to 
check whether the FS is really mounted RO, it will report that / is 
still mounted RW; the real test is to try to create or write to a 
file.)

At this point, if the system loses power, on the next boot you will 
still get a complaint that the FS was not unmounted cleanly 
(apparently even mounting RO sets the "I am mounted" flag in the FS), 
but since the OS should have flushed all dirty data from its caches 
when remounting the FS RO there isn't much chance of losing data.  If 
/ is ext3 the inconvenience is minimal.

If your UPS can accept a command to shut power off, you could have a 
script that takes the system to runlevel 1, shuts down any leftover 
daemons, remounts all FSes RO, and then tells the UPS to kill power. 
That way you wouldn't have to run your UPS batteries all the way down 
until it does a forced kill.
-- 
Tim Seufert