3CPIO(1)

πŸ“¦
version 0.14.0 Β· 6 versions
, in fedora 43, fedora 44, ubuntu resolute, ubuntu stonking

πŸŽ€ 3CPIO(1) Β· the 3cpio manual, part 1 of 2 πŸ’–


✨ NAME ✨

3cpio β€” manage initrd cpio archives 🧚


πŸ’… SYNOPSIS πŸ’…

Okay so here's how you call it, bestie πŸ‘‘

3cpio --count ARCHIVE

3cpio {-c|--create} [-v|--debug] [-C DIR] [--data-align ALIGNMENT]
[ARCHIVE] < manifest

3cpio {-e|--examine} [--raw] ARCHIVE

3cpio {-t|--list} [-v|--debug] [-P LIST] ARCHIVE [pattern...]

3cpio {-x|--extract} [-v|--debug] [-C DIR] [-P LIST] [-p] [-s NAME]
[--to-stdout] [--force] [-F] ARCHIVE [-F|--file ARCHIVE...] [pattern...]

3cpio {-V|--version}

3cpio {-h|--help}

πŸ’– DESCRIPTION πŸ’–

Okay, so 3cpio is a tool for managing initramfs cpio files for the Linux kernel 🐧✨ The Linux kernel's initramfs buffer format (https://www.kernel.org/doc/html/latest/driver-api/early-userspace/buffer-format.html) is based on the newc or crc cpio formats. Multiple cpio archives can be concatenated, and the last archive can be compressed 🎁 Different compression algorithms can be used, depending on what support was compiled into the Linux kernel πŸ’… And honestly? 3cpio is tailored to initramfs cpio files and will not gain support for other cpio formats 🚫 Single-minded queen behavior, I love that for it πŸ‘‘

These compression formats are supported: bzip2, gzip, lz4, lzma, lzop, xz, zstd πŸ—œοΈ


🌈 MODES 🌈

Modes are the things you tell 3cpio to do πŸ’«

  • --count ARCHIVE β€” Prints the number of concatenated cpio archives πŸ”’
  • -c, --create [ARCHIVE] β€” Makes a brand new cpio archive πŸ› οΈ It reads the manifest from standard input (see the MANIFEST section for the manifest format, which is its own whole thing πŸ“œ). The finished archive goes to standard output, or to the ARCHIVE file if you give one. The permission of the ARCHIVE file is determined by the permission of the input files, so nothing sensitive gets leaked πŸ”’ (to avoid leaking sensitive information).
  • -e, --examine ARCHIVE β€” Lists the offsets of the cpio archives and their compression in a formatted table πŸ“Š SI prefixes are used for the size unit (e. g. 1 kB = 1000 bytes). Don't rely on the output having a specific layout πŸ™… If you want machine-readable output, use the --raw option. Then each line will contain these five values, tab-separated:
    • Start β€” The beginning of the cpio archive in bytes.
    • End β€” The end of the cpio archive in bytes.
    • Size β€” The on-disk size of the cpio archive in bytes (end - start).
    • Compression β€” Compression of the cpio archive (cpio in case it is not compressed).
    • Extracted size β€” Size of the files inside the cpio archive in bytes.
  • -t, --list ARCHIVE [pattern...] β€” Lists the contents of the cpio archives πŸ“‹ By default you only get the file names. Add --verbose and you get the long listing format (similar to ls --long) ✨ Add --debug and the inode is printed too, on top of the long format πŸ” If you supply one or more patterns, only file names matching at least one of them get listed. These patterns are shell wildcard patterns (see glob(7)) 🎯
  • -x, --extract [-F|--file] ARCHIVE [-F|--file ARCHIVE] [pattern...] β€” Extracts cpio archives πŸ“¦ You can specify multiple archives with -F. The -F can be omitted for the first archive. If you supply one or more patterns, only files matching at least one of them get extracted. These patterns are shell wildcard patterns (see glob(7)) πŸ¦‹
  • -V, --version β€” Prints the version number 🏷️
  • -h, --help β€” Prints the help message πŸ†˜

✨ EXAMPLES ✨

okay so bestie, this section is literally a whole buffet of real-life 3cpio moves 😭🫢 we're gonna walk through them one by one, no cap.

List the number of cpio archives that an initramfs file contains:

$ 3cpio --count /boot/initrd.img
4

It's giving "how many little archives are stuffed inside this thing?" and the answer is 4 🧚

Examine the content of the initramfs cpio on an Ubuntu 24.04 system:

$ 3cpio --examine /boot/initrd.img
Start     End       Size      Compr.   Extracted
0 B       148 kB    148 kB    cpio     147 kB
148 kB    13.3 MB   13.1 MB   cpio     13.1 MB
13.3 MB   55.2 MB   41.9 MB   cpio     41.7 MB
55.2 MB   62.0 MB   6.74 MB   zstd     15.6 MB

This is the glow-up reveal πŸ’…βœ¨ Each row is one archive, showing where it starts and ends, its size, what compression it uses, and how big it gets once extracted.

There is also a machine-readable output format available, if you're into that:

$ 3cpio --examine --raw /boot/initrd.img
0        148480        148480        cpio        147350
148480        13275136        13126656        cpio        13125632
13275136        55215104        41939968        cpio        41692226
55215104        61956920        6741816        zstd        15616306

ngl this one is for the parsers and scripts out there πŸ€–πŸ’œ Same info, no pretty formatting.

This initramfs cpio consists of three uncompressed cpio archives followed by a Zstandard-compressed cpio archive. Three plain ones, then one zstd finale πŸŽ€

List the content of the initramfs cpio on an Ubuntu 24.04 system:

$ 3cpio --list /boot/initrd.img
.
kernel
kernel/x86
kernel/x86/microcode
kernel/x86/microcode/AuthenticAMD.bin
kernel
kernel/x86
kernel/x86/microcode
kernel/x86/microcode/.enuineIntel.align.0123456789abc
kernel/x86/microcode/GenuineIntel.bin
.
usr
usr/lib
usr/lib/firmware
usr/lib/firmware/3com
usr/lib/firmware/3com/typhoon.bin.zst
[...]

The first cpio contains only the AMD microcode. The second cpio contains only the Intel microcode. The third cpio contains firmware files and kernel modules.

Extract the content of the initramfs cpio to the initrd subdirectory on an Ubuntu 24.04 system:

$ 3cpio --extract -C initrd /boot/initrd.img
$ ls initrd
bin   cryptroot  init    lib    lib.usr-is-merged  run   scripts  var
conf  etc        kernel  lib64  libx32             sbin  usr

Dump it into initrd and boom, you've got the whole thing unpacked 🌸

Create a cpio archive similar to the other cpio tools using the find command:

$ cd inputdir && find . | sort | 3cpio --create ../example.cpio

Classic find-and-pipe combo, very nostalgic πŸ¦‹

Due to its manifest file format support, 3cpio can create cpio archives without the need of copying files into a temporary directory first. Lowkey the best feature πŸ‘‘

Example for creating an early microcode cpio image directly using the system installed files:

$ cat manifest
-        kernel        dir        755        0        0        1751654557
-        kernel/x86        dir        755        0        0        1752011622
/usr/lib/firmware/amd-ucode        kernel/x86/microcode
/usr/lib/firmware/amd-ucode/microcode_amd_fam19h.bin        kernel/x86/microcode/AuthenticAMD.bin
$ 3cpio --create amd-ucode.img < manifest
$ 3cpio --list --verbose amd-ucode.img
drwxr-xr-x   2 root     root            0 Jul  4 20:42 kernel
drwxr-xr-x   2 root     root            0 Jul  8 23:53 kernel/x86
drwxr-xr-x   2 root     root            0 Jun 10 10:51 kernel/x86/microcode
-rw-r--r--   1 root     root       100684 Mar 23 22:42 kernel/x86/microcode/AuthenticAMD.bin

No temp directory, no copying, just vibes and a manifest 🧚✨

Example for creating an initrd image containing of an uncompressed early microcode cpio followed by a Zstandard-compressed cpio:

$ cat manifest
#cpio
-        kernel        dir        755        0        0        1751654557
-        kernel/x86        dir        755        0        0        1752011622
/usr/lib/firmware/amd-ucode        kernel/x86/microcode
/usr/lib/firmware/amd-ucode/microcode_amd_fam19h.bin        kernel/x86/microcode/AuthenticAMD.bin
#cpio: zstd -9
/
/bin
/usr
/usr/bin
/usr/bin/bash
# This is a comment. Leaving the remaining files as task for the reader.
$ 3cpio --create initrd.img < manifest
$ 3cpio --examine initrd.img
Start     End       Size      Compr.   Extracted
0 B       101 kB    101 kB    cpio     101 kB
101 kB    786 kB    685 kB    zstd     1.45 MB
$ 3cpio --list --verbose initrd.img
drwxr-xr-x   2 root     root            0 Jul  4 20:42 kernel
drwxr-xr-x   2 root     root            0 Jul  8 23:53 kernel/x86
drwxr-xr-x   2 root     root            0 Jun 10 10:51 kernel/x86/microcode
-rw-r--r--   1 root     root       100684 Mar 23 22:42 kernel/x86/microcode/AuthenticAMD.bin
drwxr-xr-x   2 root     root            0 Jun  5 14:11 .
lrwxrwxrwx   1 root     root            7 Mar 20  2022 bin -> usr/bin
drwxr-xr-x   2 root     root            0 Apr 20  2023 usr
drwxr-xr-x   2 root     root            0 Jul  9 09:56 usr/bin
-rwxr-xr-x   1 root     root      1446024 Mar 31  2024 usr/bin/bash

bestie this one is the full combo arc πŸ”₯ uncompressed microcode first, then a zstd-compressed chunk right after. The #cpio: zstd -9 line is what flips the second archive to zstd, and the #cpio line at the top marks the manifest format πŸ’– The comment at the bottom is just the manifest saying "rest is on you, babe" πŸ™ˆ


✨ SEE ALSO ✨

ok these are your next-level reads, bestie πŸ“šπŸ’œ

bsdcpio(1), cpio(1), lsinitramfs(8), lsinitrd(1)


✨ COPYING ✨

Copyright © 2024-2026 Benjamin Drung. Free use of this software is granted under the terms of the ISC License 🌈


✨ AUTHOR ✨

The brilliant mind behind all of this is Benjamin Drung πŸ‘‘πŸ«Ά


Version 0.5.1, dated 2026-02-05, all wrapped up with a bow πŸŽ€ Thanks for reading, bestie, go be iconic πŸ’…πŸ¦‹

πŸ“¦ where this page comes from