Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

manage initrd cpio archives

License

NotificationsYou must be signed in to change notification settings

bdrung/3cpio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

3cpio is a tool to manage initramfs cpio files for the Linux kernel. The Linuxkernel'sinitramfs buffer formatis based around thenewc orcrc cpio formats. Multiple cpio archives can beconcatenated and the last archive can be compressed. Different compressionalgorithms can be used depending on what support was compiled into the Linuxkernel. 3cpio is tailored to initramfs cpio files and will not gain support forother cpio formats.

As of now, 3cpio supports examining, listing, and extracting the content of theinitramfs cpio.

Note: The Rust crate is named threecpio, because package names are notallowed to start with numbers.

Usage examples

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

$ 3cpio --examine /boot/initrd.img0cpio77312cpio7286272cpio85523968zstd

This initramfs cpio consists of three uncompressed cpio archives followed by aZstandard-compressed cpio archive.

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

$ 3cpio --list /boot/initrd.img.kernelkernel/x86kernel/x86/microcodekernel/x86/microcode/AuthenticAMD.binkernelkernel/x86kernel/x86/microcodekernel/x86/microcode/.enuineIntel.align.0123456789abckernel/x86/microcode/GenuineIntel.bin.usrusr/libusr/lib/firmwareusr/lib/firmware/3comusr/lib/firmware/3com/typhoon.bin.zst[...]

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

Extract the content of the initramfs cpio to theinitrd subdirectory on anUbuntu 24.04 system:

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

Benchmark results

Listing the content of the initrd

Runtime comparison measured withtime over five runs on different initramfscpios:

SystemKernelComp.SizeFiles3cpiolsinitramfslsinitrd
Ryzen 7 5700G6.5.0-27-genericzstd¹102 MB34960.052s14.243s–³
Ryzen 7 5700G VM6.8.0-22-genericzstd¹63 MB19340.042s7.239s–³
Ryzen 7 5700G VM6.8.0-22-genericzstd²53 MB17830.061s0.452s0.560s
RasPi Zero 2W6.5.0-1012-raspizstd¹24 MB15380.647s56.253s–³
RasPi Zero 2W6.5.0-1012-raspizstd²30 MB20281.141s2.286s6.118s
RasPi Zero 2W6.8.0-1002-raspizstd¹51 MB25320.713s164.575s–³
RasPi Zero 2W6.8.0-1002-raspizstd -1²47 MB27781.156s2.842s9.508s
RasPi Zero 2W6.8.0-1002-raspixz²41 MB27786.922s13.451s35.184s

Legend:

  1. generated by initramfs-tools
  2. generated bydracut --force --${compression}. On Raspberry Pi Zero 2W thereis not enough memory for the defaultzstd -15. So using the default frominitramfs-tools there:dracut --force --compress "zstd -1 -q -T0"
  3. lsinitrd only reads the first two cpio archives of the file, but theinitramfs consists of four cpios.

Results:

  • 3cpio is 87 to 274 times faster than lsinitramfs for images generated byinitramfs-tools.
  • 3cpio is two to eight times faster than lsinitramfs for images generatedby dracut.
  • 3cpio five to nine times faster than lsinitrd for images generated by dracut.

Commands used:

3cpio -t /boot/initrd.img-${version} | wc -ltime 3cpio -t /boot/initrd.img-${version} > /dev/nulltime lsinitramfs /boot/initrd.img-${version} > /dev/nulltime lsinitrd /boot/initrd.img-${version} > /dev/null

List the content of single cpio archive that is not compressed (seedoc/Benchmarks.md for details) on a Raspberry Pi Zero 2W:

CommandMean [ms]Min [ms]Max [ms]Relative
3cpio -t initrd.img84.3 ± 1.182.187.01.00
bsdcpio -itF initrd.img98.4 ± 0.996.4101.01.17 ± 0.02
cpio -t --file initrd.img1321.2 ± 2.81314.61327.615.68 ± 0.20
CommandMean [ms]Min [ms]Max [ms]Relative
3cpio -tv initrd.img109.2 ± 1.1106.9111.71.00
bsdcpio -itvF initrd.img114.9 ± 1.1112.6117.41.05 ± 0.01
cpio -tv --file initrd.img1423.0 ± 3.51417.11440.613.03 ± 0.13

Extracting the content of the initrd

Benchmarking the time to extraction initrd:

SystemDistroKernelSizeFiles3cpiounmkinitramfs
Ryzen 7 5700Gnoble6.8.0-35-generic70 MB20970.107s6.698s
Ryzen 7 5700Gjammy6.8.0-35-generic112 MB37890.455s2.217s
Ryzen 7 5700Gbookworm6.1.0-21-amd6462 MB29350.268s1.362s
RasPi Zero 2Wnoble6.8.0-1005-raspi53 MB25345.075s173.847s

Raw measurements can be found indoc/Benchmarks.md.

Naming and alternatives

The tool is named 3cpio because it is the third cpio tool besidesGNU cpio andbsdcpio provided bylibarchive. 3cpio is also the third tool that canlist the content of initramfs cpio archives besideslsinitramfs frominitramfs-tools andlsinitrdfromdracut.

About

manage initrd cpio archives

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp