Skip to content

Commit a30d8a3

Browse files
terrellnIngo Molnar
authored andcommitted
usr: Add support for zstd compressed initramfs
- Add support for a zstd compressed initramfs. - Add compression for compressing built-in initramfs with zstd. I have tested this patch by boot testing with buildroot and QEMU. Specifically, I booted the kernel with both a zstd and gzip compressed initramfs, both built into the kernel and separate. I ensured that the correct compression algorithm was used. I tested on arm, aarch64, i386, and x86_64. This patch has been tested in production on aarch64 and x86_64 devices. Additionally, I have performance measurements from internal use in production. On an aarch64 device we saw 19 second boot time improvement from switching from lzma to zstd (27 seconds to 8 seconds). On an x86_64 device we saw a 9 second boot time reduction from switching from xz to zstd. Signed-off-by: Nick Terrell <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Tested-by: Sedat Dilek <[email protected]> Reviewed-by: Kees Cook <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 48f7ddf commit a30d8a3

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

usr/Kconfig

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,15 @@ config RD_LZ4
100100
Support loading of a LZ4 encoded initial ramdisk or cpio buffer
101101
If unsure, say N.
102102

103+
config RD_ZSTD
104+
bool "Support initial ramdisk/ramfs compressed using ZSTD"
105+
default y
106+
depends on BLK_DEV_INITRD
107+
select DECOMPRESS_ZSTD
108+
help
109+
Support loading of a ZSTD encoded initial ramdisk or cpio buffer.
110+
If unsure, say N.
111+
103112
choice
104113
prompt "Built-in initramfs compression mode"
105114
depends on INITRAMFS_SOURCE != ""
@@ -196,6 +205,17 @@ config INITRAMFS_COMPRESSION_LZ4
196205
If you choose this, keep in mind that most distros don't provide lz4
197206
by default which could cause a build failure.
198207

208+
config INITRAMFS_COMPRESSION_ZSTD
209+
bool "ZSTD"
210+
depends on RD_ZSTD
211+
help
212+
ZSTD is a compression algorithm targeting intermediate compression
213+
with fast decompression speed. It will compress better than GZIP and
214+
decompress around the same speed as LZO, but slower than LZ4.
215+
216+
If you choose this, keep in mind that you may need to install the zstd
217+
tool to be able to compress the initram.
218+
199219
config INITRAMFS_COMPRESSION_NONE
200220
bool "None"
201221
help

usr/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ compress-$(CONFIG_INITRAMFS_COMPRESSION_LZMA) := lzma
1515
compress-$(CONFIG_INITRAMFS_COMPRESSION_XZ) := xzmisc
1616
compress-$(CONFIG_INITRAMFS_COMPRESSION_LZO) := lzo
1717
compress-$(CONFIG_INITRAMFS_COMPRESSION_LZ4) := lz4
18+
compress-$(CONFIG_INITRAMFS_COMPRESSION_ZSTD) := zstd
1819

1920
obj-$(CONFIG_BLK_DEV_INITRD) := initramfs_data.o
2021

0 commit comments

Comments
 (0)