initramfs/dracut: Enable zstd compression for kernels 5.9+

Way fast to compress/decompress and produce smaller archives (compared
to deflate/gzip in general), but only supported in kernels 5.9+.
Notice we fallback to the default "--compress=gzip" in case kernel
does not support zstd.

Special thanks to Clayton (craftyguy) for the kernel version test.

Signed-off-by: Guilherme G. Piccoli <gpiccoli@igalia.com>
This commit is contained in:
Guilherme G. Piccoli
2023-01-19 10:47:43 -03:00
parent 293ff98b12
commit dc4e6b964c

View File

@ -8,7 +8,16 @@
create_initramfs_dracut() { create_initramfs_dracut() {
rm -f "${MOUNT_FOLDER}/kdump-initrd-$1.img" rm -f "${MOUNT_FOLDER}/kdump-initrd-$1.img"
DRACUT_NO_XATTR=1 dracut --no-early-microcode --host-only -q -m\ COMPRESS="--compress=gzip"
MAJOR="$(echo "$1" | cut -f1 -d\.)"
MINOR="$(echo "$1" | cut -f2 -d\.)"
# Zstd is FAST, but only supported in kernels 5.9+.
if [ "${MAJOR}" -gt 5 ] || ([ "${MAJOR}" -eq 5 ] && [ "${MINOR}" -ge 9 ]); then
COMPRESS="--compress=zstd"
fi
DRACUT_NO_XATTR=1 dracut "${COMPRESS}" --no-early-microcode --host-only -q -m\
"bash systemd systemd-initrd systemd-sysusers modsign dbus-daemon kdump dbus udev-rules dracut-systemd base fs-lib shutdown"\ "bash systemd systemd-initrd systemd-sysusers modsign dbus-daemon kdump dbus udev-rules dracut-systemd base fs-lib shutdown"\
--kver "$1" "${MOUNT_FOLDER}/kdump-initrd-$1.img" --kver "$1" "${MOUNT_FOLDER}/kdump-initrd-$1.img"