Minimum OpenWrt x64 memory requirements QEMU, EFI vs legacy

I have been observing strange OpenWrt behaviors on QEMU q35 machine. The command to boot is nothing unusual except from virtio devices plugged into PCI Express ports to improve performance, and serial output (no GPU emulation). The images I use:

  • openwrt-21.02.2-x86-64-generic-ext4-combined.img
  • openwrt-21.02.2-x86-64-generic-ext4-combined-efi.img

First problem: the minimum memory required to boot is 132MiB (qemu-system-x86_64 -m 132M) on UEFI, and 39MiB on legacy. If I boot it with 131MiB (or 38MiB on legacy), once I get past the GRUB boot menu, I get error: out of memory and the system reboots.

Second problem: the memory reported by OpenWrt is always lower than what QEMU assigns to it.

  • I assigned 132MiB on UEFI, and free reported 103MiB (104,988KiB) total memory. Everything ran fine even after I used a balloon device to steal 55MiB from OpenWrt to return to the host. The balloon device complained if I tried to steal 60MiB, which I thought should be fine to leave OpenWrt with ~43MiB of RAM.
  • I assigned 39MiB on legacy, which was the minimum to boot. Kernel panic happened a lot during boot due to low memory. Once booted into BusyBox, it ran very slowly and free reported 17MiB (17,704KiB) total memory.

Can someone explain these strange behaviors?

P.S: Why UEFI and legacy have different memory requirements and why is 131MiB not enough to boot OpenWrt?

What strange behavior?

You're intentionally running OpenWrt with low memory and questioning the memory errors.

Maybe I'm missing something?

Video memory setting not 0?

1 Like

... and kernel + daemons allocate RAM, if you have 128MB, you hardly going to have 128 once the OS's booted.

1 Like

I used -nodefaults and did not add any GPU device to the machine. It is equivalent to -vga none if using default settings. lspci shows no GPU device.

You are missing the most important points of the question: why UEFI and legacy have different memory requirements and why is 131MiB not enough to boot OpenWrt?

1 Like

Are you saying that you use an EFI and an IMG...and you're wondering why they're different...?

One of the moderators commented on that not too long ago...somewhere...


I know from my tech days...EFI loads much differently.