Skip to content

Commit

Permalink
feat(squash): decouple the compressor for dracut and dracut-squash
Browse files Browse the repository at this point in the history
Previously dracut-squash module inherits the compressor
name from dracut, but actually the compressors are totally
different. For dracut, the compressor is zstd/gzip/lzop
cmdline tools, for dracut-squash, the compressor is the
libzstd/libz/liblzo libraries integrated by mksquashfs.

However mksquashfs support less compressors than dracut,
such as bzip2, which is not supported by mksquashfs, so
compressor decoupling seems to be a good idea to handle this.

This patch introduces a new dracut cmdline argument
--squash-compressor, by which the compressor and compressor
specific options can be passed to mksquashfs as
--squash-compressor "lzo -Xalgorithm lzo1x_1_15".

Signed-off-by: Tao Liu <ltao@redhat.com>
  • Loading branch information
liutgnu authored and johannbg committed Feb 22, 2022
1 parent 631d5f7 commit 90d9ae8
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions dracut.sh
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,9 @@ Creates initial ramdisk images for preloading modules
otherwise you will not be able to boot.
--no-compress Do not compress the generated initramfs. This will
override any other compression options.
--squash-compressor [COMPRESSION] Specify the compressor and compressor
specific options used by mksquashfs if squash module
is called when building the initramfs.
--enhanced-cpio Attempt to reflink cpio file data using dracut-cpio.
--list-modules List all available dracut modules.
-M, --show-modules Print included module's name to standard output during
Expand Down Expand Up @@ -373,6 +376,7 @@ rearrange_params() {
--long sysroot: \
--long stdlog: \
--long compress: \
--long squash-compressor: \
--long prefix: \
--long rebuild: \
--long force \
Expand Down Expand Up @@ -662,6 +666,11 @@ while :; do
PARMS_TO_STORE+=" '$2'"
shift
;;
--squash-compressor)
squash_compress_l="$2"
PARMS_TO_STORE+=" '$2'"
shift
;;
--prefix)
prefix_l="$2"
PARMS_TO_STORE+=" '$2'"
Expand Down Expand Up @@ -996,6 +1005,7 @@ stdloglvl=$((stdloglvl + verbosity_mod_l))
[[ $tmpdir ]] || tmpdir="$dracutsysrootdir"/var/tmp
[[ $INITRD_COMPRESS ]] && compress=$INITRD_COMPRESS
[[ $compress_l ]] && compress=$compress_l
[[ $squash_compress_l ]] && squash_compress=$squash_compress_l
[[ $enhanced_cpio_l ]] && enhanced_cpio=$enhanced_cpio_l
[[ $show_modules_l ]] && show_modules=$show_modules_l
[[ $nofscks_l ]] && nofscks="yes"
Expand Down Expand Up @@ -2290,11 +2300,11 @@ if dracut_module_included "squash"; then
dinfo "*** Squashing the files inside the initramfs ***"
declare squash_compress_arg
# shellcheck disable=SC2086
if [[ $compress ]]; then
if ! mksquashfs /dev/null "$DRACUT_TMPDIR"/.squash-test.img -no-progress -comp $compress &> /dev/null; then
dwarn "mksquashfs doesn't support compressor '$compress', failing back to default compressor."
if [[ $squash_compress ]]; then
if ! mksquashfs /dev/null "$DRACUT_TMPDIR"/.squash-test.img -no-progress -comp $squash_compress &> /dev/null; then
dwarn "mksquashfs doesn't support compressor '$squash_compress', failing back to default compressor."
else
squash_compress_arg="$compress"
squash_compress_arg="$squash_compress"
fi
fi
Expand Down

0 comments on commit 90d9ae8

Please sign in to comment.