Modifying an existing initrd
It is sometimes useful to change an initrd to make additional programs available during initramfs shell.
To get to initramfs shell, add break=point to the kernel boot options, where point is one of top, modules, premount, mount, mountroot, bottom, init.
Extracting the contents of the initfs into a working directory:
mkdir /tmp/initrd-root cd /tmp/initrd-root gunzip --stdout /boot/initrd.img-4.9.0-11-amd64 | cpio -imd --quiet
Modify the file system created however you see fit, and then re-create it.
eg. cp /sbin/resize2fs sbin/
cd /tmp/initid-root find . | cpio -H newc -o | gzip -9 -n > ../initrd.img-4.9.0-11-amd64
The new initrd needs to be put back in place. Keep a backup of the original just in case it's all up shit creek now!
cp -piv ../initrd.img-4.9.0-11-amd64 /boot/initrd.img-4.9.0-11-amd64
Don't forget to update-grub so that the new initrd is included.