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

Andrei Borzenkov arvidjaar at gmail.com
Fri Aug 26 10:36:59 UTC 2022


On 26.08.2022 12:29, Tomáš Hnyk wrote:
> On Friday 26. August 2022, 06:55:15 (+02:00), Andrei Borzenkov wrote:
> 
>> On 26.08.2022 03:59, Tomáš Hnyk wrote:
>>> Hello,I am trying to be able to reboot with kexec from a GUI (I am
>>> modifying this: https://github.com/varlesh/org.kde.plasma.compact-shutdown
>>> ). As far as I can tell, I need to use qdbus. Via command line, I can
>>> successfully reboot with kexec with:
>>> systemctl start kexec.target --job-mode=replace-irreversibly --no-block
>>>
>>> When I remove the --noblock parameter, the kexed reboot fails and normal
>>> reboot is performed.
>>
>> There should be no difference between the two. Both do exactly the same
>> D-Bus call. Debug logs in both cases would be interesting.
>>
> 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.

> full log here: https://hastebin.com/ruzunihepe.apache
>  
> srp 26 10:39:04 GreenOne systemd[1]: Starting Unload nvidia modesetting modules from kernel POTREBUJE NVIDIA PRO KEXEC...
> srp 26 10:39:04 GreenOne kernel: [drm] [nvidia-drm] [GPU ID 0x00000100] Unloading driver
> srp 26 10:39:04 GreenOne systemd[1]: lvm2-monitor.service: Deactivated successfully.
> srp 26 10:39:04 GreenOne systemd[1]: Stopped Monitoring of LVM2 mirrors, snapshots etc. using dmeventd or progress polling.
> srp 26 10:39:04 GreenOne systemd[1]: Reached target System Shutdown.
> srp 26 10:39:04 GreenOne systemd[1]: Reached target Late Shutdown Services.
> srp 26 10:39:04 GreenOne systemd[1]: Starting Reboot via kexec...
> srp 26 10:39:04 GreenOne systemctl[2041]: No kexec kernel loaded and autodetection failed.
> 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.

> srp 26 10:39:04 GreenOne systemctl[2041]: Failed to load kexec kernel, continuing without.
> srp 26 10:39:04 GreenOne systemd[1]: Shutting down.


More information about the systemd-devel mailing list