|
|
d4a4eb |
From 829ed8ef5cca250fac475ad6b0265c792c3af015 Mon Sep 17 00:00:00 2001
|
|
|
d4a4eb |
From: Kairui Song <kasong@redhat.com>
|
|
|
d4a4eb |
Date: Wed, 13 Mar 2019 17:36:53 +0800
|
|
|
d4a4eb |
Subject: [PATCH] squash: also squash systemctl if switch-root is not needed
|
|
|
d4a4eb |
|
|
|
d4a4eb |
systemctl need to be accessible on switch-root, but we unmount the
|
|
|
d4a4eb |
squash image on switch-root, so it will fail. systemctl depends on a lot
|
|
|
d4a4eb |
of libraries, squash them can save more RAM. So allow modules
|
|
|
d4a4eb |
(eg. kdump) to tell dracut that switch-root will be intercepted,
|
|
|
d4a4eb |
then we don't need to take care of that.
|
|
|
d4a4eb |
|
|
|
d4a4eb |
Signed-off-by: Kairui Song <kasong@redhat.com>
|
|
|
d4a4eb |
(cherry picked from commit 3ee0ca5eb74be5d1fbd0e6d643f6fff06234177f)
|
|
|
d4a4eb |
|
|
|
d4a4eb |
Resolves: #1691705
|
|
|
d4a4eb |
---
|
|
|
d4a4eb |
dracut-init.sh | 4 ++++
|
|
|
d4a4eb |
dracut.sh | 40 ++++++++++++++++++++++------------------
|
|
|
d4a4eb |
2 files changed, 26 insertions(+), 18 deletions(-)
|
|
|
d4a4eb |
|
|
|
d4a4eb |
diff --git a/dracut-init.sh b/dracut-init.sh
|
|
|
d4a4eb |
index 50d23e2d..b1ac9966 100644
|
|
|
d4a4eb |
--- a/dracut-init.sh
|
|
|
d4a4eb |
+++ b/dracut-init.sh
|
|
|
d4a4eb |
@@ -150,6 +150,10 @@ dracut_module_included() {
|
|
|
d4a4eb |
[[ " $mods_to_load $modules_loaded " == *\ $*\ * ]]
|
|
|
d4a4eb |
}
|
|
|
d4a4eb |
|
|
|
d4a4eb |
+dracut_no_switch_root() {
|
|
|
d4a4eb |
+ >"$initdir/lib/dracut/no-switch-root"
|
|
|
d4a4eb |
+}
|
|
|
d4a4eb |
+
|
|
|
d4a4eb |
if ! [[ $DRACUT_INSTALL ]]; then
|
|
|
d4a4eb |
DRACUT_INSTALL=$(find_binary dracut-install)
|
|
|
d4a4eb |
fi
|
|
|
d4a4eb |
diff --git a/dracut.sh b/dracut.sh
|
|
|
d4a4eb |
index 6de88b3e..8144a16e 100755
|
|
|
d4a4eb |
--- a/dracut.sh
|
|
|
d4a4eb |
+++ b/dracut.sh
|
|
|
d4a4eb |
@@ -1772,24 +1772,6 @@ if dracut_module_included "squash"; then
|
|
|
d4a4eb |
mv $initdir/$folder $squash_dir/$folder
|
|
|
d4a4eb |
done
|
|
|
d4a4eb |
|
|
|
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 |
- # Remove duplicated files in squashfs image, save some more space
|
|
|
d4a4eb |
- [[ ! -d $initdir/$folder/ ]] && continue
|
|
|
d4a4eb |
- for file in $(find $initdir/$folder/ -not -type d);
|
|
|
d4a4eb |
- do
|
|
|
d4a4eb |
- if [[ -e $squash_dir${file#$initdir} ]]; then
|
|
|
d4a4eb |
- mv $squash_dir${file#$initdir} $file
|
|
|
d4a4eb |
- fi
|
|
|
d4a4eb |
- done
|
|
|
d4a4eb |
- done
|
|
|
d4a4eb |
-
|
|
|
d4a4eb |
# Move some files out side of the squash image, including:
|
|
|
d4a4eb |
# - Files required to boot and mount the squashfs image
|
|
|
d4a4eb |
# - Files need to be accessable without mounting the squash image
|
|
|
d4a4eb |
@@ -1851,6 +1833,28 @@ if dracut_module_included "squash"; then
|
|
|
d4a4eb |
ln -s squash/init.sh $initdir/init
|
|
|
d4a4eb |
ln -s squash/shutdown.sh $initdir/shutdown
|
|
|
d4a4eb |
|
|
|
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.
|
|
|
d4a4eb |
+ inst_multiple "echo" "sh" "mount" "modprobe" "mkdir"
|
|
|
d4a4eb |
+ hostonly="" instmods "loop" "squashfs" "overlay"
|
|
|
d4a4eb |
+
|
|
|
d4a4eb |
+ # Only keep systemctl outsite if we need switch root
|
|
|
d4a4eb |
+ if [[ ! -f "$initdir/lib/dracut/no-switch-root" ]]; then
|
|
|
d4a4eb |
+ inst "systemctl"
|
|
|
d4a4eb |
+ fi
|
|
|
d4a4eb |
+
|
|
|
d4a4eb |
+ for folder in "${squash_candidate[@]}"; do
|
|
|
d4a4eb |
+ # Remove duplicated files in squashfs image, save some more space
|
|
|
d4a4eb |
+ [[ ! -d $initdir/$folder/ ]] && continue
|
|
|
d4a4eb |
+ for file in $(find $initdir/$folder/ -not -type d);
|
|
|
d4a4eb |
+ do
|
|
|
d4a4eb |
+ if [[ -e $squash_dir${file#$initdir} ]]; then
|
|
|
d4a4eb |
+ mv $squash_dir${file#$initdir} $file
|
|
|
d4a4eb |
+ fi
|
|
|
d4a4eb |
+ done
|
|
|
d4a4eb |
+ done
|
|
|
d4a4eb |
+
|
|
|
d4a4eb |
mksquashfs $squash_dir $squash_img -comp xz -b 64K -Xdict-size 100% &> /dev/null
|
|
|
d4a4eb |
|
|
|
d4a4eb |
if [[ $? != 0 ]]; then
|
|
|
d4a4eb |
|