units/initrd-cleanup.service: Conflict with emergency.target

This is very similar to 327cd2d3db:

If emergency.target is started while initrd-cleanup.service/start is queued,
the initrd-cleanup job did not get canceled. In parallel to the emergency
units, it eventually runs the service, which in turn isolates and starts
initrd-switch-root.target. This stops the emergency units and effectively
starts the initrd boot process again, which likely fails again like the
initial attempt. The system is thus stuck in a loop, never really reaching
emergency.target.

This can be triggered if a service in between initrd-parse-etc.service
and initrd.target fails.

With this conflict added, starting emergency.target automatically cancels
initrd-cleanup.service/start, avoiding the loop.
This commit is contained in:
Fabian Vogt
2025-07-08 13:02:47 +02:00
committed by Mike Yuan
parent f17c49c569
commit e21cd6db9c

View File

@@ -14,6 +14,7 @@ AssertPathExists=/etc/initrd-release
OnFailure=emergency.target
OnFailureJobMode=replace-irreversibly
After=initrd-root-fs.target initrd-fs.target initrd.target
Conflicts=emergency.target
[Service]
Type=oneshot