5

I have a file in /boot/initramfs.gz

extract it using tar -xzvf initramfs.gz -C ./ I got a file initramfs.

└──╼ $ file initramfs initramfs: ASCII cpio archive (SVR4 with no CRC)

It can be open using ark. But I want to change some files in this file initramfs.

enter image description here

I extracted it using ark and got a folder initramfs. Now I want to save it as before.

enter image description here

How do I create an ASCII cpio archive (SVR4 with no CRC) like the original?

Jeff Schaller
  • 66,199
  • 35
  • 114
  • 250
dotslash
  • 193
  • 1
  • 2
  • 6
  • 2
    You use `cpio` from the command line. However you probably _don't_ want to change initramfs files this way; next time you do an update which installs a patched kernel then the new initramfs generated for the new kernel won't have your changes in it. You should follow your OS distribution processes for adding files and stuff into it, so they are persisted. – Stephen Harris Jul 25 '16 at 21:54

1 Answers1

12

You can do this with GNU cpio:

$ find . | cpio -o -H newc > /tmp/file
40 blocks
$ file /tmp/file
/tmp/file: ASCII cpio archive (SVR4 with no CRC)
that other guy
  • 515
  • 4
  • 9
  • simple and best! – dotslash Jul 25 '16 at 22:06
  • 1
    `cpio -o -H newc` cpio: Invalid header "newc" specified USAGE: cpio -i[bcdfkmrstuv@BSV6] [-C size] [-E file] [-H hdr] [-I file [-M msg]] [-R id] [patterns] cpio -o[acv@ABLV] [-C size] [-H hdr] [-O file [-M msg]] cpio -p[adlmuv@LV] [-R id] directory Better use `cpio -o -c`. – schily Jul 26 '16 at 12:37