Error: "stage 2 init script (/mnt-root//init) not found" on QEMU armv7l

I’m emulating an armv7l system on QEMU using this command (direct linux kernel boot), and encounter the error below. Any ideas how to fix this?

qemu-system-arm \
    -M xilinx-zynq-a9 \
    -serial /dev/null \
    -serial mon:stdio \
    -display none \
    -dtb ./dtbs/zynq-zc702.dtb \
    -kernel linux-6.1.55-zImage \
    -initrd initrd-linux-6.1.55-initrd \
    -drive file=nixos-sd-image-23.11pre-git-armv7l-linux.img,if=sd,format=raw \
    -append "console=ttyPS0 root=/dev/mmcblk0p2 rw rootfstype=ext4 rootwait" 

<<< NixOS Stage 1 >>>

loading module dm_mod...
[    3.828440] device-mapper: ioctl: 4.47.0-ioctl (2022-07-28) initialised: dm-devel@redhat.com
running udev...
Starting systemd-udevd version 253.6
[    5.363616] macb e000b000.ethernet end0: renamed from eth0
kbd_mode: KDSKBMODE: Inappropriate ioctl for device
starting device mapper and LVM...
[    9.060726] random: crng init done
checking /dev/disk/by-label/NIXOS_SD...
fsck (busybox 1.36.1)
[fsck.ext4 (1) -- /mnt-root/] fsck.ext4 -a /dev/disk/by-label/NIXOS_SD
NIXOS_SD: recovering journal
NIXOS_SD: clean, 131122/146304 files, 563392/570399 blocks
mounting /dev/disk/by-label/NIXOS_SD on /...
[    9.373136] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Quota mode: none.
[    9.377930] EXT4-fs (mmcblk0p2): re-mounted. Quota mode: none.
stage 2 init script (/mnt-root//init) not found

An error occurred in stage 1 of the boot process, which must mount the
root filesystem on `/mnt-root' and then start stage 2.  Press one
of the following keys:

  r) to reboot immediately
  *) to ignore the error and continue
[   13.931508] amba f8801000.etb: deferred probe pending
[   13.931560] amba f8803000.tpiu: deferred probe pending
[   13.931602] amba f8804000.funnel: deferred probe pending
[   13.931649] amba f889c000.ptm: deferred probe pending
[   13.931718] amba f889d000.ptm: deferred probe pending

The sd image is designed to be booted by the u-boot. You can try something from here https://github.com/ARM-software/u-boot/blob/402465214395ed26d6fa72d9b6097c7adbf6a966/doc/README.qemu-arm
Alternatively, use full kernel cmdline from extlinux.conf file stored in the image

1 Like

Which u-boot should I generate, for the emulated device (e.g. zynq-zc702) or for qemu (e.g. qemu-arm)? Will have a look as well for the full kernel cmdline alternative.

The alternative method works! Will have to test for the u-boot method too.

Here is the new command:

qemu-system-arm \
    -M xilinx-zynq-a9 \
    -serial /dev/null \
    -serial mon:stdio \
    -display none \
    -dtb ./dtbs/zynq-zc702.dtb \
    -kernel linux-6.1.55-zImage \
    -initrd initrd-linux-6.1.55-initrd \
    -drive file=nixos-sd-image-23.11pre-git-armv7l-linux.img,if=sd,format=raw \
    -append "init=/nix/store/plk7w1mbd1x5vw9636511fmjdwv2jrbd-nixos-system-nixos-23.11pre-git/init console=ttyPS0,115200n8 loglevel=7"