[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Ensuring initramfs is compressed with zstd



Hi Ben,

Ben Hutchings <ben@decadent.org.uk> (2023-03-05):
> I did a test installation with d-i bookworm alpha 2, and I noticed a
> warning message from update-initramfs during base installation that it
> was falling back from zstd to gzip compression.  zstd has been the
> default compressor in initramfs-tools for a while, but since the
> compressor is configurable it only Recommends zstd.

Right, I've been seeing this message (esp. while trying to fight some
u-i runs, see [1]), but didn't dive into it; thanks for doing so!

 1. https://salsa.debian.org/installer-team/hw-detect/-/commit/ead9c6a980ad179b7c6f43889ab3512345fde389

> It looks like later package upgrades lead to a new initramfs being
> generated with zstd.  However, it is possible that in some conditions
> an installation would not include zstd, or would leave the initramfs
> compressed with gzip even though zstd is installed.

It makes sense to address that upfront, yes.

> Does the patch below for base-installer seem like a reasonable change?
> (I haven't tested it yet, but may do so tomorrow.)
> 
> Ben.
> 
> diff --git a/library.sh b/library.sh
> index e7fb8f60..120a39ae 100644
> --- a/library.sh
> +++ b/library.sh
> @@ -542,12 +542,16 @@ EOF
>  	if [ "$do_initrd" = yes ]; then
>  		rd_generator=initramfs-tools
>  
> -		# initramfs-tools needs busybox pre-installed (and only
> -		# recommends it)
> +		# initramfs-tools may need busybox, and prefers to use
> +		# zstd over gzip, but only recommends them
>  		if ! log-output -t base-installer apt-install busybox; then
>  			db_subst base-installer/kernel/failed-package-install PACKAGE busybox
>  			exit_error base-installer/kernel/failed-package-install
>  		fi
> +		if ! log-output -t base-installer apt-install zstd; then
> +			db_subst base-installer/kernel/failed-package-install PACKAGE zstd
> +			exit_error base-installer/kernel/failed-package-install
> +		fi
>  
>  		# Make sure the ramdisk creation tool is installed before we
>  		# change its configuration

Given the existing code for busybox, your proposal looks good to me.
For just two packages, duplicating and looping are probably equivalent,
I'll leave the choice up to you.


On a tangential note, in the “asked and answered” category: I've been
adding pigz/pixz support to various d-i and debian-cd parts lately, but
didn't check what's happening at the initramfs level. Are we getting
parallel compression by making sure zstd is used? (The manpage mentions
a zstdmt variant.)

Getting 15 seconds per (gzip) run on a powerful machine seemed a little
embarrassing (but thankfully nudged me into optimizing the number of
runs)…

From a quick look at current mkinitramfs, d-i is currently using gzip at
first since we're not explicitly pulling pigz, and switching to zstd
will give us zstd -T0 (aka. zstdmt) for free, so installing that package
(earlier or at all) will give us a speed boost in addition to improved
consistency and correctness.

Doubly great!


Cheers,
-- 
Cyril Brulebois (kibi@debian.org)            <https://debamax.com/>
D-I release manager -- Release team member -- Freelance Consultant

Attachment: signature.asc
Description: PGP signature


Reply to: