下载
git clone git://git.ipxe.org/ipxe.git
准备嵌入文件
vim embed.ipxe
#!ipxe
dhcp
chain http://SERVER/menu.ipxe
编译BIOS和UEFI启动程序
make bin/undionly.kpxe EMBED=embed.ipxe
make bin-x86_64-efi/ipxe.efi EMBED=embed.ipxe
vim菜单ipxe.menu
#!ipxe
#default
set base-url http://$Server
set menu-timeout 10000
set submenu-timeout ${menu-timeout}
isset ${menu-default} || set menu-default exit
## iPXE Menu Settings
:start
menu Boot Menu -- Client Info:(IP ${net0/ip}, MAC ${net0/mac})
item --gap -- ------------------------- Installers ---------------------------
item windows-bios Windows BIOS
item windows-uefi Windows UEFI
item centos7 CentOS 7 x86-64
item fedora Fedora 30
item ubuntu-desktop Ubuntu 19.04 Desktop
item ubuntu-server Ubuntu 18.04 Server
item --gap -- ------------------------- Advanced Options ---------------------------
item shell Drop to iPXE shell
item reboot Reboot
choose --timeout ${menu-timeout} --default ${menu-default} selected || goto cancel
set menu-timeout 0
goto ${selected}
:cancel
echo You cancelled the menu, dropping you to a shell
:shell
echo Type 'exit' to get the back to the menu
shell
set menu-timeout 0
set submenu-timeout 0
goto start
:failed
echo Booting failed, dropping to shell
goto shell
:reboot
reboot
:exit
exit
#Chainload to WDS
:windows-bios
set netX/next-server $WDServer
imgexec tftp://${netX/next-server}/boot/x64/wdsnbp.com
goto start
:windows-uefi
set netX/next-server $WDServer
imgexec tftp://${netX/next-server}/boot/x64/wdsmgfw.efi
goto start
# Centos Installation
:centos7
echo Starting CentOS 7 installer
#kernel ${base-url}/CentOS7/isolinux/vmlinuz ksdevice= inst.repo=${base-url}/
kernel ${base-url}/CentOS7/isolinux/vmlinuz ks=${base-url}/ks.cfg/CentOS-ks.cfg
initrd ${base-url}/CentOS7/isolinux/initrd.img
boot || goto failed
goto start
#Fedora Desktop Installation
:fedora
cpuid --ext 29 && set arch x86_64 || set arch i386
set repo ${base-url}/Fedora30/Workstation/x86_64/os
# Start installer
kernel ${repo}/images/pxeboot/vmlinuz initrd=initrd.img ks=${base-url}/ks.cfg/Fedora.cfg
initrd ${repo}/images/pxeboot/initrd.img
boot || goto failed
goto start
#Ubuntu Live Desktop
#The live desktop iso can not suuport netboot, use nfs to install ubuntu desktop
:ubuntu-desktop
echo Starting Ubuntu 19.04 Desktop installer
set server_ip $NFSserver
set nfs_path /opt/iPXE/ubuntu-19.04-Desktop
kernel nfs://${server_ip}${nfs_path}/casper/vmlinuz || read void
initrd nfs://${server_ip}${nfs_path}/casper/initrd || read void
imgargs vmlinuz initrd=initrd root=/dev/nfs boot=casper netboot=nfs nfsroot=${server_ip}:${nfs_path} url=${base-url}/ks.cfg
boot || goto failed
goto start
#Ubuntu Server Installation
:ubuntu-server
echo Starting Ubuntu 18.04 installer
set base ${base-url}/ubuntu-18.04-server
kernel ${base}/install/netboot/ubuntu-installer/amd64/linux
initrd ${base}/install/netboot/ubuntu-installer/amd64/initrd.gz
imgargs linux auto=true fb=false url=${base}/preseed/ubuntu.seed
boot || goto failed
goto start
安装配置Nginx
把启动菜单 ipxe.menu放入网页目录
安装配置TFTP
yum install tftp-server -y
- vim /etc/xinetd.d/tftp
disable = no
- 启动服务
systemctl start tftp.socket
systemctl start tftp
- 把 undionly.kpxe, ipxe.efi 放入TFTP目录 /var/lib/tftpboot