Source: base-installer
Version: 1.192
Severity: wishlist
Tags: patch
Dear Maintainers,
Debian-installer can already configure initramfs-tools' MODULES setting
to get a smaller initramfs. I've written a patch for configuring its
COMPRESS setting as well, please consider applying it. I've tested it
using an arm64 virtual machine with a custom built netboot image.
I'm doing something like flash-kernel & flash-kernel-installer for
chromebooks, which have size limits on kernel + initramfs + etc. If the
installer step fails due to initramfs size I'll be asking these two
questions to the user with a higher priority, regenerate the initramfs,
and retry the step. Such a flow could be implemented for flash-kernel as
well, and I think having at least the question template here would be great.
-- System Information:
Debian Release: bullseye/sid
APT prefers unstable
APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: arm64 (aarch64)
Kernel: Linux 5.4.0-3-arm64 (SMP w/6 CPU cores)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8),
LANGUAGE=en_GB:en (charmap=UTF-8)
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
>From 2864137a59bcfbc957a7e8960b65e3e39977106a Mon Sep 17 00:00:00 2001
From: Alper Nebi Yasak <alpernebiya...@gmail.com>
Date: Mon, 27 Jan 2020 21:16:10 +0300
Subject: [PATCH] Support configuring initramfs compression
Some machines/bootloaders do not support initramfs images larger than a
certain size. Setting MODULES=dep in initramfs-tools config is usually
enough to satisfy these size limits, and base-installer already asks a
question for this (driver-policy, with priority medium). This patch
implements a similar question for initramfs-tools' COMPRESS setting
which can further reduce the initramfs size for these machines.
Signed-off-by: Alper Nebi Yasak <alpernebiya...@gmail.com>
---
debian/bootstrap-base.templates | 11 +++++++++++
debian/templates-arch | 6 ++++++
library.sh | 22 ++++++++++++++++++++++
3 files changed, 39 insertions(+)
diff --git a/debian/bootstrap-base.templates b/debian/bootstrap-base.templates
index 78a6f29a..7a53cad3 100644
--- a/debian/bootstrap-base.templates
+++ b/debian/bootstrap-base.templates
@@ -88,6 +88,17 @@ _Description: Drivers to include in the initrd:
smaller targeted initrd there is a very small chance that not all needed
drivers are included.
+Template: base-installer/initramfs-tools/compression
+Type: select
+Choices: lzop, lz4, gzip, bzip2, xz, lzma
+# :sl3:
+_Description: Compression method for the initramfs image:
+ Compressing the initramfs is usually a trade-off between initramfs
+ size, memory use, compression speed, and the time your system takes to
+ boot (decompression speed). Gzip is reasonably balanced, xz and lzma
+ makes the initramfs significantly smaller, but lz4 has the highest
+ decompression speed.
+
Template: base-installer/kernel/failed-install
Type: error
# :sl2:
diff --git a/debian/templates-arch b/debian/templates-arch
index 30e8f7a8..873dc001 100644
--- a/debian/templates-arch
+++ b/debian/templates-arch
@@ -12,6 +12,12 @@ Default[armel]: dep
Description: for internal use
Default driver inclusion policy for initramfs-tools
+Template: base-installer/kernel/linux/initramfs-tools/compression
+Type: string
+Default: gzip
+Description: for internal use
+ Default compression method for initramfs-tools
+
Template: base-installer/kernel/linux/extra-packages
Type: string
Default:
diff --git a/library.sh b/library.sh
index d7f05024..d2859566 100644
--- a/library.sh
+++ b/library.sh
@@ -575,8 +575,15 @@ EOF
db_get base-installer/kernel/linux/initramfs-tools/driver-policy
db_set base-installer/initramfs-tools/driver-policy "$RET"
fi
+ if db_get base-installer/initramfs-tools/compression && \
+ [ -z "$RET" ]; then
+ # Get default for architecture
+ db_get base-installer/kernel/linux/initramfs-tools/compression
+ db_set base-installer/initramfs-tools/compression "$RET"
+ fi
db_settitle debian-installer/bootstrap-base/title
db_input medium base-installer/initramfs-tools/driver-policy || true
+ db_input medium base-installer/initramfs-tools/compression || true
if ! db_go; then
db_progress stop
exit 10
@@ -591,6 +598,21 @@ EOF
MODULES=$RET
EOF
fi
+
+ db_get base-installer/initramfs-tools/compression
+ if [ "$RET" != gzip ]; then
+ cat > $IT_CONFDIR/compression <<EOF
+# Compression method selected during installation
+# Note: this setting overrides the value set in the file
+# /etc/initramfs-tools/initramfs.conf
+COMPRESS=$RET
+EOF
+ if [ "$RET" = xz ] || [ "$RET" = lzma ]; then
+ log-output -t base-installer apt-install xz-utils
+ else
+ log-output -t base-installer apt-install "$RET"
+ fi
+ fi
else
info "Not installing an initrd generator."
fi
--
2.25.0