iPXE的Build-up請參考下方。
iPXE選單的設定,請參考之前寫的:https://jiruiwu.pixnet.net/blog/post/356092933
DHCP config 這邊跟標準PXE設定一樣,Config包含這些內容
舉例:
option architecture-type code 93 = unsigned integer 16;
subnet 192.168.0.0 netmask 255.255.255.0 {
range dynamic-bootp 192.168.0.100 192.168.0.254;
option broadcast-address 192.168.0.255;
option routers 192.168.0.1;
class "pxeclients" {
match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
# PXE servers hostname or IP address
# next-server pxe.jiruiwu.tpe;
next-server 192.168.0.10;
if option architecture-type = 00:07 {
filename "BOOTX64.EFI";
}
else {
filename "pxelinux.0";
}
}
}
[UEFI] PXE的grub config(E.g.: /var/lib/tftpboot/grub.cfg)設定如下
menuentry "iPXE - IPv4 (If BIOS boot PXE by IPv4)" {
set root=(http,192.168.0.5)
chainloader /media/ipxe.efi /media/boot.ipxe
}
menuentry "iPXE - IPv6 (IF BIOS boot PXE by IPv6)" {
set root=(http,[2020:db8:ffff:9999::5])
chainloader /media/ipxe.efi /media/boot.ipxe
}
運作流程是 UEFI Boot --> LAN PXE Boot--> TFTP boot --> bootx64.efi
--> TFTP boot --> Bootloader (General Linux Bootloader. E.g.: grub.efi / grub.cfg)
--> Chain load to another Bootloader: iPXE
--> Chain load to WDS(wdsmgfw.efi)
•Q1: Why not chain load WDS from the Bootloader grub.efi?
Ans: General Linux grub.efi doesn't support execute WDS loader.
•Q2: Why not using iPXE directly?
Ans: In my experience. Under some situation, iPXE can't boot the correct NIC port/card which is selected in BIOS Boot Menu.
Especially SUT with multi-NIC ports and not all of them with cable connected and all of network with network boot services.
Setup iPXE: Build iPXE under Linux for PXE redirect to iPXE then chain load WDS.
Precondition: git gcc make binutils perl xz-devel and mtools have been installed in OS.
- Command: yum list installed | grep “git\|gcc\|make\|binutils\|perl\|xz-devel\|mtools”
- Command: yum install -y git gcc make binutils perl xz-devel mtools (or dnf install -y {packages} )
And have a native Linux PXE server working in LAN(Local Area Network).
Build iPXE:
(a). Clone Source Code
- Command: git clone https://github.com/ipxe/ipxe.git
- Command: cd ipxe/src
(b). Embed a Boot Script to fetch a menu from an HTTP server
- Command: vim autoexec.ipxe
|
#!ipxe echo IPv4 iPXE configuration dhcp chain http://192.168.0.5/media/boot.ipxe |
(c). Compile with the embedded script:
- Command: make bin-x86_64-efi/ipxe.efi EMBED=autoexec.ipxe
(d). Create an ‘iPXE menu’ file under PXE HTTP folder.
- Command: vim /var/www/html/media/boot.ipxe
|
#!ipxe menu iPXE Boot Options #menu PXE Boot Options - Client net0 Info:(IP ${net0/ip}, MAC ${net0/mac}) # Figure out if client is 64-bit capable cpuid --ext 29 && set arch x64 || set arch x86 cpuid --ext 29 && set archl amd64 || set archl i386 #################### MAIN MENU #################### item wds1 WDS(Windows Deployment Services) - Parameter 1: Chain Load item wds2 WDS(Windows Deployment Services) - Parameter 2: Imgexec Load item exit Exit and Reset item #Empty Line item shell iPXE shell - Default Option choose --default shell --timeout 30000 option && goto ${option} :wds1 set wdsserver 192.168.0.6 set netX/next-server 192.168.0.6 set filename /boot/x64/bootmgfw.efi chain tftp://${wdsserver}/boot%5Cx64%5Cwdsmgfw.efi # Change '/' to '%5C'. It's used to UEFI-Boot to WDS. UEFI Mode! #chain tftp://${wdsserver}/boot/x64/wdsmgfw.efi # It's used to UEFI-Boot to WDS. UEFI Mode! (OK on other site) :wds2 set wdsserver 192.168.0.6 set netX/next-server 192.168.0.6 imgexec tftp://${wdsserver}/boot%5Cx64%5Cwdsmgfw.efi # Change '/' to '%5C'. It's used to UEFI-Boot to WDS. UEFI Mode! #imgexec tftp://${wdsserver}/boot/x64/wdsmgfw.efi # It's used to UEFI-Boot to WDS. UEFI Mode! (OK on other site) :shell shell :exit #exit # Mask and enable 'reset'. reboot |
(e). Edit PXE UEFI menu: Add a boot option for boot iPXE.
- Command: vim /var/lib/tftpboot/grub.cfg
|
menuentry "iPXE - ( Select iPXE to boot WDS )" { set root=(http,192.168.0.5) chainloader /media/ipxe.efi } |
Note: The native PXE bootloader is extracted from ‘grub2-efi-x64-{version}.rpm’, but there is probably an issue where it cannot properly chainload iPXE.
E.g.:
grub2-efi-x64-2.02-129.el8.x86_64.rpm: chainload iPXE success:
grub2-efi-x64-2.06-120.el9.x86_64.rpm: chainload iPXE fail. It stuck/hanging at after show "iPXE initialising devices..."
