Skip to content

Commit 5d05ffb

Browse files
ryncsnjohannbg
authored andcommitted
feat: squash module follow --compress option
Try to make mksquashfs follow --compress option if squash module is included, if not specified or invalid, fall back to use mksquashfs's default compressor.
1 parent a9345f6 commit 5d05ffb

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

dracut.sh

+15-5
Original file line numberDiff line numberDiff line change
@@ -2033,12 +2033,22 @@ fi
20332033
20342034
if dracut_module_included "squash"; then
20352035
dinfo "*** Squashing the files inside the initramfs ***"
2036+
declare squash_compress_arg
2037+
# shellcheck disable=SC2086
2038+
if [[ $compress ]]; then
2039+
if ! mksquashfs /dev/null "$DRACUT_TMPDIR"/.squash-test.img -no-progress -comp $compress &>/dev/null; then
2040+
dwarn "mksquashfs doesn't support compressor '$compress', failing back to default compressor."
2041+
else
2042+
squash_compress_arg="$compress"
2043+
fi
2044+
fi
2045+
2046+
# shellcheck disable=SC2086
20362047
if ! mksquashfs "$squash_dir" "$squash_img" \
2037-
-no-xattrs -no-exports -noappend -always-use-fragments \
2038-
-comp xz -Xdict-size 100% -no-progress \
2039-
> /dev/null; then
2040-
dfatal "dracut: Failed making squash image"
2041-
exit 1
2048+
-no-xattrs -no-exports -noappend -no-recovery -always-use-fragments \
2049+
-no-progress ${squash_compress_arg:+-comp $squash_compress_arg} 1> /dev/null; then
2050+
dfatal "dracut: Failed making squash image"
2051+
exit 1
20422052
fi
20432053
20442054
rm -rf "$squash_dir"

0 commit comments

Comments
 (0)