Booting rootfs From RAM (x86_64)

As a quick emergency OS option, can I get the official build of OpenWRT to accept a rootfs in cpio archive format as an initrd?

So, for example, download from 23.05.3 "generic-kernel.bin" and "rootfs.tar.gz", convert the rootfs to cpio format, place them in the /boot folder of the EFI system partition and then add to the system's grub.cfg:-

linux /boot/generic-kernel.bin
initrd /boot/rootfs.cpio.gz

I have tried this, but something goes wrong and it reboots instantly. Does the official kernel image have initramfs support?

(I wrote a short Python script to convert tar to cpio, seems to generate a valid archive but not extensively tested... :flushed: )

So this morning, I did a few things:-

  • Added "console=tty0" and "panic=30" to the kernel cmdline, this yielded output including:-
VFS: Cannot open root device "(null)" or unknown-block(1,0): error -6

So the kernel can't "see" the initrd.

  • If I add "initrd" to the kernel cmdline, it freezes whilst still showing GRUB.
  • Tested my generated cpio archives using 7-Zip, finding out that Python's tarfile module doesn't retain file type information in TarInfo.mode, so my archives had regular files where there should have been directories. Also fixed a padding issue at the end of the archive :face_with_open_eyes_and_hand_over_mouth:

So, I am thinking that without at least CONFIG_DEV_BLK_INITRD being enabled in the kernel config, this will never work.