Extracting concatenated cpio archives

gunzip needs to be run only once (consuming all input), whereas cpio should be run once per embedded archive, like so:

gunzip -c <input.cgz | while cpio -i; do :; done

/usr/lib/dracut/skipcpio $your-initrd-img | zcat | cpio -id --no-absolute-file-names

or else

/usr/lib/dracut/skipcpio $your-img | gunzip -c | cpio -id

(in FreeBSD there is no --no-absolute-file-names option to cpio)

This small program skipcpio if part of dracut package. But you can download the code (skipcpio.c) and compile it even under FreeBSD.

You need this when extracting dracut created initrd images, at least under RedHat-powered distros, like Fedora. It places a file called "early_cpio" into the image, so extracting your initramfs in a normal way known before will not work.