Skip to content

Commit

Permalink
feat(squash): install and depmod modules seperately
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
ryncsn authored and johannbg committed Mar 9, 2021
1 parent f9f4264 commit 5a18b24
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
3 changes: 3 additions & 0 deletions modules.d/99squash/init-squash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 5 additions & 7 deletions modules.d/99squash/module-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ depends() {
return 0
}

installkernel() {
hostonly="" instmods squashfs loop overlay
}

installpost() {
local squash_candidate=( "usr" "etc" )

Expand All @@ -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
Expand All @@ -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
Expand All @@ -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() {
Expand Down

0 comments on commit 5a18b24

Please sign in to comment.