[systemd-devel] The best way to execute kexec via dbus

Andrei Borzenkov arvidjaar at gmail.com
Fri Aug 26 13:02:54 UTC 2022


On 26.08.2022 13:54, Tomáš Hnyk wrote:
> 
>  > >>
>  > > Indeed, it must have been the late night, they are the same. However, 
> the following are not the same even the man page says they are:
>  > >
>  > > sudo systemctl kexec # results in kexec
>  > >
>  > > full log here: https://hastebin.com/gubivumaha.apache
>  > >
>  > > srp 26 10:38:08 GreenOne systemd[1]: Reached target System Shutdown.
>  > > srp 26 10:38:08 GreenOne systemd[1]: Reached target Late Shutdown 
> Services.
>  > > srp 26 10:38:08 GreenOne systemd[1]: Starting Reboot via kexec...
>  > > srp 26 10:38:08 GreenOne systemd[1]: Shutting down.
>  > > srp 26 10:38:08 GreenOne systemd-shutdown[1]: Syncing filesystems and 
> block devices.
>  > > srp 26 10:38:08 GreenOne systemd-shutdown[1]: Sending SIGTERM to 
> remaining processes...
>  > > srp 26 10:38:08 GreenOne systemd-journald[416]: Journal stopped
>  > >
>  > >
>  > > sudo systemctl start kexec.target --job-mode=replace-irreversibly 
> --no-block # failed attempted kexec
>  > >
>  >
>  > You are right. systemctl does more (and differently) in case of
>  > "systemctl kexec". Not sure whether it needs explicit documentation
>  > though, as expectations are that it /should/ have the same effect.
>  >
> Well, I guess then the man page could say something like (caps are what 
> would change) - I did assume one was just shorthand for the other:
> 
> Shut down and reboot the system via kexec. This is MORE OR 
> LESS/TYPICALLY/SHOULD BE(+delete "is") equivalent to systemctl start 
> kexec.target --job-mode=replace-irreversibly --no-block.
>    
>  > > srp 26 10:39:04 GreenOne systemctl[2041]: Cannot automatically load 
> kernel: ESP mount point not found.
>  >
>  > That could be the actual reason. systemctl attempts to autodetect kernel
>  > for kexec and it needs ESP; final call to "systemctl --force kexec"
>  > happens late, when ESP (/boot/efi in your case) is already unmounted.
>  >
>  > For testing you could set DefaultDependencies=false for /boot/efi to
>  > avoid it being unmounted on shutdown.
>  >
> Where can I set it? kexec.target already has "DefaultDependencies=no" in 
> [Unit]?
> 

It is not about kexec.target.

You can add it in drop-in, like

bor at localhost:~> cat /etc/systemd/system/boot-efi.mount.d/nodef.conf
[Unit]
DefaultDependencies=false
bor at localhost:~>

By default fsck service has RemainAfterExit=yes and mount units require
fsck services so they are stopped anyway, I had to add override

bor at localhost:~> cat
/etc/systemd/system/systemd-fsck at dev-disk-by\\x2duuid-893B\\x2d91D8.service.d/exit.conf

[Service]
RemainAfterExit=false
bor at localhost:~>


But notice also that systemd only supports automatic detection when
using systemd-boot. E.g. here openSUSE provides customer service that
detects default grub2 boot entry and performs "kexec --load".


More information about the systemd-devel mailing list