[PATCH] recipes-initramfs/compress-initrd: add recipe to compress initrd with xz

23 views
Skip to first unread message

srinuv...@siemens.com

unread,
May 13, 2024, 1:24:44 AMMay 13
to isar-...@googlegroups.com, jan.k...@siemens.com, ub...@ilbers.de, srinuvasan
From: srinuvasan <srinuv...@siemens.com>

By default initrd compressed with zstd tool, with the present bullseye base image
of amd64 the initrd size is almost 27MB, this can be reduced with the help of xz tool,
using this one the generated initrd size is almost 18MB, we saved almost 9MB.

Signed-off-by: srinuvasan <srinuv...@siemens.com>
---
meta-isar/conf/local.conf.sample | 2 +-
.../compress-initrd/compress-initrd.bb | 18 ++++++++++++++++++
.../compress-initrd/files/postinst | 5 +++++
3 files changed, 24 insertions(+), 1 deletion(-)
create mode 100644 meta-isar/recipes-initramfs/compress-initrd/compress-initrd.bb
create mode 100644 meta-isar/recipes-initramfs/compress-initrd/files/postinst

diff --git a/meta-isar/conf/local.conf.sample b/meta-isar/conf/local.conf.sample
index 17455015..ac8b749e 100644
--- a/meta-isar/conf/local.conf.sample
+++ b/meta-isar/conf/local.conf.sample
@@ -149,7 +149,7 @@ CONF_VERSION = "1"

#
# The default list of extra packages to be installed.
-IMAGE_INSTALL = "hello-isar example-raw example-module-${KERNEL_NAME} enable-fsck isar-exclude-docs samefile hello isar-disable-apt-cache cowsay example-prebuilt"
+IMAGE_INSTALL = "hello-isar example-raw example-module-${KERNEL_NAME} enable-fsck isar-exclude-docs samefile hello isar-disable-apt-cache cowsay example-prebuilt compress-initrd"

#
# Machines with secure boot should use signed modules.
diff --git a/meta-isar/recipes-initramfs/compress-initrd/compress-initrd.bb b/meta-isar/recipes-initramfs/compress-initrd/compress-initrd.bb
new file mode 100644
index 00000000..21e28782
--- /dev/null
+++ b/meta-isar/recipes-initramfs/compress-initrd/compress-initrd.bb
@@ -0,0 +1,18 @@
+# Compress the initrd with better compression tool
+#
+# This software is a part of ISAR.
+
+DESCRIPTION = "Compress the initrd with better compression tool"
+MAINTAINER = "Your name here <y...@domain.com>"
+
+inherit dpkg-raw
+
+DEBIAN_DEPENDS = "linux-image-${KERNEL_NAME}, xz-utils, initramfs-tools"
+
+SRC_URI = " \
+ file://postinst \
+"
+do_install() {
+ install -v -d "${D}/etc/initramfs-tools/conf.d/"
+ echo "COMPRESS=xz" > "${D}/etc/initramfs-tools/conf.d/${PN}.conf"
+}
diff --git a/meta-isar/recipes-initramfs/compress-initrd/files/postinst b/meta-isar/recipes-initramfs/compress-initrd/files/postinst
new file mode 100644
index 00000000..0db52142
--- /dev/null
+++ b/meta-isar/recipes-initramfs/compress-initrd/files/postinst
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+set -e
+
+update-initramfs -c -k all
--
2.39.2

Jan Kiszka

unread,
May 13, 2024, 1:27:37 AMMay 13
to srinuv...@siemens.com, isar-...@googlegroups.com, ub...@ilbers.de
On 13.05.24 07:26, srinuv...@siemens.com wrote:
> From: srinuvasan <srinuv...@siemens.com>
>
> By default initrd compressed with zstd tool, with the present bullseye base image
> of amd64 the initrd size is almost 27MB, this can be reduced with the help of xz tool,
> using this one the generated initrd size is almost 18MB, we saved almost 9MB.
>

Isn't that just a matter of increasing the compression rate of zstd? It
seems xz is getting out of fashion generally, and it comes with higher
decompression load.

Jan
Siemens AG, Technology
Linux Expert Center

Srinuvasan Arjunan

unread,
May 13, 2024, 1:47:25 AMMay 13
to Jan Kiszka, srinuv...@siemens.com, isar-...@googlegroups.com, ub...@ilbers.de
On Mon, May 13, 2024 at 10:57 AM 'Jan Kiszka' via isar-users <isar-...@googlegroups.com> wrote:
On 13.05.24 07:26, srinuv...@siemens.com wrote:
> From: srinuvasan <srinuv...@siemens.com>
>
> By default initrd compressed with zstd tool, with the present bullseye base image
> of amd64 the initrd size is almost 27MB, this can be reduced with the help of xz tool,
> using this one the generated initrd size is almost 18MB, we saved almost 9MB.
>

Isn't that just a matter of increasing the compression rate of zstd? It
seems xz is getting out of fashion generally, and it comes with higher
decompression load.

Jan

  Sorry, its not zstd tool, the default one is gzip (wrongly captured in commit message), Just i pushed this patch for very limited memory requirement embedded devices, in this case i considered the memory requirement not a decompression load.

Thanks,
Srinu
--
You received this message because you are subscribed to the Google Groups "isar-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to isar-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/isar-users/bc4dcff7-778a-44ac-a7c4-b9d67edec32e%40siemens.com.

Jan Kiszka

unread,
May 13, 2024, 2:29:27 AMMay 13
to Srinuvasan Arjunan, srinuv...@siemens.com, isar-...@googlegroups.com, ub...@ilbers.de
On 13.05.24 07:47, Srinuvasan Arjunan wrote:
>
>
> On Mon, May 13, 2024 at 10:57 AM 'Jan Kiszka' via isar-users
> <isar-...@googlegroups.com <mailto:isar-...@googlegroups.com>> wrote:
>
> On 13.05.24 07:26, srinuv...@siemens.com
> <mailto:srinuv...@siemens.com> wrote:
> > From: srinuvasan <srinuv...@siemens.com
> <mailto:srinuv...@siemens.com>>
> >
> > By default initrd compressed with zstd tool, with the present
> bullseye base image
> > of amd64 the initrd size is almost 27MB, this can be reduced with
> the help of xz tool,
> > using this one the generated initrd size is almost 18MB, we saved
> almost 9MB.
> >
>
> Isn't that just a matter of increasing the compression rate of zstd? It
> seems xz is getting out of fashion generally, and it comes with higher
> decompression load.
>
> Jan
>
>
>   Sorry, its not zstd tool, the default one is gzip (wrongly captured in
> commit message), Just i pushed this patch for very limited memory
> requirement embedded devices, in this case i considered the memory
> requirement not a decompression load.
>

OK, but then not hard-code the tool used for compression, rather make it
configurable.

Jan

MOESSBAUER, Felix

unread,
May 13, 2024, 2:47:51 AMMay 13
to isar-...@googlegroups.com, Arjunan, Srinu, ub...@ilbers.de, Schmidt, Adriaan, Kiszka, Jan
On Mon, 2024-05-13 at 10:56 +0530, srinuvasan.a via isar-users wrote:
> From: srinuvasan <srinuv...@siemens.com>
>
> By default initrd compressed with zstd tool, with the present

Hi, the standard for bullseye is gz.
> disable-apt-cache cowsay example-prebuilt compress-initrd"
>  
>  #
>  # Machines with secure boot should use signed modules.
> diff --git a/meta-isar/recipes-initramfs/compress-initrd/compress-
> initrd.bb b/meta-isar/recipes-initramfs/compress-initrd/compress-
> initrd.bb
> new file mode 100644
> index 00000000..21e28782
> --- /dev/null
> +++ b/meta-isar/recipes-initramfs/compress-initrd/compress-initrd.bb
> @@ -0,0 +1,18 @@
> +# Compress the initrd with better compression tool
> +#
> +# This software is a part of ISAR.
> +
> +DESCRIPTION = "Compress the initrd with better compression tool"

This description makes is too vague.

> +MAINTAINER = "Your name here <y...@domain.com>"

No ;)

> +
> +inherit dpkg-raw
> +
> +DEBIAN_DEPENDS = "linux-image-${KERNEL_NAME}, xz-utils, initramfs-
> tools"
> +
> +SRC_URI = " \
> +    file://postinst \
> +"
> +do_install() {
> +    install -v -d "${D}/etc/initramfs-tools/conf.d/"
> +    echo "COMPRESS=xz" >

Please don't hardcode values. Further, we need to have the compression
utility installed to be able to perform that compression. For xz,
that's xz-utils.

In general, I like the idea to make this customizable (even if I like
zstd more than xz because xz requires a lot of resources for
decompression). However, I'm wondering if we can implement this using
the imagetypes infrastructure (@Adriaan, in CC). That would make it
consistent across ISAR and also avoid the introduction of additional
variables.

Felix

> "${D}/etc/initramfs-tools/conf.d/${PN}.conf"
> +}
> diff --git a/meta-isar/recipes-initramfs/compress-
> initrd/files/postinst b/meta-isar/recipes-initramfs/compress-
> initrd/files/postinst
> new file mode 100644
> index 00000000..0db52142
> --- /dev/null
> +++ b/meta-isar/recipes-initramfs/compress-initrd/files/postinst
> @@ -0,0 +1,5 @@
> +#!/bin/sh
> +
> +set -e
> +
> +update-initramfs -c -k all
> --
> 2.39.2
>

srinuv...@siemens.com

unread,
May 13, 2024, 5:39:49 AMMay 13
to isar-...@googlegroups.com, felix.mo...@siemens.com, jan.k...@siemens.com, adriaan...@siemens.com, srinuvasan
From: srinuvasan <srinuv...@siemens.com>

By default initrd compressed with gzip tool, with the present bullseye base image
of amd64 the initrd size is almost 27MB, this can be reduced with the help of xz tool,
using this one the generated initrd size is almost 18MB, we saved almost 9MB.

Signed-off-by: srinuvasan <srinuv...@siemens.com>
---
meta-isar/conf/local.conf.sample | 2 +-
.../compress-initrd/compress-initrd.bb | 21 +++++++++++++++++++
.../compress-initrd/files/postinst | 5 +++++
3 files changed, 27 insertions(+), 1 deletion(-)
create mode 100644 meta-isar/recipes-initramfs/compress-initrd/compress-initrd.bb
create mode 100644 meta-isar/recipes-initramfs/compress-initrd/files/postinst

diff --git a/meta-isar/conf/local.conf.sample b/meta-isar/conf/local.conf.sample
index 17455015..ac8b749e 100644
--- a/meta-isar/conf/local.conf.sample
+++ b/meta-isar/conf/local.conf.sample
@@ -149,7 +149,7 @@ CONF_VERSION = "1"

#
# The default list of extra packages to be installed.
-IMAGE_INSTALL = "hello-isar example-raw example-module-${KERNEL_NAME} enable-fsck isar-exclude-docs samefile hello isar-disable-apt-cache cowsay example-prebuilt"
+IMAGE_INSTALL = "hello-isar example-raw example-module-${KERNEL_NAME} enable-fsck isar-exclude-docs samefile hello isar-disable-apt-cache cowsay example-prebuilt compress-initrd"

#
# Machines with secure boot should use signed modules.
diff --git a/meta-isar/recipes-initramfs/compress-initrd/compress-initrd.bb b/meta-isar/recipes-initramfs/compress-initrd/compress-initrd.bb
new file mode 100644
index 00000000..b1a5909b
--- /dev/null
+++ b/meta-isar/recipes-initramfs/compress-initrd/compress-initrd.bb
@@ -0,0 +1,21 @@
+# Sample recipe to configure the desired compression tool
+# during initramfs generation
+#
+# This software is a part of ISAR.
+
+DESCRIPTION = "Compress the initrd with configured compression tool"
+MAINTAINER = "Your name here <y...@domain.com>"
+
+inherit dpkg-raw
+
+COMPRESS_TOOL ?= "xz"
+
+DEBIAN_DEPENDS = "linux-image-${KERNEL_NAME}, xz-utils, initramfs-tools"
+
+SRC_URI = " \
+ file://postinst \
+"
+do_install() {
+ install -v -d "${D}/etc/initramfs-tools/conf.d/"
+ echo "COMPRESS=${COMPRESS_TOOL}" > "${D}/etc/initramfs-tools/conf.d/${PN}.conf"
+}
diff --git a/meta-isar/recipes-initramfs/compress-initrd/files/postinst b/meta-isar/recipes-initramfs/compress-initrd/files/postinst
new file mode 100644
index 00000000..0db52142
--- /dev/null
+++ b/meta-isar/recipes-initramfs/compress-initrd/files/postinst
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+set -e
+
+update-initramfs -c -k all
--
2.34.1

Uladzimir Bely

unread,
May 30, 2024, 1:49:32 AMMay 30
to srinuv...@siemens.com, isar-...@googlegroups.com
On Mon, 2024-05-13 at 15:11 +0530, srinuvasan.a via isar-users wrote:
> From: srinuvasan <srinuv...@siemens.com>
>
> By default initrd compressed with gzip tool, with the present
> bullseye base image
> of amd64 the initrd size is almost 27MB, this can be reduced with the
> help of xz tool,
> using this one the generated initrd size is almost 18MB, we saved
> almost 9MB.
>
> Signed-off-by: srinuvasan <srinuv...@siemens.com>
> ---
>  meta-isar/conf/local.conf.sample              |  2 +-
>  .../compress-initrd/compress-initrd.bb        | 21
> +++++++++++++++++++
>  .../compress-initrd/files/postinst            |  5 +++++
>  3 files changed, 27 insertions(+), 1 deletion(-)
>  create mode 100644 meta-isar/recipes-initramfs/compress-
> initrd/compress-initrd.bb
>  create mode 100644 meta-isar/recipes-initramfs/compress-
> initrd/files/postinst
>
> diff --git a/meta-isar/conf/local.conf.sample b/meta-
> isar/conf/local.conf.sample
> index 17455015..ac8b749e 100644
> --- a/meta-isar/conf/local.conf.sample
> +++ b/meta-isar/conf/local.conf.sample
> @@ -149,7 +149,7 @@ CONF_VERSION = "1"
>  
>  #
>  # The default list of extra packages to be installed.
> -IMAGE_INSTALL = "hello-isar example-raw example-module-
> ${KERNEL_NAME} enable-fsck isar-exclude-docs samefile hello isar-
> disable-apt-cache cowsay example-prebuilt"
> +IMAGE_INSTALL = "hello-isar example-raw example-module-
> ${KERNEL_NAME} enable-fsck isar-exclude-docs samefile hello isar-
> disable-apt-cache cowsay example-prebuilt compress-initrd"
>  
>  #
>  # Machines with secure boot should use signed modules.
> diff --git a/meta-isar/recipes-initramfs/compress-initrd/compress-
> initrd.bb b/meta-isar/recipes-initramfs/compress-initrd/compress-
> initrd.bb
> new file mode 100644
> index 00000000..b1a5909b
> --- /dev/null
> +++ b/meta-isar/recipes-initramfs/compress-initrd/compress-initrd.bb
> @@ -0,0 +1,21 @@
> +# Sample recipe to configure the desired compression tool
> +# during initramfs generation
> +#
> +# This software is a part of ISAR.
> +
> +DESCRIPTION = "Compress the initrd with configured compression tool"
> +MAINTAINER = "Your name here <y...@domain.com>"

This line is still not fixed/removed.
Since this is a new Isar package, an appropriate Kconfig/yaml item is
worth adding into kas/package.

--
Best regards,
Uladzimir.

Srinuvasan Arjunan

unread,
May 30, 2024, 1:53:00 AMMay 30
to isar-users
  Thanks for the review, will send another version of the patch soon.

  Many thanks,
Srinu 

Jan Kiszka

unread,
May 31, 2024, 3:35:08 AMMay 31
to srinuv...@siemens.com, isar-...@googlegroups.com, felix.mo...@siemens.com, adriaan...@siemens.com
"However, I'm wondering if we can implement this using
the imagetypes infrastructure (@Adriaan, in CC). That would make it
consistent across ISAR and also avoid the introduction of additional
variables."

This question of Felix remains open.

Jan

srinuv...@siemens.com

unread,
Jul 2, 2024, 9:41:00 AM (4 days ago) Jul 2
to isar-...@googlegroups.com, ub...@ilbers.de, jan.k...@siemens.com, srinuvasan
From: srinuvasan <srinuv...@siemens.com>

By default initrd compressed with gzip tool, with the present bullseye base image
of amd64 the initrd size is almost 27MB, this can be reduced with the help of xz tool,
using this one the generated initrd size is almost 18MB, we saved almost 9MB.

Signed-off-by: srinuvasan <srinuv...@siemens.com>
---
kas/package/Kconfig | 9 ++++++++
kas/package/pkg_compress_initrd.yaml | 9 ++++++++
.../compress-initrd/compress-initrd.bb | 21 +++++++++++++++++++
.../compress-initrd/files/postinst | 5 +++++
4 files changed, 44 insertions(+)
create mode 100644 kas/package/pkg_compress_initrd.yaml
create mode 100644 meta-isar/recipes-initramfs/compress-initrd/compress-initrd.bb
create mode 100644 meta-isar/recipes-initramfs/compress-initrd/files/postinst

diff --git a/kas/package/Kconfig b/kas/package/Kconfig
index 35ba7cf1..9c24a680 100644
--- a/kas/package/Kconfig
+++ b/kas/package/Kconfig
@@ -146,6 +146,15 @@ config KAS_INCLUDE_PACKAGE_ISAR_CI_SSH_SETUP
default "kas/package/pkg_sshd-regen-keys.yaml"
depends on PACKAGE_ISAR_CI_SSH_SETUP

+config PACKAGE_COMPRESS_INITRD
+ bool "compress initrd"
+ default y
+
+config KAS_INCLUDE_PACKAGE_COMPRESS_INITRD
+ string
+ default "kas/package/pkg_compress_initrd.yaml"
+ depends on PACKAGE_COMPRESS_INITRD
+
endmenu

config KAS_IMAGE_PREINSTALL
diff --git a/kas/package/pkg_compress_initrd.yaml b/kas/package/pkg_compress_initrd.yaml
new file mode 100644
index 00000000..376a280c
--- /dev/null
+++ b/kas/package/pkg_compress_initrd.yaml
@@ -0,0 +1,9 @@
+# This software is a part of ISAR.
+# Copyright (C) 2024 ilbers GmbH
+
+header:
+ version: 14
+
+local_conf_header:
+ package-compress-initrd: |
+ IMAGE_INSTALL:append = " compress-initrd"
--
2.34.1

Reply all
Reply to author
Forward
0 new messages