2

How to recompile the file type of CPIO-archive (application/x-cpio)

enter image description here

I am able to unpack its contents with below command.

unmkinitramfs initrd .

enter image description here

But not able to recompile.

How can I Achive this?

PRATAP-PANABAKA
  • 127
  • 1
  • 15

2 Answers2

2

Ok, I took some motivation from this https://askubuntu.com/questions/777260/how-to-repack-initrd-img

Let us start with the assumption that your current directory is $DIR and it has the "initrd" from the live CD/casper/initrd. We will create a new initrd called myinitrd in the same ${DIR}

mkdir 18
unmkinitramfs initrd ${DIR}/18

# start with an empty file
rm -rf ${DIR}/myinitrd
touch ${DIR}/myinitrd

# Add the first microcode firmware
cd ${DIR}/18/early
find . -print0 | cpio --null --create --format=newc > ${DIR}/myinitrd

# Add the second microcode firmware
cd ${DIR}/18/early2
find kernel -print0 | cpio --null --create --format=newc >> ${DIR}/myinitrd

# Add the actual ram fs file system
cd ${DIR}/18/main
find . | cpio --create --format=newc | xz --format=lzma >> ${DIR}/myinitrd

# verify both initrds are the same
binwalk ${DIR}/myinitrd
binwalk ${DIR}/initrd
0

@PRATAP, based on your confirmation in the comments, can you try this?

I'm assuming the 3 directories are inside a parent directory, kernel/

find kernel/ | cpio -o -H newc > my_new_initrd

my_new_initrd should be your recompiled initrd

b0yfriend
  • 235