Discussion:
Custom power off
(too old to reply)
Zygmunt Ptak
2017-12-20 17:54:47 UTC
Permalink
Hi systemd devs and users,

I want to implement custom power off method.
I added to the yocto script: /usr/sbin/halt.local which will power off
my machine.

But from what I see it is not correct.
Ive got this from my machine:

[ OK ] Reached target Shutdown.
Starting /usr/sbin/halt.local Compatibility...
My power off
[ 76.916101] EXT4-fs (mmcblk1p1): re-mounted. Opts: (null)
[ OK ] Started /usr/sbin/halt.local Compatibility.
[ OK ] Reached target Final Step.
Starting Power-Off...
[ 77.102708] systemd-shutdown[1]: Sending SIGTERM to remaining processes...
[ 77.124900] systemd-journald[203]: Received SIGTERM from PID 1
(systemd-shutdow).
[ 77.174386] systemd-shutdown[1]: Sending SIGKILL to remaining processes...
[ 77.194122] systemd-shutdown[1]: Unmounting file systems.
[ 77.200107] systemd-shutdown[1]: Remounting '/var/volatile'
read-only with options ''.
[ 77.208187] systemd-shutdown[1]: Unmounting /var/volatile.
[ 77.253911] systemd-shutdown[1]: Remounting '/tmp' read-only with options ''.
[ 77.261142] systemd-shutdown[1]: Unmounting /tmp.
[ 77.314075] systemd-shutdown[1]: Remounting '/' read-only with
options 'data=ordered'.
[ 77.322732] EXT4-fs (mmcblk1p1): re-mounted. Opts: data=ordered
[ 77.328818] systemd-shutdown[1]: Remounting '/' read-only with
options 'data=ordered'.
[ 77.336983] EXT4-fs (mmcblk1p1): re-mounted. Opts: data=ordered
[ 77.342981] systemd-shutdown[1]: Remounting '/' read-only with
options 'data=ordered'.
[ 77.351167] EXT4-fs (mmcblk1p1): re-mounted. Opts: data=ordered
[ 77.357245] systemd-shutdown[1]: All filesystems unmounted.
[ 77.362835] systemd-shutdown[1]: Deactivating swaps.
[ 77.367923] systemd-shutdown[1]: All swaps deactivated.
[ 77.373168] systemd-shutdown[1]: Detaching loop devices.
[ 77.390252] systemd-shutdown[1]: All loop devices detached.
[ 77.395883] systemd-shutdown[1]: Detaching DM devices.
[ 77.401337] systemd-shutdown[1]: All DM devices detached.
[ 77.409285] systemd-shutdown[1]: Powering off.
[ 77.431515] reboot: System halted

"My power off" will power off machine, but to early.

I want to call my script after:
"[ 77.409285] systemd-shutdown[1]: Powering off."

How to do it?

Best Regards
Reindl Harald
2017-12-20 18:19:56 UTC
Permalink
Post by Zygmunt Ptak
I want to implement custom power off method.
I added to the yocto script: /usr/sbin/halt.local which will power off
my machine.
[ OK ] Reached target Shutdown.
Starting /usr/sbin/halt.local Compatibility...
My power off
[ 76.916101] EXT4-fs (mmcblk1p1): re-mounted. Opts: (null)
[ OK ] Started /usr/sbin/halt.local Compatibility.
[ OK ] Reached target Final Step.
Starting Power-Off...
[ 77.357245] systemd-shutdown[1]: All filesystems unmounted.
[ 77.362835] systemd-shutdown[1]: Deactivating swaps.
[ 77.367923] systemd-shutdown[1]: All swaps deactivated.
[ 77.373168] systemd-shutdown[1]: Detaching loop devices.
[ 77.390252] systemd-shutdown[1]: All loop devices detached.
[ 77.395883] systemd-shutdown[1]: Detaching DM devices.
[ 77.401337] systemd-shutdown[1]: All DM devices detached.
[ 77.409285] systemd-shutdown[1]: Powering off.
[ 77.431515] reboot: System halted
"My power off" will power off machine, but to early.
"[ 77.409285] systemd-shutdown[1]: Powering off."
How to do it?
how do you imagine that after "All filesystems unmounted"

probably somehow with dracut/initramfs but not that way and even then
you can't do that much after everything is gone
Zygmunt Ptak
2017-12-20 18:30:50 UTC
Permalink
Ouch, thanks

Doesn't saw that.
Post by Reindl Harald
Post by Zygmunt Ptak
I want to implement custom power off method.
I added to the yocto script: /usr/sbin/halt.local which will power off
my machine.
[ OK ] Reached target Shutdown.
Starting /usr/sbin/halt.local Compatibility...
My power off
[ 76.916101] EXT4-fs (mmcblk1p1): re-mounted. Opts: (null)
[ OK ] Started /usr/sbin/halt.local Compatibility.
[ OK ] Reached target Final Step.
Starting Power-Off...
[ 77.357245] systemd-shutdown[1]: All filesystems unmounted.
[ 77.362835] systemd-shutdown[1]: Deactivating swaps.
[ 77.367923] systemd-shutdown[1]: All swaps deactivated.
[ 77.373168] systemd-shutdown[1]: Detaching loop devices.
[ 77.390252] systemd-shutdown[1]: All loop devices detached.
[ 77.395883] systemd-shutdown[1]: Detaching DM devices.
[ 77.401337] systemd-shutdown[1]: All DM devices detached.
[ 77.409285] systemd-shutdown[1]: Powering off.
[ 77.431515] reboot: System halted
"My power off" will power off machine, but to early.
"[ 77.409285] systemd-shutdown[1]: Powering off."
How to do it?
how do you imagine that after "All filesystems unmounted"
probably somehow with dracut/initramfs but not that way and even then you
can't do that much after everything is gone
_______________________________________________
systemd-devel mailing list
https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Mantas Mikulėnas
2017-12-20 20:05:11 UTC
Permalink
Post by Zygmunt Ptak
Hi systemd devs and users,
I want to implement custom power off method.
I added to the yocto script: /usr/sbin/halt.local which will power off
my machine.
But from what I see it is not correct.
[ OK ] Reached target Shutdown.
Starting /usr/sbin/halt.local Compatibility...
My power off
[ 76.916101] EXT4-fs (mmcblk1p1): re-mounted. Opts: (null)
[ OK ] Started /usr/sbin/halt.local Compatibility.
[ OK ] Reached target Final Step.
Starting Power-Off...
[ 77.102708] systemd-shutdown[1]: Sending SIGTERM to remaining processes...
[ 77.124900] systemd-journald[203]: Received SIGTERM from PID 1
(systemd-shutdow).
[ 77.174386] systemd-shutdown[1]: Sending SIGKILL to remaining processes...
[ 77.194122] systemd-shutdown[1]: Unmounting file systems.
[ 77.200107] systemd-shutdown[1]: Remounting '/var/volatile'
read-only with options ''.
[ 77.208187] systemd-shutdown[1]: Unmounting /var/volatile.
[ 77.253911] systemd-shutdown[1]: Remounting '/tmp' read-only with options ''.
[ 77.261142] systemd-shutdown[1]: Unmounting /tmp.
[ 77.314075] systemd-shutdown[1]: Remounting '/' read-only with
options 'data=ordered'.
[ 77.322732] EXT4-fs (mmcblk1p1): re-mounted. Opts: data=ordered
[ 77.328818] systemd-shutdown[1]: Remounting '/' read-only with
options 'data=ordered'.
[ 77.336983] EXT4-fs (mmcblk1p1): re-mounted. Opts: data=ordered
[ 77.342981] systemd-shutdown[1]: Remounting '/' read-only with
options 'data=ordered'.
[ 77.351167] EXT4-fs (mmcblk1p1): re-mounted. Opts: data=ordered
[ 77.357245] systemd-shutdown[1]: All filesystems unmounted.
[ 77.362835] systemd-shutdown[1]: Deactivating swaps.
[ 77.367923] systemd-shutdown[1]: All swaps deactivated.
[ 77.373168] systemd-shutdown[1]: Detaching loop devices.
[ 77.390252] systemd-shutdown[1]: All loop devices detached.
[ 77.395883] systemd-shutdown[1]: Detaching DM devices.
[ 77.401337] systemd-shutdown[1]: All DM devices detached.
[ 77.409285] systemd-shutdown[1]: Powering off.
[ 77.431515] reboot: System halted
"My power off" will power off machine, but to early.
"[ 77.409285] systemd-shutdown[1]: Powering off."
Generally, programs no longer run after the computer has been powered off...

To run custom code *before* systemd powers off (or halts) the system:

a) Use a shutdown hook (man systemd-shutdown),
or b) Use a shutdown initramfs (/run/initramfs/shutdown).
--
Mantas Mikulėnas
Loading...