afa7aa1
From 4c2d98c75b0dd3dad45430becb78c9d40bc6be1b Mon Sep 17 00:00:00 2001
afa7aa1
From: Martin Wilck <mwilck@suse.com>
afa7aa1
Date: Mon, 9 Oct 2017 14:39:12 +0200
afa7aa1
Subject: [PATCH] emergency.service: use Type=idle
afa7aa1
MIME-Version: 1.0
afa7aa1
Content-Type: text/plain; charset=UTF-8
afa7aa1
Content-Transfer-Encoding: 8bit
afa7aa1
afa7aa1
Type=oneshot, as currently set in dracut's emergency service file,
afa7aa1
causes an awkward situation if emergency mode is entered e.g. because
afa7aa1
of a root device timeout, and the root device appears later because it
afa7aa1
just has taken longer than the timeout. In that situation, my
afa7aa1
expectation (backed by past positive experience) is that the user should
afa7aa1
be able to simply exit the emergency shell and resume normal boot.
afa7aa1
afa7aa1
:/# systemctl status sysroot.mount
afa7aa1
‚óŹ sysroot.mount - /sysroot
afa7aa1
   Loaded: loaded (/proc/cmdline; bad; vendor preset: enabled)
afa7aa1
   Active: active (mounted) since Mon 2017-10-09 14:32:15 CEST; 16s ago
afa7aa1
    Where: /sysroot
afa7aa1
     What: /dev/mapper/3600601600a30200024fbbaf3f500e411-part5
afa7aa1
     Docs: man:fstab(5)
afa7aa1
           man:systemd-fstab-generator(8)
afa7aa1
  Process: 1873 ExecMount=/usr/bin/mount /dev/disk/by-uuid/63751805-6abc-46a3-a66f-427920dece4d /sysroot -o ro (code=exited, status=0/SUCCESS)
afa7aa1
    Tasks: 0 (limit: 512)
afa7aa1
afa7aa1
:/# systemctl list-jobs
afa7aa1
JOB UNIT              TYPE  STATE
afa7aa1
 56 emergency.target  start waiting
afa7aa1
 57 emergency.service start running
afa7aa1
afa7aa1
2 jobs listed.
afa7aa1
:/# exit
afa7aa1
logout
afa7aa1
Failed to start default.target: Transaction is destructive.
afa7aa1
afa7aa1
(system keeps idling from this point on, user has no chance to
afa7aa1
do anything).
afa7aa1
afa7aa1
This results from the combination of two effects:
afa7aa1
1) initrd-root-fs.target sets "OnFailureJobMode=replace-irreversibly",
afa7aa1
2) emergency.service's Type=oneshot causes the start jobs for both
afa7aa1
emergency.service and emergency.target to persist while the user is in
afa7aa1
the emergency shell.
afa7aa1
afa7aa1
When the shell is exited, systemd tries to isolate "initrd.target"
afa7aa1
again, but this fails with "the transaction is destructive" error
afa7aa1
because of the still pending jobs.
afa7aa1
afa7aa1
This patch fixes this by changing the Type of "emergency.service" from
afa7aa1
"oneshot" to "idle".
afa7aa1
---
afa7aa1
 modules.d/98dracut-systemd/emergency.service | 2 +-
afa7aa1
 1 file changed, 1 insertion(+), 1 deletion(-)
afa7aa1
afa7aa1
diff --git a/modules.d/98dracut-systemd/emergency.service b/modules.d/98dracut-systemd/emergency.service
afa7aa1
index 288aac39..100146a3 100644
afa7aa1
--- a/modules.d/98dracut-systemd/emergency.service
afa7aa1
+++ b/modules.d/98dracut-systemd/emergency.service
afa7aa1
@@ -17,7 +17,7 @@ Environment=NEWROOT=/sysroot
afa7aa1
 WorkingDirectory=/
afa7aa1
 ExecStart=/bin/dracut-emergency
afa7aa1
 ExecStopPost=-/usr/bin/systemctl --fail --no-block default
afa7aa1
-Type=oneshot
afa7aa1
+Type=idle
afa7aa1
 StandardInput=tty-force
afa7aa1
 StandardOutput=inherit
afa7aa1
 StandardError=inherit
afa7aa1