Format:cpio newc (initramfs)
| On this wiki | Facts · Code · Notes · Topics |
|---|
The cpio newc archive (magic 070701, 070702 with checksum) that Linux unpacks into the root ramfs at boot as initramfs/initrd: 110-byte ASCII hex headers, names and data padded to 4 bytes, ended by a TRAILER!!! entry, optionally compressed and concatenated.
Identification
- Starts with ASCII
070701(30 37 30 37 30 31), or070702for the variant with a data byte-sum. A compressed initramfs starts with the compressor's magic instead (gzip1F 8B, zstd28 B5 2F FD, xzFD 37 7A 58 5A 00, lz402 21 4C 18legacy, bzip2BZh, lzma, lzo). - The kernel buffer may be a sequence of parts: zero padding, uncompressed cpio, compressed cpio. Intel/AMD microcode is commonly an uncompressed cpio placed before the compressed main archive, so
binwalk-style tools must restart at each part.
Other cpio variants share the extractor in tools such as libarchive: odc (ASCII octal, magic 070707, 76-byte header), afio large (070727) and the old binary format (16-bit magic octal 070707, 0x71C7, either byte order, 26-byte header); see Fact:cpio newc (initramfs)/magic/cpio format magics, Fact:cpio newc (initramfs)/struct/odc header and Fact:cpio newc (initramfs)/struct/binary header. RPM payloads are newc (Format:RPM package).
Layout
Fact:cpio newc (initramfs)/struct/newc header (110 bytes, 13 fields of 8 hex digits after the 6-character magic). Fact:cpio newc (initramfs)/behavior/Entry layout and padding: header, file name with NUL, pad to 4, data, pad to 4. The last entry is named TRAILER!!! with size 0.
Kernel specifics
- Hard links: for non-directories with
c_nlink > 1the tuple (c_maj, c_min, c_ino) is tracked; a repeated tuple makes a hard link and data may come on any instance. A TRAILER resets the table, which lets separately made archives be concatenated. c_mtimeis ignored unless CONFIG_INITRAMFS_PRESERVE_MTIME is set.c_chksumis a plain 32-bit sum, not a CRC.c_namesizemay include extra NULs (used to align file data).- Generated at build time by
usr/gen_init_cpiofrom a file list, or bycpio -H newc, dracut, mkinitramfs.
Reversing tips
Unpack with cpio -idmv < file (after decompressing) or unmkinitramfs; the init script (/init, often a shell script or busybox) shows module loading order and the pivot to the real root.
See Platform:Linux kernel; source: Documentation/driver-api/early-userspace/buffer-format.rst.
Code & repositories
- https://github.com/torvalds/linux @
32c52ec87d6245ee2d12ed5dd509e40062939b50· license: GPL-2.0 WITH Linux-syscall-note (read from COPYING; GitHub's detector did not classify it)
Linux kernel sources (GPL-2.0): Documentation/arch/x86/boot.rst, include/uapi/linux/btf.h, include/linux/module.h, vermagic.h, export.h, scripts/kallsyms.c, scripts/mod/modpost.c, scripts/extract-vmlinux
Tested on: source read, not run: not run; source read at the pinned commit · checked 2026-10-18; last activity 2026-10-18 - https://github.com/libarchive/libarchive @
7f149b1076f27449a6cfcb92e5046aea8590f833· license: BSD-2-Clause (declared by the contributor for the files used; GitHub reports BSD-2-Clause (read from COPYING; GitHub's API was busy) for the repository)
libarchive: archive_read_support_format_cpio.c (odc, newc, binary) and _ar.c readers
Tested on: source read, not run · checked 2026-10-19