Updating a single file in a CPIO archive

1

I have a CPIO archive with the Linux image on it. With binwalk I can see that there are the following chunks:

DECIMAL       HEXADECIMAL     DESCRIPTION
--------------------------------------------------------------------------------
0             0x0             ASCII cpio archive (SVR4 with no CRC), file name: "kernel", file name length: "0x00000007", file size: "0x00000000"
120           0x78            ASCII cpio archive (SVR4 with no CRC), file name: "kernel/x86", file name length: "0x0000000B", file size: "0x00000000"
244           0xF4            ASCII cpio archive (SVR4 with no CRC), file name: "kernel/x86/microcode", file name length: "0x00000015", file size: "0x00000000"
376           0x178           ASCII cpio archive (SVR4 with no CRC), file name: "kernel/x86/microcode/.enuineIntel.align.0123456789abc", file name length: "0x00000036", file size: "0x00000000"
540           0x21C           ASCII cpio archive (SVR4 with no CRC), file name: "kernel/x86/microcode/GenuineIntel.bin", file name length: "0x00000026", file size: "0x001A3800"
1718960       0x1A3AB0        ASCII cpio archive (SVR4 with no CRC), file name: "TRAILER!!!", file name length: "0x0000000B", file size: "0x00000000"
1719296       0x1A3C00        gzip compressed data, NULL date (1970-01-01 00:00:00)
32277012      0x1EC8214       Zlib compressed data, default compression
70217888      0x42F70A0       Unix path: /usr/local/go/src/runtime/runtime-gdb.py
85577309      0x519CE5D       MySQL MISAM compressed data file Version 3
96044561      0x5B98611       Unix path: /usr/local/go/src/runtime/runtime-gdb.py
100702073     0x6009779       Zlib compressed data, default compression
106454594     0x6585E42       MySQL MISAM compressed data file Version 7
110250207     0x69248DF       Unix path: /usr/local/go/src/runtime/runtime-gdb.py
115809787     0x6E71DFB       Unix path: /usr/local/go/src/runtime/runtime-gdb.py

I need to extract the the gzipped one:

1719296       0x1A3C00        gzip compressed data, NULL date (1970-01-01 00:00:00)

and replace a single binary file within it, then repack the image.

That gzipped content is another CPIO image.

What is the best/easiest way of doing that?

disk-image
cpio
asked on Server Fault Jun 4, 2019 by jdevelop

1 Answer

0

the command you search for is

cpio -id < archive.cpio "TRAILER!!!"

You may not need -d as file is located in to the root path For more information you can check this Q/A

answered on Server Fault Jun 4, 2019 by Romeo Ninov

User contributions licensed under CC BY-SA 3.0