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