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