Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

docs: initramfs: update compression and mtime descriptions

Update the document to reflect that initramfs didn't replace initrd
following kernel 2.5.x.
The initramfs buffer format now supports many compression types in
addition to gzip, so include them in the grammar section.
c_mtime use is dependent on CONFIG_INITRAMFS_PRESERVE_MTIME.

Signed-off-by: David Disseldorp <ddiss@suse.de>
Link: https://lore.kernel.org/r/20250402033949.852-2-ddiss@suse.de
Reviewed-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Christian Brauner <brauner@kernel.org>

authored by

David Disseldorp and committed by
Christian Brauner
418556fa 0af2f6be

+21 -13
+21 -13
Documentation/driver-api/early-userspace/buffer-format.rst
··· 4 4 5 5 Al Viro, H. Peter Anvin 6 6 7 - Last revision: 2002-01-13 8 - 9 - Starting with kernel 2.5.x, the old "initial ramdisk" protocol is 10 - getting {replaced/complemented} with the new "initial ramfs" 11 - (initramfs) protocol. The initramfs contents is passed using the same 12 - memory buffer protocol used by the initrd protocol, but the contents 7 + With kernel 2.5.x, the old "initial ramdisk" protocol was complemented 8 + with an "initial ramfs" protocol. The initramfs content is passed 9 + using the same memory buffer protocol used by initrd, but the content 13 10 is different. The initramfs buffer contains an archive which is 14 - expanded into a ramfs filesystem; this document details the format of 15 - the initramfs buffer format. 11 + expanded into a ramfs filesystem; this document details the initramfs 12 + buffer format. 16 13 17 14 The initramfs buffer format is based around the "newc" or "crc" CPIO 18 15 formats, and can be created with the cpio(1) utility. The cpio 19 - archive can be compressed using gzip(1). One valid version of an 20 - initramfs buffer is thus a single .cpio.gz file. 16 + archive can be compressed using gzip(1), or any other algorithm provided 17 + via CONFIG_DECOMPRESS_*. One valid version of an initramfs buffer is 18 + thus a single .cpio.gz file. 21 19 22 20 The full format of the initramfs buffer is defined by the following 23 21 grammar, where:: ··· 23 25 * is used to indicate "0 or more occurrences of" 24 26 (|) indicates alternatives 25 27 + indicates concatenation 26 - GZIP() indicates the gzip(1) of the operand 28 + GZIP() indicates gzip compression of the operand 29 + BZIP2() indicates bzip2 compression of the operand 30 + LZMA() indicates lzma compression of the operand 31 + XZ() indicates xz compression of the operand 32 + LZO() indicates lzo compression of the operand 33 + LZ4() indicates lz4 compression of the operand 34 + ZSTD() indicates zstd compression of the operand 27 35 ALGN(n) means padding with null bytes to an n-byte boundary 28 36 29 - initramfs := ("\0" | cpio_archive | cpio_gzip_archive)* 37 + initramfs := ("\0" | cpio_archive | cpio_compressed_archive)* 30 38 31 - cpio_gzip_archive := GZIP(cpio_archive) 39 + cpio_compressed_archive := (GZIP(cpio_archive) | BZIP2(cpio_archive) 40 + | LZMA(cpio_archive) | XZ(cpio_archive) | LZO(cpio_archive) 41 + | LZ4(cpio_archive) | ZSTD(cpio_archive)) 32 42 33 43 cpio_archive := cpio_file* + (<nothing> | cpio_trailer) 34 44 ··· 80 74 81 75 The c_mode field matches the contents of st_mode returned by stat(2) 82 76 on Linux, and encodes the file type and file permissions. 77 + 78 + c_mtime is ignored unless CONFIG_INITRAMFS_PRESERVE_MTIME=y is set. 83 79 84 80 The c_filesize should be zero for any file which is not a regular file 85 81 or symlink.