Packing and unpacking initrd

From Leo's Notes
Revision as of 19:13, 24 February 2017 by Leo (talk | contribs) (Text replacement - "<code>" to "{{code|")
This page was last edited on 24 February 2017, at 19:13.

modify {{code|initird.img or other similar images

To extract {{code|initird.img:

 # Go to an empty directory before extracting the image.
 mkdir -p /mnt/initrd_extract && cd /mnt/initrd_extract
 gzip -dc < /path/to/initrd.img | cpio -i

To pack files back into {{code|initrd.img

 # Go to the directory containing the contents of the image.
 cd /mnt/initrd_extract
 find . | cpio -o -c | gzip -9 > /path/to/initrd.img

You may want to run {{code|file /path/to/initrd.img in order to determine the exact method of compression. The above commands above assumes {{code|cpio + gzip.