x86: add onie-installer image type

The current documentation for using OpenWRT on Mellanox Spectrum
switches (https://openwrt.org/toh/mellanox/spectrum) suggests
reflashing the entire harddrive from the recovery USB. This is not
the most friendly way to install a new OS on these switches. From
factory, they come with ONIE (Open Network Install Environment),
which is a linux-based preboot environment for fetching an OS
image from the network and installing it on disk. The installer
is a self-executing bash script that executes inside the ONIE
environment. The installer is expected to preserve the ONIE partition
for use as recovery environement. To be a better citizen on
these platforms, it would be preferrable to provide OpenWRT as
an ONIE-compatible installer.

This PR adds an ONIE_INSTALLER_IMAGES build option that produces
an ONIE compatible .bin. The generated .bin follows the ONIE demo
installer pattern [1]: it creates a new GPT partition
labelled OPENWRT-ROOT on the ONIE install device, formats ext4, extracts
the OpenWrt rootfs and kernel into it, installs GRUB into the existing
UEFI ESP under bootloader-id "OpenWrt", and adds a NVRAM boot entry via
efibootmgr.  ONIE-BOOT is preserved so ONIE rescue remains available.

Tested with the config at [2] on a Mellanox Spectrum SN3800 to produce
a booting OpenWRT install.

[1] https://github.com/opencomputeproject/onie/demo/installer/grub-arch/install.sh
[2] https://gist.github.com/Keno/abc8c5b72645e73fadd1ff0d9616b23d

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Signed-off-by: Keno Fischer <keno@juliahub.com>
Link: https://github.com/openwrt/openwrt/pull/23062
Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
This commit is contained in:
Keno Fischer
2026-04-22 14:10:37 +00:00
committed by Jonas Jelonek
parent 15593de376
commit c7e8cffcb2
3 changed files with 230 additions and 0 deletions
+15
View File
@@ -309,6 +309,21 @@ menu "Target Images"
depends on GRUB_IMAGES || GRUB_EFI_IMAGES
select PACKAGE_kmod-e1000
config ONIE_INSTALLER_IMAGES
bool "Build ONIE installer image (self-extracting .bin)"
depends on TARGET_x86
depends on GRUB_EFI_IMAGES
help
Build a self-extracting ONIE installer .bin for installing
OpenWrt on switches that ship with the Open Network Install
Environment (e.g. Mellanox/NVIDIA Spectrum-based SN series).
The resulting .bin wraps a tar payload (rootfs + kernel) in a
shell script that follows the ONIE demo installer pattern:
a new GPT partition labelled OPENWRT-ROOT is created for
OpenWrt, and the existing ONIE-BOOT partition is preserved so
ONIE rescue remains bootable.
config TARGET_SERIAL
string "Serial port device"
depends on TARGET_x86 || TARGET_armsr || TARGET_loongarch64