e83cdd
From 927428e6a5e90b2214ee9edf15d4eb6c0fc5c203 Mon Sep 17 00:00:00 2001
e83cdd
From: Kairui Song <kasong@redhat.com>
e83cdd
Date: Mon, 11 Mar 2019 18:44:02 +0800
e83cdd
Subject: [PATCH] squash: squash systemd binary and udevadm
e83cdd
e83cdd
systemd binary and udevadm are not needed to be outside the squash
e83cdd
image. Some binaries are kept outside because they are required before
e83cdd
mounting the image, or after umounting the image (when switching root),
e83cdd
or they may block umounting the image. But we are using lazy umounting,
e83cdd
so actually nothing will block the umount.
e83cdd
e83cdd
Keep more binaries outside the squash image won't hurt but cost extra
e83cdd
memories, the idea of squash image is to save memory usage.
e83cdd
e83cdd
So, there is no reason to keep udevadm outside, that should be a debug
e83cdd
left over. For systemd binary, it's running when switch root happens,
e83cdd
But we have lazy umounted the image and overlay, once systemd process
e83cdd
exec the new systemd in new root, everything will be cleared by kernel.
e83cdd
e83cdd
Also tidy up the comment make it less confussing.
e83cdd
e83cdd
Signed-off-by: Kairui Song <kasong@redhat.com>
e83cdd
(cherry picked from commit e1e1f6e8e6747d8f32c065e267e0a57587818c9e)
e83cdd
e83cdd
Resolves: #1691705
e83cdd
---
e83cdd
 dracut.sh | 8 +++++---
e83cdd
 1 file changed, 5 insertions(+), 3 deletions(-)
e83cdd
e83cdd
diff --git a/dracut.sh b/dracut.sh
e83cdd
index e683a9bc..a0158f22 100755
e83cdd
--- a/dracut.sh
e83cdd
+++ b/dracut.sh
e83cdd
@@ -1772,9 +1772,11 @@ if dracut_module_included "squash"; then
e83cdd
         mv $initdir/$folder $squash_dir/$folder
e83cdd
     done
e83cdd
 
e83cdd
-    # Reinstall required files, because we have moved some important folders to $squash_dir
e83cdd
-    inst_multiple "echo" "sh" "mount" "modprobe" "mkdir" \
e83cdd
-        "systemctl" "udevadm" "$systemdutildir/systemd"
e83cdd
+    # Reinstall required files for the squash image setup script.
e83cdd
+    # We have moved them inside the squashed image, but they need to be
e83cdd
+    # accessible before mounting the image. Also install systemctl,
e83cdd
+    # it's requires for switch-root, but we will umount the image before switch-root
e83cdd
+    inst_multiple "echo" "sh" "mount" "modprobe" "mkdir" "systemctl"
e83cdd
     hostonly="" instmods "loop" "squashfs" "overlay"
e83cdd
 
e83cdd
     for folder in "${squash_candidate[@]}"; do
e83cdd