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

Message ID 20240513094143.365942-1-srinuvasan.a@siemens.com
State Under Review
Headers show
Series [v1] recipes-initramfs/compress-initrd: add recipe to compress initrd with xz | expand

Commit Message

Arjunan, Srinu May 13, 2024, 9:41 a.m. UTC
From: srinuvasan <srinuvasan.a@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 <srinuvasan.a@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

Comments

Uladzimir Bely May 30, 2024, 5:49 a.m. UTC | #1
On Mon, 2024-05-13 at 15:11 +0530, srinuvasan.a via isar-users wrote:
> From: srinuvasan <srinuvasan.a@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 <srinuvasan.a@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 <you@domain.com>"

This line is still not fixed/removed.

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

Since this is a new Isar package, an appropriate Kconfig/yaml item is
worth adding into kas/package.
Srinuvasan Arjunan May 30, 2024, 5:52 a.m. UTC | #2
On Thursday, May 30, 2024 at 11:19:32 AM UTC+5:30 Uladzimir Bely wrote:

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. 

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

Since this is a new Isar package, an appropriate Kconfig/yaml item is 
worth adding into kas/package.
Jan Kiszka May 31, 2024, 7:35 a.m. UTC | #3
On 13.05.24 11:41, srinuvasan.a@siemens.com wrote:
> From: srinuvasan <srinuvasan.a@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 <srinuvasan.a@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 <you@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

"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

Patch

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