[systemd-devel] Service is started multiple times during initrd
cd
cd at terminal.space
Tue Oct 4 19:14:26 UTC 2022
Hello,
I have configured systemd to handle the initrd part of boot (using the systemd hook in mkinitcpio.conf on arch).
I've added the following service to my initramfs (with a corresponding .wants symlink)
add_symlink "/usr/lib/systemd/system/initrd-root-fs.target.wants/lvm-autosnap-initrd.service" "/usr/lib/systemd/system/lvm-autosnap-initrd.service"
[Unit]
Description="Run the core lvm-autosnap logic to take manage snapshots during boot"
DefaultDependencies=no
Before=sysroot.mount
After=initrd-root-device.target
[Service]
Type=oneshot
ExecStart=/usr/bin/lvm-autosnap initrd_main
Restart=no
StandardInput=tty
StandardOutput=tty
The problem I'm running into is that the service is started multiple times during boot. Here's the relevant snippets from journalctl -b
First, the service is started at the correct time (after initrd-root-device.target)
Oct 04 11:48:56 archlinux systemd[1]: Reached target Initrd Root Device.
Oct 04 11:48:56 archlinux systemd[1]: Starting "Run the core lvm-autosnap logic to take manage snapshots during boot"...
<snip>
Oct 04 11:48:56 archlinux kernel: audit: type=1130 audit(1664909336.153:6): pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=system>
Oct 04 11:48:56 archlinux systemd[1]: lvm-activate-testvg.service: Deactivated successfully.
Oct 04 11:48:56 archlinux audit[1]: SERVICE_STOP pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=lvm-activate-testvg comm="systemd>
Oct 04 11:48:56 archlinux kernel: audit: type=1131 audit(1664909336.159:7): pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=lvm-ac>
Oct 04 11:49:20 archlinux systemd[1]: lvm-autosnap-initrd.service: Deactivated successfully.
Oct 04 11:49:20 archlinux systemd[1]: Finished "Run the core lvm-autosnap logic to take manage snapshots during boot".
It then completes, and the service enters the inactive state.
Shortly afterwards, however, the service gets started again:
Oct 04 11:49:20 archlinux systemd[1]: Reached target Initrd Default Target.
Oct 04 11:49:20 archlinux systemd[1]: Starting Cleaning Up and Shutting Down Daemons...
Oct 04 11:49:20 archlinux systemd[1]: Stopped target Initrd Default Target.
Oct 04 11:49:20 archlinux systemd[1]: Stopped target Basic System.
Oct 04 11:49:20 archlinux systemd[1]: Stopped target Initrd Root Device.
Oct 04 11:49:20 archlinux systemd[1]: Stopped target Path Units.
Oct 04 11:49:20 archlinux systemd[1]: Stopped target Slice Units.
Oct 04 11:49:20 archlinux systemd[1]: Stopped target Socket Units.
Oct 04 11:49:20 archlinux systemd[1]: Stopped target System Initialization.
Oct 04 11:49:20 archlinux systemd[1]: Stopped target Local File Systems.
Oct 04 11:49:20 archlinux systemd[1]: Stopped target Swaps.
Oct 04 11:49:20 archlinux systemd[1]: Stopped target Timer Units.
Oct 04 11:49:20 archlinux systemd[1]: Starting "Run the core lvm-autosnap logic to take manage snapshots during boot"...
where it is then promptyl killed by the switch root:
Oct 04 11:49:20 archlinux systemd[1]: Switching root.
Oct 04 11:49:20 archlinux systemd-journald[136]: Journal stopped
Oct 04 11:49:21 archvm systemd-journald[136]: Received SIGTERM from PID 1 (systemd).
Oct 04 11:49:21 archvm systemd[1]: systemd 251.5-1-arch running in system mode (+PAM +AUDIT -SELINUX -APPARMOR -IMA +SMACK +SECCOMP +GC>
Oct 04 11:49:21 archvm systemd[1]: Detected virtualization kvm.
Oct 04 11:49:21 archvm systemd[1]: Detected architecture x86-64.
Oct 04 11:49:21 archvm systemd[1]: Hostname set to <archvm>.
Oct 04 11:49:21 archvm systemd[1]: lvm-autosnap-initrd.service: Main process exited, code=killed, status=1/HUP
Oct 04 11:49:21 archvm systemd[1]: lvm-autosnap-initrd.service: Failed with result 'signal'.
Oct 04 11:49:21 archvm systemd[1]: Stopped "Run the core lvm-autosnap logic to take manage snapshots during boot".
Oct 04 11:49:21 archvm systemd[1]: initrd-switch-root.service: Deactivated successfully.
Oct 04 11:49:21 archvm systemd[1]: Stopped Switch Root.
Is there a way to prevent this second instantiation of the service? (while preserving the oneshot behavior to prevent sysroot.mount from reaching until the service exits)
Thanks,Anil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20221004/be1a5913/attachment.htm>
More information about the systemd-devel
mailing list