01.01.2025 09:55, Qu Wenruo wrote:
[BACKGROUND] I'm trying to implement a super simple kdump service(s) for Archlinux. The idea is super simple, just use the default linux kernel installed as kernel/initramfs for the kexec environment. So there is a kexec.service to setup the environment, with extra systemd options to disable th kexec.service itself, and start the kdump.service: ``` [Unit] Description=Setup kexec environment After=local-fs.target [Service] Type=oneshot RemainAfterExit=true ExecStart=/usr/bin/kexec -p /boot/vmlinuz-linux --initrd=/boot/initramfs-linux.img --append="root=/dev/os/root rw console=ttyS0 nr_cpus=1 reset_devices systemd.mask=kexec.service systemd.unit=kdump.service" ExecStop=/usr/bin/kexec -p -u [Install] WantedBy=multi-user.target ``` So that after a crash we can boot into the same kernel/initramfs combo and do whatever to collect the vmcore. The kdump.service will just call makedumpfile and exit (hopefully also reboot the system): ``` [Unit] Description=Save the kernel crash dump after a crash After=multi-user.target [Service] Type=idle ExecStart=/bin/sh -c 'mkdir -p /var/crash/ && /usr/bin/makedumpfile -z -d 31 /proc/vmcore "/var/crash/crashdump-$$(date +%%F-%%T)"' ExecStartPost=reboot UMask=0077 StandardInput=tty-force StandardOutput=inherit StandardError=inherit ``` [PROBLEM] The vmcore collection happens well, but reboot failed: ``` Failed to connect to system scope bus via local transport: No such file or directory ```
Could be https://github.com/systemd/systemd/pull/35773
Then the system hang and I have to force reboot the VM instead. So any idea what's the proper way to reboot the system inside a service triggered by `systemd.unit=` boot option? Thanks, Qu