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 <antonlacon@gmail.com>
This commit is contained in:
Ian Leonard 2018-09-21 19:13:08 +00:00
parent 59c1e54455
commit cd6287cc54

View File

@ -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