2019年1月2日 星期三

ipxe for legacy and efi

make bin/undionly.kpxe  EMBED=legacy.ipxe
make bin-x86_64-efi/ipxe.efi EMBED=efi.ipxe

#!ipxe
set user-class QCT-UEFI
dhcp && goto chainloading || echo
dhcp && goto chainloading || echo
dhcp && goto chainloading || echo
exit
:chainloading
#echo chainload1
isset ${filename} && chain ${filename} || dhcp
#echo chainload2
isset ${filename} && chain ${filename} || dhcp
#echo chainload3
isset ${filename} && chain ${filename}
exit

dhcp configuration

subnet 10.102.99.0 netmask 255.255.255.0 {
  pool {
    allow members of "allocation-class-1";
    range dynamic-bootp 10.102.99.150 10.102.99.199;
    next-server 10.102.99.30;

     if exists user-class {
         if option user-class = "QCT-LEGACY" {
           filename "http://10.102.99.30/ks.html";
         } elsif option user-class = "QCT-UEFI" {
           filename "http://10.102.99.30/ks.html";
         }
     } else {
         if substring(hardware,1,3) = 08:00:27 or  substring(hardware,1,3) = 08:00:26 {
           filename "http://10.102.99.30/ks.html";
         } else {
           if substring(option vendor-class-identifier, 0, 20) = "PXEClient:Arch:00000" {
             filename "undionly.kpxe";
           } elsif substring(option vendor-class-identifier, 0, 20) = "PXEClient:Arch:00007" {
             filename "ipxe.efi";
           }
         }
     }
  }


chainload - please note, initrd value needs to match the one listed in kernel parameter.
#!ipxe
initrd http://172.16.1.1/initrd.img
chain http://172.16.1.1/vmlinuz initrd=initrd.img root=live:http://172.16.1.1/rootfs.img ro readonlyroot rd.net.timeout.dhcp=45 rd.writable.fsimg rd.live.dir=../../../tmp/curl_fetch_url0/ console=tty0 console=ttyS1,115200n8