summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
author Eric Hameleers <alien@slackware.com>2018-08-26 13:28:30 +0200
committer Eric Hameleers <alien@slackware.com>2018-08-26 13:28:30 +0200
commit0a888bf1a580e6b7b1113dc7db0359484da36078 (patch)
tree479b61fafe2070af9c52c70a22711cedeeb5211f
parente103f0de308539e2bd0f53845d365e45fdf60ebc (diff)
downloadliveslak-0a888bf1a580e6b7b1113dc7db0359484da36078.tar.gz
liveslak-0a888bf1a580e6b7b1113dc7db0359484da36078.tar.xz
Add zstd compression support for squashfs modules
This will provide compression ratios approaching those of xz, while achieving decompression rations similar to lzo (5 times faster than xz). We will need to have a zstd package in Slackware first, and then rebuild squashfs-tools to add zstd support.
Diffstat (limited to '')
-rwxr-xr-xmake_slackware_live.sh38
-rwxr-xr-xmakemod7
2 files changed, 35 insertions, 10 deletions
diff --git a/make_slackware_live.sh b/make_slackware_live.sh
index 851af44..a20c809 100755
--- a/make_slackware_live.sh
+++ b/make_slackware_live.sh
@@ -227,17 +227,41 @@ ADD_CACERT=${ADD_CACERT:-"YES"}
# the alternative is gzip (which adds ~30% to the initrd size).
COMPR=${COMPR:-"xz --check=crc32"}
+# What compressors are available?
+SQ_COMP_AVAIL=(gzip lzma lzo xz zstd)
+
+# Compressor optimizations:
+declare -A SQ_COMP_PARAMS_DEF
+SQ_COMP_PARAMS_DEF[gzip]=""
+SQ_COMP_PARAMS_DEF[lzma]=""
+SQ_COMP_PARAMS_DEF[lzo]=""
+SQ_COMP_PARAMS_DEF[xz]=""-b 512k -Xdict-size 100%"
+SQ_COMP_PARAMS_DEF[zstd]="-b 512k -Xcompression-level 16"
+declare -A SQ_COMP_PARAMS_OPT
+SQ_COMP_PARAMS_OPT[gzip]=""
+SQ_COMP_PARAMS_OPT[lzma]=""
+SQ_COMP_PARAMS_OPT[lzo]=""
+SQ_COMP_PARAMS_OPT[xz]=""-b 1M"
+SQ_COMP_PARAMS_OPT[zstd]="-b 1M -Xcompression-level 19"
+
# What compression to use for the squashfs modules?
-# Default is xz, alternatives are gzip, lzma, lzo:
+# Default is xz, alternatives are gzip, lzma, lzo, zstd:
SQ_COMP=${SQ_COMP:-"xz"}
+# Test whether the compressor of choice is supported by the script:
+if [[ ${SQ_COMP_AVAIL[*]} =~ ${SQ_COMP} ]]; then
+ echo "*** Compressor '${SQ_COMP}' not supported by $(basename $0 .sh)!"
+ echo "*** Select one of '${SQ_COMP_AVAIL[@]}'"
+ exit 1
+fi
+
# What compression parameters to use?
# For our lean XFCE image we try to achieve max compression,
# at the expense of runtime latency:
if [ "$LIVEDE" = "XFCE" ] ; then
- SQ_COMP_PARAMS=${SQ_COMP_PARAMS:-"-b 1M"}
+ SQ_COMP_PARAMS=${SQ_COMP_PARAMS:-"${SQ_COMP_PARAMS_OPT[${SQ_COMP}]}"}
else
- SQ_COMP_PARAMS=${SQ_COMP_PARAMS:-"-b 512k -Xdict-size 100%"}
+ SQ_COMP_PARAMS=${SQ_COMP_PARAMS:-"${SQ_COMP_PARAMS_DEF[${SQ_COMP}]}"}
fi
# Mount point where Live filesystem is assembled (no storage requirements):
@@ -1147,13 +1171,13 @@ for SPS in ${SL_SERIES} ; do
rm -rf ${LIVE_BOOT}/boot
mv ${INSTDIR}/boot ${LIVE_BOOT}/
# Squash the boot files into a module as a safeguard:
- mksquashfs ${LIVE_BOOT} ${LIVE_MOD_SYS}/0000-${DISTRO}_boot-${SL_VERSION}-${SL_ARCH}.sxz -noappend -comp ${SQ_COMP} -b 1M
+ mksquashfs ${LIVE_BOOT} ${LIVE_MOD_SYS}/0000-${DISTRO}_boot-${SL_VERSION}-${SL_ARCH}.sxz -noappend -comp ${SQ_COMP} ${SQ_COMP_PARAMS}
fi
fi
# Squash the installed package series into a module:
- mksquashfs ${INSTDIR} ${LIVE_MOD_SYS}/${MNUM}-${DISTRO}_${SPS}-${SL_VERSION}-${SL_ARCH}.sxz -noappend -comp ${SQ_COMP} -b 1M
+ mksquashfs ${INSTDIR} ${LIVE_MOD_SYS}/${MNUM}-${DISTRO}_${SPS}-${SL_VERSION}-${SL_ARCH}.sxz -noappend -comp ${SQ_COMP} ${SQ_COMP_PARAMS}
rm -rf ${INSTDIR}/*
# End result: we have our .sxz file and the INSTDIR is empty again,
@@ -2191,7 +2215,7 @@ chroot ${LIVE_ROOTDIR} /etc/cron.daily/${LOCATE_BIN} 2>${DBGOUT}
# Squash the configuration into its own module:
umount ${LIVE_ROOTDIR} 2>${DBGOUT} || true
-mksquashfs ${INSTDIR} ${LIVE_MOD_SYS}/0099-${DISTRO}_zzzconf-${SL_VERSION}-${SL_ARCH}.sxz -noappend -comp ${SQ_COMP} -b 1M
+mksquashfs ${INSTDIR} ${LIVE_MOD_SYS}/0099-${DISTRO}_zzzconf-${SL_VERSION}-${SL_ARCH}.sxz -noappend -comp ${SQ_COMP} ${SQ_COMP_PARAMS}
rm -rf ${INSTDIR}/*
# End result: we have our .sxz file and the INSTDIR is empty again,
@@ -2318,7 +2342,7 @@ cp -a ${LIVE_BOOT}/boot/vmlinuz-generic*-$KGEN ${LIVE_STAGING}/boot/generic
mv ${LIVE_BOOT}/boot/initrd_${KVER}.img ${LIVE_STAGING}/boot/initrd.img
# Squash the boot directory into its own module:
-mksquashfs ${LIVE_BOOT} ${LIVE_MOD_SYS}/0000-${DISTRO}_boot-${SL_VERSION}-${SL_ARCH}.sxz -noappend -comp ${SQ_COMP} -b 1M
+mksquashfs ${LIVE_BOOT} ${LIVE_MOD_SYS}/0000-${DISTRO}_boot-${SL_VERSION}-${SL_ARCH}.sxz -noappend -comp ${SQ_COMP} ${SQ_COMP_PARAMS}
# Determine additional boot parameters to be added:
if [ -z ${KAPPEND} ]; then
diff --git a/makemod b/makemod
index ae030c9..38a5566 100755
--- a/makemod
+++ b/makemod
@@ -62,9 +62,10 @@ fi
MODEXT=$(echo "$2" |rev |cut -d'.' -f1 |rev)
case $MODEXT in
- sxz) COMPR="xz" ;;
- sgz) COMPR="gzip" ;;
- xzm) COMPR="xz" ;;
+ sxz) COMPR=${COMPR:-"xz"} ;;
+ sgz) COMPR=${COMPR:-"gzip"} ;;
+ szs) COMPR=${COMPR:-"zstd"} ;;
+ xzm) COMPR=${COMPR:-"xz"} ;; # Porteus module extension and compressor
*) echo "-- Unsupported module extension '$MODEXT'" ; exit 1 ;;
esac