e83cdd
From 2caaf8b9ba5b95983154bd641f0f493ff1562cc0 Mon Sep 17 00:00:00 2001
e83cdd
From: Kairui Song <kasong@redhat.com>
e83cdd
Date: Tue, 6 Aug 2019 15:39:31 +0800
e83cdd
Subject: [PATCH] 99squash: Only start the cleaner on switch-root
e83cdd
e83cdd
Currently it starts the cleaner early and do the clean up job if switch
e83cdd
root is called. It's better to just start the service only on switch
e83cdd
root to avoid any risk of service dependency failure and make is
e83cdd
simpler.
e83cdd
e83cdd
Signed-off-by: Kairui Song <kasong@redhat.com>
e83cdd
(cherry picked from commit 5d88809319049eb06e3472dcd11cca9c4557d8c2)
e83cdd
e83cdd
Resolves: #1678248
e83cdd
---
e83cdd
 modules.d/99squash/module-setup.sh          |  3 ++-
e83cdd
 modules.d/99squash/squash-mnt-clear.service | 11 ++++-------
e83cdd
 2 files changed, 6 insertions(+), 8 deletions(-)
e83cdd
e83cdd
diff --git a/modules.d/99squash/module-setup.sh b/modules.d/99squash/module-setup.sh
e83cdd
index 935fd721..e7e9ed8e 100644
e83cdd
--- a/modules.d/99squash/module-setup.sh
e83cdd
+++ b/modules.d/99squash/module-setup.sh
e83cdd
@@ -25,5 +25,6 @@ install() {
e83cdd
     inst $moddir/init.sh /squash/init.sh
e83cdd
 
e83cdd
     inst "$moddir/squash-mnt-clear.service" "$systemdsystemunitdir/squash-mnt-clear.service"
e83cdd
-    ln_r "$systemdsystemunitdir/squash-mnt-clear.service" "$systemdsystemunitdir/initrd.target.wants/squash-mnt-clear.service"
e83cdd
+    mkdir -p "$initdir$systemdsystemunitdir/initrd-switch-root.target.wants"
e83cdd
+    ln_r "$systemdsystemunitdir/squash-mnt-clear.service" "$systemdsystemunitdir/initrd-switch-root.target.wants/squash-mnt-clear.service"
e83cdd
 }
e83cdd
diff --git a/modules.d/99squash/squash-mnt-clear.service b/modules.d/99squash/squash-mnt-clear.service
e83cdd
index f8d5db46..84441f60 100644
e83cdd
--- a/modules.d/99squash/squash-mnt-clear.service
e83cdd
+++ b/modules.d/99squash/squash-mnt-clear.service
e83cdd
@@ -4,17 +4,14 @@
e83cdd
 [Unit]
e83cdd
 Description=Cleanup squashfs mounts when switch root
e83cdd
 DefaultDependencies=no
e83cdd
-After=initrd.target
e83cdd
-After=dracut-initqueue.service dracut-pre-pivot.service
e83cdd
-Before=initrd-cleanup.service
e83cdd
+Before=initrd-switch-root.service
e83cdd
+After=initrd-switch-root.target
e83cdd
 ConditionPathExists=/squash/root
e83cdd
-Conflicts=initrd-switch-root.target
e83cdd
-IgnoreOnIsolate=true
e83cdd
 
e83cdd
 [Service]
e83cdd
 Type=oneshot
e83cdd
-RemainAfterExit=yes
e83cdd
+RemainAfterExit=no
e83cdd
 StandardInput=null
e83cdd
 StandardOutput=syslog+console
e83cdd
 StandardError=syslog+console
e83cdd
-ExecStop=/squash/clear-squash.sh
e83cdd
+ExecStart=/squash/clear-squash.sh
e83cdd