[systemd-devel] Antw: Re: [EXT] Re: Run "ipmitool power cycle" after lib/systemd/system-shutdown scripts

Mantas Mikulėnas grawity at gmail.com
Thu Feb 10 13:15:47 UTC 2022


On Thu, Feb 10, 2022 at 3:11 PM Ulrich Windl <
Ulrich.Windl at rz.uni-regensburg.de> wrote:

> >>> Etienne Champetier <champetier.etienne at gmail.com> schrieb am
> 10.02.2022 um
> 12:47 in Nachricht
> <CAOdf3grZ2wUOkJ8Pzu-EM=+ZCKY4b6XK9dyZoh=QpX5HgHJfxA at mail.gmail.com>:
> > Le jeu. 10 févr. 2022 à 11:49, Ulrich Windl
> > <Ulrich.Windl at rz.uni-regensburg.de> a écrit :
> >>
> >> >>> Lennart Poettering <lennart at poettering.net> schrieb am 10.02.2022
> um
> 11:31
> >> in
> >> Nachricht <YgTpdVFRgL+uQoY9 at gardel-login>:
> >> > On Mi, 09.02.22 22:05, Etienne Champetier (
> champetier.etienne at gmail.com)
> >> > wrote:
> >> >
> >> >> Hello systemd hackers,
> >> >>
> >> >> After flashing the firmware of some pcie card I need to power cycle
> >> >> the server to finish the flashing process.
> >> >> For now I have a simple script in lib/systemd/system-shutdown/
> running
> >> >> "ipmitool power cycle" but I would like to make sure it runs after
> >> >> other scripts like fwupd.shutdown or mdadm.shutdown
> >> >>
> >> >> Is there any way to have systemd cleanly power cycle my server
> instead
> >> >> of rebooting it ?
> >> >
> >> > What does "power cycle" entail that "reboot" doesnt? i.e. why doesn't
> >> > "systemctl reboot" suffice?
> >>
> >> My guess is that some smart cards with their own firmware and CPu do not
> >> reboot unless they are power cycled, so maybe if the firmware upgrade on
> the
> >> card does not force it to reboot, it my need a power cycle.
> >>
> >> >
> >> > /usr/lib/systemd/system-shutdown/ drop-ins are executed before the OS
> >> > transitions back into the initrd — the initrd will then detach the
> >> > root fs (i.e. undo what it attached at boot) and actually reboot. This
> >> > means if your command turns off the power source you should stick it
> >> > in the initrd's shutdown logic, and not into
> >> > /usr/lib/systemd/system-shutdown/. If you are using RHEL this means
> >> > into dracut. But adding it there is something to better discuss with
> >> > the dracut community than here.
> >>
> >> My guess is that it would be handled best by some special GRUB boot
> menu
> > entry
> >> (like "boot 'power cycle' once).
> >
> > This is pretty clean but it means going through "BIOS" init twice
> > which can be pretty long on physical servers
>
> Hi!
>
> Of course I have a better solution: Use an external server and just before
> restarting send a command to that server that will, after a carefully tuned
> delay, will trigger the IPMI power-cycle remotely ;-)
> I believe that it's almost impossible to trigger a power cycle through IPMI
> while also doing a clean shutdown/reboot, unless the the IPMI features a
> delayed execution itself.
>

Asking the BMC to power the system off is no different than asking the
system to power itself off – what makes it a "clean shutdown" is stopping
services, syncing and unmounting filesystems, etc. So in theory these
shutdown hooks should do the job.

Though a better place would be a "shutdown initramfs" which runs from a
tmpfs after *all* storage has been unmounted. I think Dracut has that, and
explicitly specifies the order for its shutdown hooks, so it should be
possible to put ipmitool there.

-- 
Mantas Mikulėnas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20220210/84226887/attachment.htm>


More information about the systemd-devel mailing list