At OpenWrt 22.03.x, is it possible to mount overlay on initramfs?
I asked the question with chatGPT, I try the script and it is not working.
I try to use procd to auto mount overlay, but the log show
[ 12.249624] block: attempting to load /tmp/ubifs_cfg/upper/etc/config/fstab
[ 12.256895] block: unable to load configuration (fstab: Entry not found)
[ 12.263911] block: attempting to load /tmp/ubifs_cfg/etc/config/fstab
[ 12.270756] block: unable to load configuration (fstab: Entry not found)
[ 12.277655] block: attempting to load /etc/config/fstab
[ 12.283856] block: extroot: not configured
[ 12.290334] mount_root: switching to ubifs overlay
[ 12.301604] mount_root: pivot_root failed /mnt /mnt/rom: Invalid argument
[ 12.308738] mount_root: switching to ubifs failed - fallback to ramoverlay
[ 12.316213] mount_root: opening /proc/filesystems failed: No such file or directory
[ 12.324139] mount_root: BUG: no suitable fs found
The rootfs (initial ramfs) cannot be pivot_root()ed. The recommended method of changing the root filesystem in this case is to delete everything in rootfs, overmount rootfs with the new root, attach stdin/stdout/stderr to the new /dev/console, and exec the new init(1). Helper programs for this process exist; see switch_root(8).
So AFAICS your only option is to copy the content of the initramfs to a newly mounted tmpfs, and use that to create a layered filesystem. Then you can pivot_root or chroot into it. But the old initramfs keeps in memory. The alternative is to do from init, in process 1, then you can switch_root to the new filesystem, destroying the old one.