Skip to content

Instantly share code, notes, and snippets.

@warewolf
Created December 22, 2021 00:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save warewolf/eeb645abcde939fa18251c02a433b4fe to your computer and use it in GitHub Desktop.
Save warewolf/eeb645abcde939fa18251c02a433b4fe to your computer and use it in GitHub Desktop.
append to args with "set args ${args} newstuffhere"
#!ipxe
# menu-url, boot-url and sanboot-url is set in bootstrap.ipxe
# Setup some basic convenience variables
isset ${menu-timeout} || set menu-timeout 5000
isset ${submenu-timeout} || set submenu-timeout ${menu-timeout}
set base-iqn iqn.2012-12.com.xabean.sandbox
set base-iscsi iscsi:${iscsi-server}:::1:${base-iqn}
# Set initiator-iqn to either hostname or mac
isset ${hostname} && set initiator-iqn ${base-iqn}:${hostname} || set initiator-iqn ${base-iqn}:${mac}
# Ensure we have menu-default set to something
isset ${menu-default} || set menu-default exit
# Figure out some typical client information
cpuid --ext 29 && set arch x64 || set arch x86
cpuid --ext 29 && set archl 64 || set archl 32
cpuid --ext 29 && set archf x86_64 || set archf i386
cpuid --ext 29 && set archw amd64 || set archf x86
###################### MAIN MENU ####################################
:start
menu iPXE http boot menu for ${initiator-iqn}
# ...
item --key i menu-install (I)nstallers...
# ...
############################ INSTALLER MENU #########################
:menu-install
menu Installers for ${initiator-iqn}
item --key f fedora-34-install-local Install (F)edora 34 to local drive
item fedora-34-install Install Fedora 31 to iSCSI
item --gap --
item --key t text Enable (t)ext install
item --key v vnc Enable (V)NC install
item --key s serial-console Enable (s)erial console for installers
:vnc
set vnc-console vnc
goto menu-install
:serial-console
echo -n Enter serial port number, e.g 0 for ttyS0 ${}
read serial-port
set serial-console console=tty1 console=ttyS${serial-port},115200
goto menu-install
:text
set text-console text nomodeset nouveau.modeset=0
goto menu-install
############################ FEDORA 34
# the actual boot process
:fedora-34-start
set distro fc34
set repo-url nfs:192.168.1.1:/nfs4exports/${distro}_${archl}
set base-url ${boot-url}/${distro}_${archl}
kernel ${base-url}/vmlinuz || goto failed
initrd ${base-url}/initrd.img || goto failed
# stitch together kernel command line args from user selections from ipxe menu
set args ${args} inst.repo=${repo-url}
set args ${args} ${serial-console}
set args ${args} ${vnc-console}
set args ${args} initrd=initrd.img
imgargs vmlinuz ${args}
boot || goto failed
goto start
:fedora-34-install-local
echo Starting Fedora ${distro} ${archl} local installer for ${initiator-iqn}
goto fedora-34-start
:fedora-34-rescue
echo Starting Fedora ${distro} ${archl} local installer for ${initiator-iqn}
set root-path ${base-iscsi}:${hostname}.boot.fedora
sanhook ${root-path} || goto failed
set args ${args} rescue
set args ${args} ip-ibft
set args ${args} ip=eth0:dhcp
goto fedora-34-start
:fedora-34-rescue-local
echo Starting Fedora ${distro} ${archl} local installer for ${initiator-iqn}
set args ${args} rescue
set args ${args} ip-ibft
set args ${args} ip=eth0:dhcp
goto fedora-34-start
:fedora-34-install
set distro fc34
echo Starting Fedora ${distro} ${archl} local installer for ${initiator-iqn}
set root-path ${base-iscsi}:${hostname}.boot.fedora
login
sanhook ${root-path} || goto failed
set args ${args} ip-ibft
set args ${args} ip=eth0:dhcp
goto fedora-34-start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment