All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/1] fs/squashfs: add more options to customize creation
@ 2022-05-15 14:54 Linus Kaschulla via buildroot
  2022-05-15 20:52 ` Yann E. MORIN
  0 siblings, 1 reply; 5+ messages in thread
From: Linus Kaschulla via buildroot @ 2022-05-15 14:54 UTC (permalink / raw)
  To: buildroot; +Cc: Linus Kaschulla, Yann E . MORIN

Squashfs seems to be the best way to shipping a highly compressed
rootfs that can easily be mounted without any extraction overhead.
While trying to get the squashfs as small as possible, I found out
that buildroot only allows rather basic customizations and many
options to improve the compression ratio are not available.

Notably, squashfs doesn't use the maximum available blocksize by
default and compression options offered by `mksquashfs` are not
changable from buildroot without patching the source code.

This patch adds 2 new options to fs/squashfs:

 - Changing the blocksize (e.g. to improve compression ratio)
 - Appending any custom arguments (e.g. for adding compression options)

Using these options, specifying the max blocksize of 1M and adding
the arguments `-Xbcj arm` allows for a notably smaller rootfs when
using xz compression and building for an arm target.

Signed-off-by: Linus Kaschulla <linus@cosmos-ink.net>
---
 fs/squashfs/Config.in   | 20 ++++++++++++++++++++
 fs/squashfs/squashfs.mk |  8 ++++++++
 2 files changed, 28 insertions(+)

diff --git a/fs/squashfs/Config.in b/fs/squashfs/Config.in
index 70d4a20cf0..7ae2743961 100644
--- a/fs/squashfs/Config.in
+++ b/fs/squashfs/Config.in
@@ -12,6 +12,16 @@ config BR2_TARGET_ROOTFS_SQUASHFS_PAD
 	  Say 'y' here (the default) to pad the the filesystem image
 	  to a 4K boundary. Say 'n' to disable padding.
 
+config BR2_TARGET_ROOTFS_SQUASHFS4_BLOCKSIZE
+	string "block size"
+	help
+	  Define a specific block size to use when creating the
+	  squashfs. Higher values can improve compression ratios.
+	  The suffixes K and M are supported. The value should not
+	  be above 1 MiB.
+
+	  If unsure, leave this empty to use the default blocksize.
+
 choice
 	prompt "Compression algorithm"
 	default BR2_TARGET_ROOTFS_SQUASHFS4_GZIP
@@ -39,4 +49,14 @@ config BR2_TARGET_ROOTFS_SQUASHFS4_ZSTD
 
 endchoice
 
+config BR2_TARGET_ROOTFS_SQUASHFS4_CUSTOM_ARGS
+	string "additional arguments to pass to the squashfs creation"
+	help
+	  Append extra commandline arguments to the mksquashfs command.
+	  This can be useful for finetuning a selected compression or
+	  enable/disable other features of squashfs.
+	  See "$HOST_DIR/bin/mksquashfs -h" for available arguments.
+
+	  If unsure, leave empty.
+
 endif
diff --git a/fs/squashfs/squashfs.mk b/fs/squashfs/squashfs.mk
index 7a5e3e313e..42343b1b40 100644
--- a/fs/squashfs/squashfs.mk
+++ b/fs/squashfs/squashfs.mk
@@ -12,6 +12,10 @@ ifeq ($(BR2_TARGET_ROOTFS_SQUASHFS_PAD),)
 ROOTFS_SQUASHFS_ARGS += -nopad
 endif
 
+ifneq ($(BR2_TARGET_ROOTFS_SQUASHFS4_BLOCKSIZE),"")
+ROOTFS_SQUASHFS_ARGS += -b "$(BR2_TARGET_ROOTFS_SQUASHFS4_BLOCKSIZE)"
+endif
+
 ifeq ($(BR2_TARGET_ROOTFS_SQUASHFS4_LZ4),y)
 ROOTFS_SQUASHFS_ARGS += -comp lz4 -Xhc
 else ifeq ($(BR2_TARGET_ROOTFS_SQUASHFS4_LZO),y)
@@ -26,6 +30,10 @@ else
 ROOTFS_SQUASHFS_ARGS += -comp gzip
 endif
 
+ifneq ($(BR2_TARGET_ROOTFS_SQUASHFS4_CUSTOM_ARGS),"")
+ROOTFS_SQUASHFS_ARGS += $(call qstrip,$(BR2_TARGET_ROOTFS_SQUASHFS4_CUSTOM_ARGS))
+endif
+
 define ROOTFS_SQUASHFS_CMD
 	$(HOST_DIR)/bin/mksquashfs $(TARGET_DIR) $@ $(ROOTFS_SQUASHFS_ARGS)
 endef
-- 
2.35.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-05-17  3:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-15 14:54 [Buildroot] [PATCH 1/1] fs/squashfs: add more options to customize creation Linus Kaschulla via buildroot
2022-05-15 20:52 ` Yann E. MORIN
2022-05-15 23:56   ` Linus via buildroot
2022-05-16 16:47     ` Yann E. MORIN
2022-05-17  3:23       ` Linus via buildroot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.