linux: Use the choosen rootfs compression type when rootfs is builtin
PATCH 1/1 linux: Use the choosen rootfs compression type when rootfs is builtin
I have built a buildroot with:
BR2_TARGET_ROOTFS_CPIO_XZ=y
BR2_TARGET_ROOTFS_INITRAMFS=y
With this buildroot produces an images/rootfs.cpio.xz but the kernel still use gzip (CONFIG_INITRAMFS_COMPRESSION_GZIP) as compression for a plain rootfs.cpio
Setting CONFIG_INITRAMFS_COMPRESSION_XZ in a linux.fragment does not work as it seems the fragment is setup before buildroot set CONFIG_INITRAMFS_SOURCE which reset the CONFIG_INITRAMFS_COMPRESSION choice.
So buildroot have to change CONFIG_INITRAMFS_COMPRESSION after setup CONFIG_INITRAMFS_SOURCE.
--- linux/linux.mk | 12 ++++++++++++ 1 file changed, 12 insertions(+)
linux/linux.mk +12 -0
@@ -116,6 +116,14 @@ LINUX_COMPRESSION_OPT_$(BR2_LINUX_KERNEL_XZ) += CONFIG_KERNEL_XZ LINUX_COMPRESSION_OPT_$(BR2_LINUX_KERNEL_ZSTD) += CONFIG_KERNEL_ZSTD LINUX_COMPRESSION_OPT_$(BR2_LINUX_KERNEL_UNCOMPRESSED) += CONFIG_KERNEL_UNCOMPRESSED +LINUX_ROOTFS_COMPRESSION_OPT_$(BR2_TARGET_ROOTFS_CPIO_GZIP) += CONFIG_INITRAMFS_COMPRESSION_GZIP +LINUX_ROOTFS_COMPRESSION_OPT_$(BR2_TARGET_ROOTFS_CPIO_LZ4) += CONFIG_INITRAMFS_COMPRESSION_LZ4 +LINUX_ROOTFS_COMPRESSION_OPT_$(BR2_TARGET_ROOTFS_CPIO_LZMA) += CONFIG_INITRAMFS_COMPRESSION_LZMA +LINUX_ROOTFS_COMPRESSION_OPT_$(BR2_TARGET_ROOTFS_CPIO_LZO) += CONFIG_INITRAMFS_COMPRESSION_LZO +LINUX_ROOTFS_COMPRESSION_OPT_$(BR2_TARGET_ROOTFS_CPIO_XZ) += CONFIG_INITRAMFS_COMPRESSION_XZ +LINUX_ROOTFS_COMPRESSION_OPT_$(BR2_TARGET_ROOTFS_CPIO_ZSTD) += CONFIG_INITRAMFS_COMPRESSION_ZSTD +LINUX_ROOTFS_COMPRESSION_OPT_$(BR2_TARGET_ROOTFS_CPIO_NONE) += CONFIG_INITRAMFS_COMPRESSION_NONE + ifeq ($(BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL),y) LINUX_DEPENDENCIES += host-openssl endif
@@ -378,6 +386,10 @@ define LINUX_KCONFIG_FIXUP_CMDS_ROOTFS_CPIO $(call KCONFIG_SET_OPT,CONFIG_INITRAMFS_SOURCE,"$${BR_BINARIES_DIR}/rootfs.cpio") $(call KCONFIG_SET_OPT,CONFIG_INITRAMFS_ROOT_UID,0) $(call KCONFIG_SET_OPT,CONFIG_INITRAMFS_ROOT_GID,0) + $(call KCONFIG_ENABLE_OPT,$(strip $(LINUX_ROOTFS_COMPRESSION_OPT_y))) + $(foreach opt, $(LINUX_ROOTFS_COMPRESSION_OPT_), + $(call KCONFIG_DISABLE_OPT,$(opt)) + ) endef endif
Signature · 6 lines
2.25.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 11 lines · Corentin Labbe
I have built a buildroot with:
BR2_TARGET_ROOTFS_CPIO_XZ=y
BR2_TARGET_ROOTFS_INITRAMFS=y
With this buildroot produces an images/rootfs.cpio.xz but the kernel still use gzip (CONFIG_INITRAMFS_COMPRESSION_GZIP) as compression for a plain rootfs.cpioSetting
CONFIG_INITRAMFS_COMPRESSION_XZin a linux.fragment does not work as it seems the fragment is setup before buildroot setCONFIG_INITRAMFS_SOURCEwhich reset theCONFIG_INITRAMFS_COMPRESSIONchoice.
Quoted 5 lines
So buildroot have to change
CONFIG_INITRAMFS_COMPRESSIONafter setupCONFIG_INITRAMFS_SOURCE.Signed-off-by Corentin Labbe <[email protected]>---
Hello
Ping
Regards
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Hi Corentin,
Sorry to come back to this only three years later... You probably don't
remember anything about this, but I'm replying anyway in case anybody comes back on this.
Quoted 39 lines · Corentin Labbe
I have built a buildroot with:
BR2_TARGET_ROOTFS_CPIO_XZ=y
BR2_TARGET_ROOTFS_INITRAMFS=y
With this buildroot produces an images/rootfs.cpio.xz but the kernel still use gzip (CONFIG_INITRAMFS_COMPRESSION_GZIP) as compression for a plain rootfs.cpioSetting
CONFIG_INITRAMFS_COMPRESSION_XZin a linux.fragment does not work as it seems the fragment is setup before buildroot setCONFIG_INITRAMFS_SOURCEwhich reset theCONFIG_INITRAMFS_COMPRESSIONchoice.So buildroot have to change
CONFIG_INITRAMFS_COMPRESSIONafter setupCONFIG_INITRAMFS_SOURCE.Signed-off-by Corentin Labbe <[email protected]>--- linux/linux.mk | 12 ++++++++++++ 1 file changed, 12 insertions(+)linux/linux.mk +8
-0@@ -116,6 +116,14 @@ LINUX_COMPRESSION_OPT_$(BR2_LINUX_KERNEL_XZ) += CONFIG_KERNEL_XZ LINUX_COMPRESSION_OPT_$(BR2_LINUX_KERNEL_ZSTD) += CONFIG_KERNEL_ZSTD LINUX_COMPRESSION_OPT_$(BR2_LINUX_KERNEL_UNCOMPRESSED) += CONFIG_KERNEL_UNCOMPRESSED +LINUX_ROOTFS_COMPRESSION_OPT_$(BR2_TARGET_ROOTFS_CPIO_GZIP) += CONFIG_INITRAMFS_COMPRESSION_GZIP +LINUX_ROOTFS_COMPRESSION_OPT_$(BR2_TARGET_ROOTFS_CPIO_LZ4) += CONFIG_INITRAMFS_COMPRESSION_LZ4 +LINUX_ROOTFS_COMPRESSION_OPT_$(BR2_TARGET_ROOTFS_CPIO_LZMA) += CONFIG_INITRAMFS_COMPRESSION_LZMA +LINUX_ROOTFS_COMPRESSION_OPT_$(BR2_TARGET_ROOTFS_CPIO_LZO) += CONFIG_INITRAMFS_COMPRESSION_LZO +LINUX_ROOTFS_COMPRESSION_OPT_$(BR2_TARGET_ROOTFS_CPIO_XZ) += CONFIG_INITRAMFS_COMPRESSION_XZ +LINUX_ROOTFS_COMPRESSION_OPT_$(BR2_TARGET_ROOTFS_CPIO_ZSTD) += CONFIG_INITRAMFS_COMPRESSION_ZSTD +LINUX_ROOTFS_COMPRESSION_OPT_$(BR2_TARGET_ROOTFS_CPIO_NONE) += CONFIG_INITRAMFS_COMPRESSION_NONE + ifeq ($(BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL),y) LINUX_DEPENDENCIES += host-openssl endif
linux/linux.mk define LINUX_KCONFIG_FIXUP_CMDS_ROOTFS_CPIO · line 386
Quoted 1 line
linux/linux.mk +0
-0@@ -378,6 +386,10 @@ define LINUX_KCONFIG_FIXUP_CMDS_ROOTFS_CPIO $(call KCONFIG_SET_OPT,CONFIG_INITRAMFS_SOURCE,"$${BR_BINARIES_DIR}/rootfs.cpio")
We still use the uncompressed cpio, so shouldn't we simply setCONFIG_INITRAMFS_COMPRESSION_NONE ?
We could use the compressed image here, but I think it's intentional to use
the uncompressed one, because normally you still compress your kernel afterwards (either as a zImage or in the U-Boot wrapper). This will also compress the cpio, so compressing it separately just adds overhead.
linux/linux.mk define LINUX_KCONFIG_FIXUP_CMDS_ROOTFS_CPIO · line 391
Quoted 5 lines
linux/linux.mk +3
-0$(call KCONFIG_SET_OPT,CONFIG_INITRAMFS_ROOT_UID,0) $(call KCONFIG_SET_OPT,CONFIG_INITRAMFS_ROOT_GID,0) + $(call KCONFIG_ENABLE_OPT,$(strip $(LINUX_ROOTFS_COMPRESSION_OPT_y))) + $(foreach opt, $(LINUX_ROOTFS_COMPRESSION_OPT_), + $(call KCONFIG_DISABLE_OPT,$(opt))
AFAIK for a choice it's not needed to disable all the other options; the last
=y option wins anyway (if it is not forbidden by other options).
I've marked the patch as Changes Requested in patchwork.
Regards,
Arnout
linux/linux.mk define LINUX_KCONFIG_FIXUP_CMDS_ROOTFS_CPIO · line 395
Quoted 4 lines
linux/linux.mk +1
-0+ ) endef endif
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH v2 1/1 linux: Use the choosen rootfs compression type when rootfs is builtin
In reply to Corentin LabbeFrom: Corentin Labbe <[email protected]>
I have built a buildroot with:
BR2_TARGET_ROOTFS_CPIO_XZ=y
BR2_TARGET_ROOTFS_INITRAMFS=y
With this buildroot produces an images/rootfs.cpio.xz but the kernel still use gzip (CONFIG_INITRAMFS_COMPRESSION_GZIP) as compression for a plain rootfs.cpio
Setting CONFIG_INITRAMFS_COMPRESSION_XZ in a linux.fragment does not work as it seems the fragment is setup before buildroot set CONFIG_INITRAMFS_SOURCE which reset the CONFIG_INITRAMFS_COMPRESSION choice.
So buildroot have to change CONFIG_INITRAMFS_COMPRESSION after setup CONFIG_INITRAMFS_SOURCE.
Without cpio compression, the kernel keeps its own default, as before. So the defconfigs with a built-in initramfs, which use no cpio compression and often boot an uncompressed kernel image, don't change.
---
Changes v1 -> v2:
- keep the kernel default when the cpio image is not compressed, instead of CONFIG_INITRAMFS_COMPRESSION_NONE: the 20 defconfigs with a built-in initramfs use no cpio compression, and most of them boot an uncompressed kernel (vmlinux, linux.bin, XIP), so their images would grow [Arnout Vandecappelle]
- only enable the chosen option, don't disable the others [Arnout Vandecappelle]
- also enable the CONFIG_RD_* option the choice depends on
- add bzip2
- rebase on master
Supersedes v1: https://patchwork.buildroot.org/project/buildroot/patch/[email protected]/
linux/linux.mk | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
linux/linux.mk +19 -0
@@ -420,7 +420,26 @@ define LINUX_KCONFIG_FIXUP_CMDS_ROOTFS_CPIO $(call KCONFIG_SET_OPT,CONFIG_INITRAMFS_SOURCE,"$${BR_BINARIES_DIR}/rootfs.cpio") $(call KCONFIG_SET_OPT,CONFIG_INITRAMFS_ROOT_UID,0) $(call KCONFIG_SET_OPT,CONFIG_INITRAMFS_ROOT_GID,0) + $(LINUX_KCONFIG_FIXUP_CMDS_INITRAMFS_COMPRESSION) endef + +# Compress the built-in initramfs like the cpio image. Setting +# CONFIG_INITRAMFS_SOURCE above resets this choice, so a kernel +# configuration fragment can't set it. Without cpio compression, the +# kernel keeps its own default. +LINUX_INITRAMFS_COMPRESSION_$(BR2_TARGET_ROOTFS_CPIO_BZIP2) = BZIP2 +LINUX_INITRAMFS_COMPRESSION_$(BR2_TARGET_ROOTFS_CPIO_GZIP) = GZIP +LINUX_INITRAMFS_COMPRESSION_$(BR2_TARGET_ROOTFS_CPIO_LZ4) = LZ4 +LINUX_INITRAMFS_COMPRESSION_$(BR2_TARGET_ROOTFS_CPIO_LZMA) = LZMA +LINUX_INITRAMFS_COMPRESSION_$(BR2_TARGET_ROOTFS_CPIO_LZO) = LZO +LINUX_INITRAMFS_COMPRESSION_$(BR2_TARGET_ROOTFS_CPIO_XZ) = XZ +LINUX_INITRAMFS_COMPRESSION_$(BR2_TARGET_ROOTFS_CPIO_ZSTD) = ZSTD +ifneq ($(LINUX_INITRAMFS_COMPRESSION_y),) +define LINUX_KCONFIG_FIXUP_CMDS_INITRAMFS_COMPRESSION + $(call KCONFIG_ENABLE_OPT,CONFIG_RD_$(LINUX_INITRAMFS_COMPRESSION_y)) + $(call KCONFIG_ENABLE_OPT,CONFIG_INITRAMFS_COMPRESSION_$(LINUX_INITRAMFS_COMPRESSION_y)) +endef +endif endif # Since kernel >= 6.15.y, x86 and x86_64 kernels requires a toolchain
Signature · 6 lines
2.53.0 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot