From e5335402ef7bfed72a3bf86191d4bb5e0f51557f Mon Sep 17 00:00:00 2001 From: Benjamin Gilbert Date: Wed, 13 Jul 2022 22:29:52 -0400 Subject: [PATCH] overlay: compress initrd with zstd -19 on FCOS and RHCOS/SCOS 9 On my system, relative to gzip -9, it roughly halves decompression time at boot while also reducing initrd size. RHCOS 8 can't inherit this because the RHEL 8 kernel doesn't enable CONFIG_RD_ZSTD. This requires coreos-installer to support decoding zstd (for `coreos-installer pxe customize`), which is https://github.com/coreos/coreos-installer/pull/920. For https://github.com/coreos/fedora-coreos-tracker/issues/1247. --- .../lib/dracut/dracut.conf.d/coreos-zstd.conf | 8 ++++++++ tests/kola/files/initrd/compression | 20 +++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 overlay.d/06el9/usr/lib/dracut/dracut.conf.d/coreos-zstd.conf create mode 100755 tests/kola/files/initrd/compression diff --git a/overlay.d/06el9/usr/lib/dracut/dracut.conf.d/coreos-zstd.conf b/overlay.d/06el9/usr/lib/dracut/dracut.conf.d/coreos-zstd.conf new file mode 100644 index 0000000000..9a9c0678d8 --- /dev/null +++ b/overlay.d/06el9/usr/lib/dracut/dracut.conf.d/coreos-zstd.conf @@ -0,0 +1,8 @@ +# Compress initrd with zstd. dracut defaults to -15, but we want the +# maximum reasonable compression, so override the command line to use +# dracut's defaults along with -19. +# +# We can't use this in RHCOS 8 because the kernel doesn't enable +# CONFIG_RD_ZSTD. + +compress="zstd -19 -q -T0" diff --git a/tests/kola/files/initrd/compression b/tests/kola/files/initrd/compression new file mode 100755 index 0000000000..5944a3b216 --- /dev/null +++ b/tests/kola/files/initrd/compression @@ -0,0 +1,20 @@ +#!/bin/bash +## kola: +## exclusive: false +# +# If dracut can't find the configured compressor, it warns and falls back to +# gzip (!). Fail if the initrd isn't compressed with zstd. + +set -xeuo pipefail + +. $KOLA_EXT_DATA/commonlib.sh + +# Check initrd for zstd magic number +if is_rhcos8; then + ok "Skipping initrd zstd compression test on RHCOS 8" +else + if ! LANG=C grep -aUPq "\x28\xb5\x2f\xfd" /boot/ostree/*/init*; then + fatal "Didn't find zstd compression in initrd" + fi + ok "Found zstd compression in initrd" +fi