Packing and unpacking initrd: Difference between revisions

From Leo's Notes
This page was last edited on 15 April 2013, at 05:37.
Created page with "modify <code>initird.img</code> or other similar images To extract <code>initird.img</code>: # Go to an empty directory before extracting the image. # eg: mkdir -p /mnt/ini..."
 
No edit summary
Line 3: Line 3:
To extract <code>initird.img</code>:
To extract <code>initird.img</code>:
  # Go to an empty directory before extracting the image.
  # Go to an empty directory before extracting the image.
  # eg: mkdir -p /mnt/initrd_extract && cd /mnt/initrd_extract
  mkdir -p /mnt/initrd_extract && cd /mnt/initrd_extract
  gzip -dc < ../initrd.img | cpio -i
  gzip -dc < /path/to/initrd.img | cpio -i


To pack files back into <code>initrd.img</code>
To pack files back into <code>initrd.img</code>
  # Go to the directory containing the contents of the image.
  # Go to the directory containing the contents of the image.
  # eg: cd /mnt/initrd_extract
  cd /mnt/initrd_extract
  find . | cpio -o -c | gzip -9 > ../initrd.img
  find . | cpio -o -c | gzip -9 > /path/to/initrd.img
 
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]]

Revision as of 05:37, 15 April 2013

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.