Unpacking and repacking an initrd (Initial Ramdisk)

Here are the steps to unpack and repack an initrd.

Unpacking:

[root@localhost ~]# mkdir -p ./A/B
[root@localhost ~]# cd A
[root@localhost ~]# cp /boot/initrd-2.6.18-406 .
[root@localhost ~]# mv initrd-2.6.18-406 initrd-2.6.18-406.gz
[root@localhost ~]# gunzip initrd-2.6.18-406.gz
[root@localhost ~]# cd B
[root@localhost ~]# cpio -i < ../initrd-2.6.18-406

Make your changes to the filesystem which was decompressed to the cwd.

Repacking:

[root@localhost ~]# find | cpio -H newc -o > ../initrd-2.6.18-406.custom
[root@localhost ~]# gzip -9 ../initrd-2.6.18-406.custom
[root@localhost ~]# mv ../initrd-2.6.18-406.custom /boot

Source: http://www.alexonlinux.com/opening-and-modifying-the-initrd

Leave a Reply