It usefull sometimes to edit the initrd/initramfs image of the system. This howto describes the simple and usual way to do it.
Hint: Mainstream distributions have own mechanisms to do this things. Take a look at mkinitramfs/mkinitrd. In such case your customized image can be overwritten by this tools, so try to do in on the right way;)
- Copy to the temporary folder
cd /tmp mkdir initrd cd initrd cp /boot/initrd* .
- Detect the type of image
gunzip -c -S "" initrd* > decompressed-initrd file decompressed-initrd
If you get something like “ASCII cpio archive (SVR4 with no CRC)” process with working with CPIO archive, if you get something like “Linux rev 1.0 ext2 filesystem data” process with working with ext2 image
- working with CPIO archive
rm decompressed-initrd cat initrd* | gzip -d | cpio -i rm initrd*
rm initrd* cat decompressed-initrd | cpio -i rm decompressed-initrd
find | cpio -H newc -o | gzip > ../newinitrd
- working with ext2 image
rm initrd* mkdir mnt mount -o loop decompressed-initrd mnt
umount mnt rm -rf mnt cat decompressed-initrd | gzip > ../newinitrd