Long version:
Many UPS-es do not support cutting power at all, or ignore the command
to cut the power in certain situations. There was a workaround for that:
instead of powering the machines off, they had to halt, then wait a
reasonable amount of time (during which the UPS should turn off), and
then reboot - in case power came back and the UPS did not power-cycle
its load.


This is fragile as you have no idea whether power returned or not and
risk hard power off in the middle of next boot.

Usually, you set it to wait for enough time for the UPS to drain; either it will drain and power off, or the power is back by then. The risk of power "having been back, but cut off again just now" is miniscule compared to the risk of having to manually power the machines on (and by the way, UPS-es do NOT like to be powered on with no load).


Now that systemd manages the shutdown procedure, I don't know if it's
possible to achieve the same behaviour (and thus make NUT work with
systemd).

As already mentioned, it is ouside of scope of OS actually. How you did
it before systemd?

It was actually a feature of NUT - and a default and recommended feature at some moment.
See this, from their FAQ:
http://networkupstools.org/docs/FAQ.html#_i_8217_m_facing_a_power_race
And this - https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=835634
(there is a link to an old discussion about implementing this feature).
Now it doesn't work anymore, and I'm trying to find a new solution...


But since it's systemd, maybe we can make this even better!
There were some concerns that it's not a good idea to simply "halt the
system"; what we should do is flush all the drives' cache and unload
their heads, which can only be done *properly* from the kernel. (See
this old Debian bug:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=358696 ) So maybe with
systemd, we can actually not simply "halt" the system, but make all the
necessary preparations in order to ensure that cutting power is safe?

So your question is misleading. You did not halt (in proper sense) but
rather left OS lingering before doing halt.

There were some concerns about this not being a "proper halt" (in that old thread); I thought maybe now it's possible to solve that problem as well, seeing that systemd is all about removing the need for such scripts and doing things more properly instead.


>> Short version: is it possible with systemd to have the machine halt,
>> wait for a few minutes and then reboot?
When system halts OS kernel is stopped and control is returned to
firmware. So the only thing you can do is to program firmware to reboot
after some delay.

So the best way to implement this would be in the kernel - implement a "halt-wait-reboot" function that would do everything correctly...


systemd supports switching back to initramfs instead of directly halting
system. This allows you to implement your logic there after everything
is completely shut down and unmounted (you probably need to unmount old
root manually though). You can even monitor UPS from initramfs and only
reboot when it reports power is back to make it safe.

This may be the best idea without touching the kernel. But it still can't go through the "proper" halt procedure with syncing and unloading the drives, correct?..


--
darkpenguin
_______________________________________________
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel

Reply via email to