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