Re: [systemd-devel] Halt then reboot

2016-09-28 Thread Che
I wonder if it's possible to discuss matters, in any list, without
everything coming out looking like an insult and/or a put-down...
:/



On Sun, Sep 18, 2016 at 3:17 PM, Dark Penguin  wrote:

> 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...
>>>
>>
>> So you do not even bother to describe how it worked before so others may
>> suggest how it can be (re-)implemented using systemd? Oh, well ...
>>
>
> No, that's not what I meant! Instead of trying to describe it myself, I've
> posted a link to their website where they describe the procedure
> first-hand! Basically, there is a "shutdown script" (though I'm not exactly
> sure where is it), which is apparently executed right before halting, so
> you can put "sleep" and "reboot" there. I was wondering if there is a
> similar thing in systemd.
>
>
> 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?..
>>>
>>
>> I have no idea what "unloading the drives" means.
>>
>
> That's why I've posted the second link: in that bug discussion, one person
> is explaining why this is a bad idea. In general, only the kernel can do
> "proper" halt, which among other things includes unloading the heads from
> the hard drive so that it is ready to be powered off (and apparently
> "hdparm -y" does not cut it somehow).
>
>
> --
> darkpenguin
>
> ___
> systemd-devel mailing list
> systemd-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/systemd-devel
>
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Halt then reboot

2016-09-18 Thread Dark Penguin

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...


So you do not even bother to describe how it worked before so others may
suggest how it can be (re-)implemented using systemd? Oh, well ...


No, that's not what I meant! Instead of trying to describe it myself, 
I've posted a link to their website where they describe the procedure 
first-hand! Basically, there is a "shutdown script" (though I'm not 
exactly sure where is it), which is apparently executed right before 
halting, so you can put "sleep" and "reboot" there. I was wondering if 
there is a similar thing in systemd.




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?..


I have no idea what "unloading the drives" means.


That's why I've posted the second link: in that bug discussion, one 
person is explaining why this is a bad idea. In general, only the kernel 
can do "proper" halt, which among other things includes unloading the 
heads from the hard drive so that it is ready to be powered off (and 
apparently "hdparm -y" does not cut it somehow).



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


Re: [systemd-devel] Halt then reboot

2016-09-17 Thread Andrei Borzenkov
17.09.2016 14:23, Dark Penguin пишет:
>>> 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:

So you do not even bother to describe how it worked before so others may
suggest how it can be (re-)implemented using systemd? Oh, well ...

> 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...
> 
> 
...
> 
> 
>> 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?..
> 
> 

I have no idea what "unloading the drives" means.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Halt then reboot

2016-09-17 Thread Reindl Harald



Am 17.09.2016 um 13:23 schrieb Dark Penguin:

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)


that risk is *not* miniscule and i have even seen UPS after power back 
too empty to stand the load peak of machines without power management in 
their early state after power on them and cutt off within seconds while 
machines booting - not 100% sure what happened but i was in the room and 
line back for sure uninterrupted


what all that crap would really need is that a UPS software completly 
*shutdown* the machines (in the best case staged - unimportant stuff 
first to keep critical longer online and maybe survive before batteries 
are empty) and the UPS after line is back *long enough and not just now* 
sends a wakeup-on-lan to them, all that routers/switches stuff is coming 
back after a hard power off when power returns


the "UPS-es do NOT like to be powered on with no load" don't happen in 
the real world since you hav enot only by managament software powered 
down machines but a ton of networking stuff

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


Re: [systemd-devel] Halt then reboot

2016-09-17 Thread Dark Penguin

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


Re: [systemd-devel] Halt then reboot

2016-09-16 Thread Andrei Borzenkov
16.09.2016 20:20, Dark Penguin пишет:
> Greetings!
> 
> 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.

> 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.

> 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?

> 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.

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.

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


[systemd-devel] Halt then reboot

2016-09-16 Thread Dark Penguin

Greetings!

Short version: is it possible with systemd to have the machine halt, 
wait for a few minutes and then reboot?


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.


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). 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?



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