From cd6287cc54a7b31ffb1f578f24e6590287d7c779 Mon Sep 17 00:00:00 2001 From: Ian Leonard Date: Fri, 21 Sep 2018 19:13:08 +0000 Subject: [PATCH] scripts/image: use custom blocksizes for squashfs images Squashfs allows configuring a blocksize between 4KB and 1MB. The default is 128KB. Increasing blocksize, in general, increases compression efficiency at a cost of increased access time. Using 256KB for a blocksize appears to be a sweet spot balancing the two for gzip and zstd. Blocksize 512KB appears right for lzo. Gzip decreases by ~700KB. Lzo decreases by ~1.25MB. Zstd decreaes by ~2.5MB. Signed-off-by: Ian Leonard --- scripts/image | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/scripts/image b/scripts/image index 44530696ca..d1246a349d 100755 --- a/scripts/image +++ b/scripts/image @@ -231,11 +231,15 @@ rm -rf $TARGET_IMG/$IMAGE_NAME.kernel cp -PR $BUILD/linux-$(kernel_version)/arch/$TARGET_KERNEL_ARCH/boot/$KERNEL_TARGET $TARGET_IMG/$IMAGE_NAME.kernel chmod 0644 $TARGET_IMG/$IMAGE_NAME.kernel -# use strongest available compression level for images -if [ "$SQUASHFS_COMPRESSION" = "lzo" -o "${SQUASHFS_COMPRESSION:-gzip}" = "gzip" ]; then - SQUASHFS_COMPRESSION_OPTION="-Xcompression-level 9" -elif [ "$SQUASHFS_COMPRESSION" = "zstd" ]; then - SQUASHFS_COMPRESSION_OPTION="-Xcompression-level 22" +# Set mksquashfs options for each compression method +if [ -z "$SQUASHFS_COMPRESSION_OPTION" ]; then + if [ "${SQUASHFS_COMPRESSION:-gzip}" = "gzip" ]; then + SQUASHFS_COMPRESSION_OPTION="-Xcompression-level 9 -b 262144" + elif [ "$SQUASHFS_COMPRESSION" = "lzo" ]; then + SQUASHFS_COMPRESSION_OPTION="-Xcompression-level 9 -b 524288" + elif [ "$SQUASHFS_COMPRESSION" = "zstd" ]; then + SQUASHFS_COMPRESSION_OPTION="-Xcompression-level 22 -b 262144" + fi fi # create squashfs file, default to gzip if no compression configured