Packing and unpacking initrd: Difference between revisions

From Leo's Notes
This page was last edited on 29 March 2015, at 06:03.
mNo edit summary
No edit summary
Line 16: Line 16:


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


[[Category:Linux]]
[[Category:Linux]]
{{Navbox Linux}}

Revision as of 06:03, 29 March 2015

modify initird.img or other similar images

To extract 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 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 file /path/to/initrd.img in order to determine the exact method of compression. The above commands above assumes cpio + gzip.