From 3a666bbeea85ea776b0db341231d6a9aacd0e0dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20=C4=8Cerm=C3=A1k?= Date: Fri, 14 Feb 2025 12:27:39 +0100 Subject: [PATCH] Use EROFS LZMA compression of firmware on x86 instead of per-file ZSTD (#3877) Instead of using per-file ZSTD compression, compress firmware (and newly also kernel modules) using LZMA within EROFS image. LZMA was picked because ZSTD support in EROFS is still experimental and due to some limitations in the implementation, the compression takes significantly more time. This change gives us more control over compression of the files and with the proposed settings, saves a bit of the space (~10 MiB) in the resulting image. In theory, even higher savings could be achieved through compressing other runtime binaries, but this would need to be thoroughly tested whether it doesn't have any detrimental effects. For firmware and modules, the overhead should be minimal, as they are usually touched only once per boot and are rather small before decompression. * buildroot 74994c4f32...92fab35fed (6): > fs/erofs: add custom compression option with optional compress-hints file > package/erofs-utils: bump to version 1.8.5 > package/erofs-utils: bump to version 1.8.3 > package/erofs-utils: bump to version 1.8.2 > package/erofs-utils: bump to version 1.8.1 > package/erofs-utils: add libdeflate and zlib optional dependencies --- buildroot | 2 +- .../board/pc/generic-x86-64/erofs-compress-hints.txt | 3 +++ buildroot-external/configs/generic_x86_64_defconfig | 6 +++--- buildroot-external/kernel/v6.12.y/hassos.config | 1 + 4 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 buildroot-external/board/pc/generic-x86-64/erofs-compress-hints.txt diff --git a/buildroot b/buildroot index 74994c4f3..92fab35fe 160000 --- a/buildroot +++ b/buildroot @@ -1 +1 @@ -Subproject commit 74994c4f32fd6f7abe5400aff454ef5e20651d6c +Subproject commit 92fab35fede435d7df72b118a02f83334241f074 diff --git a/buildroot-external/board/pc/generic-x86-64/erofs-compress-hints.txt b/buildroot-external/board/pc/generic-x86-64/erofs-compress-hints.txt new file mode 100644 index 000000000..eaf95343e --- /dev/null +++ b/buildroot-external/board/pc/generic-x86-64/erofs-compress-hints.txt @@ -0,0 +1,3 @@ +# assumed -zlz4hc,12:lzma,9 for optimal compression +16384 1 usr/lib/firmware/ +16384 1 usr/lib/modules/ diff --git a/buildroot-external/configs/generic_x86_64_defconfig b/buildroot-external/configs/generic_x86_64_defconfig index f67c710da..53508a476 100644 --- a/buildroot-external/configs/generic_x86_64_defconfig +++ b/buildroot-external/configs/generic_x86_64_defconfig @@ -33,8 +33,6 @@ BR2_PACKAGE_E2FSPROGS_E2IMAGE=y BR2_PACKAGE_NFS_UTILS=y # BR2_PACKAGE_NFS_UTILS_RPC_NFSD is not set BR2_PACKAGE_LINUX_FIRMWARE=y -BR2_PACKAGE_LINUX_FIRMWARE_COMPRESS=y -BR2_PACKAGE_LINUX_FIRMWARE_COMPRESS_ZSTD=y BR2_PACKAGE_LINUX_FIRMWARE_AMDGPU=y BR2_PACKAGE_LINUX_FIRMWARE_I915=y BR2_PACKAGE_LINUX_FIRMWARE_IBT=y @@ -156,7 +154,9 @@ BR2_PACKAGE_UTIL_LINUX_NOLOGIN=y BR2_PACKAGE_UTIL_LINUX_PARTX=y BR2_PACKAGE_UTIL_LINUX_ZRAMCTL=y BR2_TARGET_ROOTFS_EROFS=y -BR2_TARGET_ROOTFS_EROFS_LZ4HC_LEVEL=12 +BR2_TARGET_ROOTFS_EROFS_CUSTOM_COMPRESSION=y +BR2_TARGET_ROOTFS_EROFS_COMPRESSION_ALGORITHMS="lz4hc,12:lzma,9" +BR2_TARGET_ROOTFS_EROFS_COMPRESSION_HINTS="$(BR2_EXTERNAL_HASSOS_PATH)/board/pc/generic-x86-64/erofs-compress-hints.txt" BR2_TARGET_ROOTFS_EROFS_DEDUPE=y BR2_TARGET_ROOTFS_EROFS_FRAGMENTS=y BR2_TARGET_ROOTFS_EROFS_ZTAILPACKING=y diff --git a/buildroot-external/kernel/v6.12.y/hassos.config b/buildroot-external/kernel/v6.12.y/hassos.config index 0742acda7..da9337ef7 100644 --- a/buildroot-external/kernel/v6.12.y/hassos.config +++ b/buildroot-external/kernel/v6.12.y/hassos.config @@ -36,6 +36,7 @@ CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y CONFIG_MISC_FILESYSTEMS=y CONFIG_BLOCK=y CONFIG_EROFS_FS=y +CONFIG_EROFS_FS_ZIP_LZMA=y CONFIG_EXT4_FS=y CONFIG_MSDOS_FS=y CONFIG_VFAT_FS=y