| From 39d06b934fd4bec88b0945b5277407d7b5510c22 Mon Sep 17 00:00:00 2001 |
| From: Kairui Song <kasong@redhat.com> |
| Date: Mon, 15 Feb 2021 22:58:20 +0800 |
| Subject: [PATCH] feat(squash): install and depmod modules seperately |
| |
| Separately install the modules required for squash image setup. |
| These modules can be deleted after squash image setup to save |
| memory. |
| |
| Signed-off-by: Kairui Song <kasong@redhat.com> |
| (cherry picked from commit 5a18b24a8b9c20c98f711963ce5407ceb2f3d57b) |
| |
| Cherry-picked from: 5a18b24a8b9c20c98f711963ce5407ceb2f3d57b |
| Resolves: #1959336 |
| |
| modules.d/99squash/init-squash.sh | 3 +++ |
| modules.d/99squash/module-setup.sh | 12 +++++------- |
| 2 files changed, 8 insertions(+), 7 deletions(-) |
| |
| diff --git a/modules.d/99squash/init-squash.sh b/modules.d/99squash/init-squash.sh |
| index 449585f0..ecb6cc58 100755 |
| |
| |
| @@ -34,6 +34,9 @@ if [ $? != 0 ]; then |
| echo "Unable to setup overlay module" |
| fi |
| |
| +# These modules are no longer needed, delete to save memory |
| +rm -rf /usr/lib/modules/ |
| + |
| [ ! -d "$SQUASH_MNT" ] && \ |
| mkdir -m 0755 -p $SQUASH_MNT |
| |
| diff --git a/modules.d/99squash/module-setup.sh b/modules.d/99squash/module-setup.sh |
| index c0eb4acd..ad619176 100644 |
| |
| |
| @@ -18,10 +18,6 @@ depends() { |
| return 0 |
| } |
| |
| -installkernel() { |
| - hostonly="" instmods -c squashfs loop overlay |
| -} |
| - |
| installpost() { |
| local squash_candidate=( "usr" "etc" ) |
| |
| @@ -36,7 +32,6 @@ installpost() { |
| # - Files need to be accessible without mounting the squash image |
| # - Initramfs marker |
| for file in \ |
| - "$squash_dir"/usr/lib/modules/*/modules.* \ |
| "$squash_dir"/usr/lib/dracut/* \ |
| "$squash_dir"/etc/initrd-release |
| do |
| @@ -46,8 +41,7 @@ installpost() { |
| done |
| |
| # Install required files for the squash image setup script. |
| - hostonly="" instmods "loop" "squashfs" "overlay" |
| - inst_multiple modprobe mount mkdir ln echo |
| + inst_multiple modprobe mount mkdir ln echo rm |
| |
| mv "$initdir"/init "$initdir"/init.orig |
| inst "$moddir"/init-squash.sh /init |
| @@ -63,6 +57,10 @@ installpost() { |
| find "$initdir/$folder/" -not -type d \ |
| -exec bash -c 'mv -f "$squash_dir${1#$initdir}" "$1"' -- "{}" \; |
| done |
| + |
| + # Install required modules for the squash image init script. |
| + hostonly="" instmods "loop" "squashfs" "overlay" |
| + dracut_kernel_post |
| } |
| |
| install() { |
| |