Packing and unpacking initrd: Difference between revisions
From Leo's Notes
This page was last edited on 9 August 2021, at 17:36.
m Leo moved page Pack/Unpack initrd to Packing and unpacking initrd |
mNo edit summary |
||
| Line 1: | Line 1: | ||
modify {{code|initird.img}} or other similar images | To modify {{code|initird.img}} or other similar images, first determine the compression method used by the initrd file. Below, we see that it's using gzip which is typical. | ||
{{Highlight | |||
| code = # file initrd.img | |||
initramfs.gz: gzip compressed data, last modified: Thu Jul 22 04:16:52 2021, max compression, from Unix, original size 46489600 | |||
| lang = terminal | |||
}} | |||
To | To unpack and extract {{code|initird.img}}, compressed with gzip: | ||
{{Highlight | |||
| code = ## 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 | |||
| lang = terminal | |||
}} | |||
To re-pack files back into {{code|initrd.img}} after making your changes: | |||
{{Navbox Linux}}[[Category:Linux]] | {{Highlight | ||
| code = # Go to the directory containing the contents of the image. | |||
# cd /mnt/initrd_extract | |||
# find . {{!}} cpio -o -c {{!}} gzip -9 > /path/to/initrd.img | |||
| lang = terminal | |||
}}<br /> | |||
{{Navbox Linux}} | |||
[[Category:Linux]] | |||
Revision as of 17:36, 9 August 2021
To modify initird.img or other similar images, first determine the compression method used by the initrd file. Below, we see that it's using gzip which is typical.
# file initrd.img
initramfs.gz: gzip compressed data, last modified: Thu Jul 22 04:16:52 2021, max compression, from Unix, original size 46489600
To unpack and extract initird.img, compressed with gzip:
## 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 re-pack files back into initrd.img after making your changes:
# Go to the directory containing the contents of the image.
# cd /mnt/initrd_extract
# find . | cpio -o -c | gzip -9 > /path/to/initrd.img