Is there a way to use a directory as initrd when booting QEMU?

I know how to use the -kernel and -initrd flags for QEMU to boot a kernel and initrd without needing to first create a bootable device containing those two files. Now I am wondering if there is a way to skip the step of using cpio to create the initrd file as well.

Usually when making changes to the directory containing all the files for my initrd. I would test them by running

(cd initrd ; find . | cpio --quiet -R 0:0 -o -H newc) | gzip >initrd.gz
qemu-system-i386 -kernel /boot/vmlinuz -initrd initrd.gz

Can I somehow achieve the same without having to create the initrd file on the file system?

What I tried so far was the following:

qemu-system-i386 -kernel /boot/vmlinuz -initrd initrd

resulting in the kernel starting but panicing when trying to mount the root file system.

qemu-system-i386 -kernel /boot/vmlinuz -initrd <(
   cd initrd ; find . | cpio --quiet -R 0:0 -o -H newc)

resulting in QEMU dying with:

qemu: error reading initrd /dev/fd/63: Illegal seek

1 Answer 1


I suspect not - as far as I can tell from the QEMU documentation, it does not support reading kernel or initrd from stdin, which is essentially what you were trying to do with the redirect. I believe Qemu expects an actual file descriptor (based on the /dev/fd/63 error), so you're probably out of luck. You could ask on the Qemu mailing list or IRC channel and see if there's any specific expertise there to accomplish what you're trying to do, but I'm guessing you're going to have to rebuild that every time.

  • 1
    I already sent an implementation of this feature to the mailing list. But there was no response.
    – kasperd
    Dec 12, 2016 at 21:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.