Boot SmartOS platform images through PXE

One of the installation options for SmartOS is pxe, this option comes in handy when we are not able to use an usb stick. To boot through ipxe we need ipxe binary on the host that you want to install SmartOS and then just boot into the EFI shell and type the following:

dhcp
chain --autofree https://yourhost/your_ipxe_script 

Here is a sample script to boot through ipxe, this is the smartos.pxe script that Triton uses


#!ipxe

#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#

#
# Copyright 2021 Joyent, Inc.
# Copyright 2022 MNX Cloud, Inc.
#

:custom
clear smartos_build
clear kflags
set bp_console ttya
set bp_smartos true
set bp_noimport false
set kmdb_e false
set kmdb_b false
set space:hex 20:20
set space ${space:string}
goto smartos_menu

:smartos_menu
menu Triton SmartOS
item --gap Platform Images:
item 20230214T155114Z ${space} 20230214T155114Z
item 20230309T001400Z ${space} 20230309T001400Z
item 20230329T172606Z ${space} 20230329T172606Z
item 20210812T031946Z ${space} 20210812T031946Z
item 20230409T163109Z ${space} 20230409T163109Z
item 20230410T000252Z ${space} 20230410T000252Z

item --gap Options:
item change_console ${space} OS Console: ${bp_console}
item toggle_pool ${space} Rescue mode: ${bp_noimport}
item toggle_kmdb_e ${space} Load Kernel Debugger: ${kmdb_e}
item toggle_kmdb_b ${space} Boot Kernel Debugger First: ${kmdb_b}

iseq ${bp_noimport} true && item --gap ${space} ||
iseq ${bp_noimport} true && item --gap ${space} Zpool will not be imported. Rescue mode root password can be found at ||
iseq ${bp_noimport} true && item --gap ${space} https://us-central.manta.mnx.io/Joyent_Dev/public/SmartOS/smartos.html ||

choose --default 20221229T230932Z --timeout 10000 smartos_build &&
iseq ${smartos_build} change_console && goto change_console ||
iseq ${smartos_build} toggle_pool && goto toggle_pool ||
iseq ${smartos_build} toggle_kmdb_e && goto toggle_kmdb_e ||
iseq ${smartos_build} toggle_kmdb_b && goto toggle_kmdb_b ||
goto smartos_boot

:smartos_boot
iseq ${kmdb_e} true && set kflags:hex 2d:6b ||
iseq ${kmdb_b} true && set kflags:hex 2d:6b:64 ||
kernel os/${smartos_build}/platform/i86pc/kernel/amd64/unix ${kflags:string} -B console=${bp_console},${bp_console}-mode="115200,8,n,1,-",smartos=${bp_smartos},noimport=${bp_noimport}${root_shadow:string}
module os/${smartos_build}/platform/i86pc/amd64/boot_archive type=rootfs name=ramdisk || goto fail
module os/${smartos_build}/platform/i86pc/amd64/boot_archive.hash type=hash name=ramdisk || goto fail
boot || goto smartos_menu

:change_console
iseq ${bp_console} text && set bp_console ttya && goto smartos_menu ||
iseq ${bp_console} ttya && set bp_console ttyb && goto smartos_menu ||
iseq ${bp_console} ttyb && set bp_console ttyc && goto smartos_menu ||
iseq ${bp_console} ttyc && set bp_console ttyd && goto smartos_menu ||
iseq ${bp_console} ttyd && set bp_console text && goto smartos_menu

:toggle_pool
iseq ${bp_noimport} true && set bp_noimport false || set bp_noimport true
iseq ${bp_noimport} true && set bp_smartos false || set bp_smartos true
iseq ${bp_noimport} false && clear root_shadow || set root_shadow:hex 2c:72:6f:6f:74:5f:73:68:61:64:6f:77:3d:27:24:35:24:32:48:4f:48:52:6e:4b:33:24:4e:76:4c:6c:6d:2e:31:4b:51:42:62:42:30:57:6a:6f:50:37:78:63:49:77:47:6e:6c:6c:68:7a:70:32:48:6e:54:2e:6d:44:4f:37:44:70:78:59:41:27:0a
goto smartos_menu

:toggle_kmdb_e
iseq ${kmdb_e} true && set kmdb_e false || set kmdb_e true
iseq ${kmdb_e} false && set kmdb_b false ||
goto smartos_menu

:toggle_kmdb_b
iseq ${kmdb_b} true && set kmdb_b false || set kmdb_b true
iseq ${kmdb_b} true && set kmdb_e true ||
goto smartos_menu

:smartos_exit
clear menu
exit 0


For this script to work, we need the following tree structure so it's able to pull the needed files, basically is just a directory called os, and inside you will need to decompress the platform.gz image and rename the directory contents to match the following structure:

os
|-- 20210812T031946Z
|   `-- platform
|       |-- etc
|       |   `-- version
|       |       `-- platform
|       |-- i86pc
|       |   |-- amd64
|       |   |   |-- boot_archive
|       |   |   |-- boot_archive.gitstatus
|       |   |   |-- boot_archive.hash
|       |   |   `-- boot_archive.manifest
|       |   `-- kernel
|       |       `-- amd64
|       |           `-- unix
|       `-- root.password
|-- 20221229T010131Z
|   `-- platform
|       |-- etc
|       |   `-- version
|       |       `-- platform
|       |-- i86pc
|       |   |-- amd64
|       |   |   |-- boot_archive
|       |   |   |-- boot_archive.gitstatus
|       |   |   |-- boot_archive.hash
|       |   |   `-- boot_archive.manifest
|       |   `-- kernel
|       |       `-- amd64
|       |           `-- unix
|       `-- root.password
|-- 20221229T230932Z
|   `-- platform
|       |-- etc
|       |   `-- version
|       |       `-- platform
|       |-- i86pc
|       |   |-- amd64
|       |   |   |-- boot_archive
|       |   |   |-- boot_archive.gitstatus
|       |   |   |-- boot_archive.hash
|       |   |   `-- boot_archive.manifest
|       |   `-- kernel
|       |       `-- amd64
|       |           `-- unix
|       `-- root.password
|-- 20230214T155114Z
|   `-- platform
|       |-- etc
|       |   `-- version
|       |       `-- platform
|       |-- i86pc
|       |   |-- amd64
|       |   |   |-- boot_archive
|       |   |   |-- boot_archive.gitstatus
|       |   |   |-- boot_archive.hash
|       |   |   `-- boot_archive.manifest
|       |   `-- kernel
|       |       `-- amd64
|       |           `-- unix
|       `-- root.password
|-- 20230309T001400Z
|   `-- platform
|       |-- etc
|       |   `-- version
|       |       `-- platform
|       |-- i86pc
|       |   |-- amd64
|       |   |   |-- boot_archive
|       |   |   |-- boot_archive.gitstatus
|       |   |   |-- boot_archive.hash
|       |   |   `-- boot_archive.manifest
|       |   `-- kernel
|       |       `-- amd64
|       |           `-- unix
|       `-- root.password
|-- 20230329T172606Z
|   `-- platform
|       |-- etc
|       |   `-- version
|       |       `-- platform
|       |-- i86pc
|       |   |-- amd64
|       |   |   |-- boot_archive
|       |   |   |-- boot_archive.gitstatus
|       |   |   |-- boot_archive.hash
|       |   |   `-- boot_archive.manifest
|       |   `-- kernel
|       |       `-- amd64
|       |           `-- unix
|       `-- root.password
|-- 20230409T163109Z
|   `-- platform
|       |-- etc
|       |   `-- version
|       |       `-- platform
|       |-- i86pc
|       |   |-- amd64
|       |   |   |-- boot_archive
|       |   |   |-- boot_archive.gitstatus
|       |   |   |-- boot_archive.hash
|       |   |   `-- boot_archive.manifest
|       |   `-- kernel
|       |       `-- amd64
|       |           `-- unix
|       `-- root.password
|-- 20230410T000252Z
|   `-- platform
|       |-- etc
|       |   `-- version
|       |       `-- platform
|       |-- i86pc
|       |   |-- amd64
|       |   |   |-- boot_archive
|       |   |   |-- boot_archive.gitstatus
|       |   |   |-- boot_archive.hash
|       |   |   `-- boot_archive.manifest
|       |   `-- kernel
|       |       `-- amd64
|       |           `-- unix
|       `-- root.password

Here 20210812T031946Z represents a menu entry in the ipxe script, that when selected it will boot the kernel and required files from that location.


References

How to pxe boot from Ubuntu

PXE booting SmartOS