I am trying to unpack an initramfs image obtained from an embedded system, but I get errors like cpio: premature end of archive
when using any utility for unpacking the file. I'll paste the file signature and some of the things I've tried down below:
$ file initramfs
initramfs: u-boot legacy uImage, OE and Crypt, Linux/ARM, RAMDisk Image (gzip), 6722916 bytes, Wed Jun 19 11:31:12 2019, Load Address: 0x00000000, Entry Point: 0x00000000, Header CRC: 0x9D0680ED, Data CRC: 0x2A1021B1
$ lsinitramfs initramfs
cpio: premature end of archive
$ zcat initramfs | cpio -idmv
gzip: initramfs: not in gzip format
cpio: premature end of archive
$ xz -dc < initramfs | cpio -idmv
xz: (stdin): File format not recognized
cpio: premature end of archive
Edit: I forgot to mention that I have tried all of these commands on ARM as well with the exact same results.
As shown in this post you can unpack uImage files using the following command:
tail -c+65 < initramfs | gunzip > unpacked_initramfs
The resultant unpacked_initramfs
file should have a signature like this:
$ file unpacked_initramfs
unpacked_initramfs: ASCII cpio archive (SVR4 with no CRC)
Then you can run whatever commands you need on that file (for example: lsinitramfs unpacked_initramfs
).
User contributions licensed under CC BY-SA 3.0