Files
warewulf/etc/ipxe/default.ipxe
Shane Nehring 0ecef40ba9 adding dracut_static ipxe method
Signed-off-by: Shane Nehring <snehring@iastate.edu>
2026-04-09 11:37:39 -05:00

150 lines
5.0 KiB
Plaintext

#!ipxe
echo
echo Warewulf v4 (iPXE)
echo
set next start
goto metadata
:start
{{- if not .ImageName }}
echo !!
echo !! No image defined for {{.Fqdn}}.
echo !! Rebooting in 30s...
echo !!
sleep 30
reboot
{{- end }}
set base http://{{.Authority}}
set hwaddr {{.Hwaddr}}
set params assetkey=${asset}&uuid=${uuid}
echo Downloading kernel image...
kernel --name kernel ${base}/kernel/${hwaddr}?${params} || goto reboot
{{- if .Tags.IPXEMenuEntry }}
set method {{ .Tags.IPXEMenuEntry }}
{{- else }}
# https://github.com/warewulf/warewulf/issues/222
iseq ${platform} efi && set method imgextract || set method initrd
{{- end }}
:menu
menu Warewulf v4 image provisioning method
item imgextract Single-stage with imgextract
item initrd Single-stage with initrd
item initrd_nocompress Single stage with initrd (no compression)
item dracut Two stage with dracut
item dracut_static Two stage with dracut and static ips
item shell iPXE shell
choose --default ${method} --timeout 2000 method && goto ${method} || goto menu
:imgextract
set next imgextract_continue
goto metadata
:imgextract_continue
echo
echo Downloading compressed image with imgextract...
imgextract --name image ${base}/image/${hwaddr}?${params}&compress=gz || goto error_use_initrd
echo Downloading compressed system overlay image with imgextract...
imgextract --name system ${base}/system/${hwaddr}?${params}&compress=gz || goto error_reboot
{{- if not (eq .TLS true) }}
echo Downloading compressed runtime overlay image with imgextract...
imgextract --name runtime ${base}/runtime/${hwaddr}?${params}&compress=gz && set runtime_initrd initrd=runtime || echo Unable to download runtime overlay. (ignored)
{{- end }}
goto boot_single_stage
:error_use_initrd
echo Encountered an error. Now using initrd.
goto initrd_continue
:initrd
set next initrd_continue
goto metadata
:initrd_continue
echo
echo Downloading compressed image with initrd...
initrd --name image ${base}/image/${hwaddr}?${params}&compress=gz || goto error_reboot
echo Downloading compressed system overlay with initrd...
initrd --name system ${base}/system/${hwaddr}?${params}&compress=gz || goto error_reboot
{{- if not (eq .TLS true) }}
echo Downloading compressed runtime overlay with initrd...
initrd --name runtime ${base}/runtime/${hwaddr}?${params}&compress=gz && set runtime_initrd initrd=runtime || echo Unable to download runtime overlay. (ignored)
{{- end }}
goto boot_single_stage
:initrd_nocompress
set next initrd_nocompress_continue
goto metadata
:initrd_nocompress_continue
echo
echo Downloading uncompressed image with initrd...
initrd --name image ${base}/image/${hwaddr}?${params} || goto error_reboot
echo Downloading uncompressed system overlay with initrd...
initrd --name system ${base}/system/${hwaddr}?${params} || goto error_reboot
{{- if not (eq .TLS true) }}
echo Downloading uncompressed runtime overlay with initrd...
initrd --name runtime ${base}/runtime/${hwaddr}?${params} && set runtime_initrd initrd=runtime || echo Unable to download runtime overlay. (ignored)
{{- end }}
goto boot_single_stage
:dracut
set next dracut_continue
goto metadata
:dracut_continue
echo
echo Downloading dracut initramfs...
initrd --name initramfs ${base}/initramfs/${hwaddr}?${params} || goto error_reboot
set dracut_net rd.neednet=1 {{range $devname, $netdev := .NetDevs}}{{if and $netdev.Hwaddr $netdev.Device}} ifname={{$netdev.Device}}:{{$netdev.Hwaddr}} ip={{$netdev.Device}}:dhcp {{end}}{{end}}
set dracut_wwinit root=wwinit:{{default "tmpfs" .Root}} wwinit.server=${base} wwinit.uri=${base}/provision/${hwaddr} init=/warewulf/run-init
goto boot_two_stage_dracut
:dracut_static
set next dracut_static_continue
goto metadata
:dracut_static_continue
echo
echo Downloading dracut initramfs...
initrd --name initramfs ${base}/initramfs/${hwaddr}?${params} || goto error_reboot
set dracut_net rd.neednet=1 {{range $devname, $netdev := .NetDevs}}{{if and $netdev.Hwaddr $netdev.Device}} ifname={{$netdev.Device}}:{{$netdev.Hwaddr}} ip={{$netdev.Ipaddr}}::{{$netdev.Gateway}}:{{$netdev.Netmask}}::{{$netdev.Device}}:on {{end}}{{end}}
set dracut_wwinit root=wwinit:{{default "tmpfs" .Root}} wwinit.server=${base} wwinit.uri=${base}/provision/${hwaddr} init=/warewulf/run-init
goto boot_two_stage_dracut
:boot_single_stage
echo Booting (single stage)...
boot kernel initrd=image initrd=system ${runtime_initrd} wwid={{.Hwaddr}} {{.KernelArgs}} || goto error_reboot
:boot_two_stage_dracut
echo Booting dracut (first stage)...
boot kernel initrd=initramfs ${dracut_net} ${dracut_wwinit} wwid={{.Hwaddr}} {{.KernelArgs}} || error_reboot
:error_reboot
echo !!
echo !! Encountered an error.
echo !! rebooting in 15s...
echo !!
sleep 15
reboot
:shell
shell
goto menu
:metadata
echo Warewulf Server:
echo * Ipaddr: {{.Ipaddr}}
echo * Port: {{.Port}}
echo * Authority: {{.Authority}}
echo
echo This node:
echo * Fqdn: {{.Fqdn}}
echo * Hwaddr: {{.Hwaddr}}
echo * ImageName: {{.ImageName}}
{{- if .KernelVersion }}
echo * KernelVersion: {{.KernelVersion}}
{{- else }}
echo * KernelVersion: (image default)
{{- end }}
echo * KernelArgs: {{.KernelArgs}}
goto ${next}