等到我在裸机上跑pxe的时候,发现是新旧两种机型混合,主板启动有legacy和uefi两种,woc。
思路其实很简单,dhcp有一些参数支持根据client的类型来match不同的启动文件,只需要导向到不同的启动文件,后面的事情就交给tftp了。uefi的启动文件稍稍有些不同,这里做一些记录。
DHCP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 # DHCP Server Configuration file. option space PXE; option PXE.mtftp-ip code 1 = ip-address; option PXE.mtftp-cport code 2 = unsigned integer 16; option PXE.mtftp-sport code 3 = unsigned integer 16; option PXE.mtftp-tmout code 4 = unsigned integer 8; option PXE.mtftp-delay code 5 = unsigned integer 8; option arch code 93 = unsigned integer 16; # RFC4578 ddns-update-style interim; ignore client-updates; authoritative; allow booting; allow bootp; allow unknown-clients; # internal subnet for my DHCP Server subnet 192.168.2.0 netmask 255.255.255.0 { range 192.168.2.200 192.168.2.255; default-lease-time 600; max-lease-time 7200; # IP of PXE Server class "pxeclients" { match if substring (option vendor-class-identifier, 0, 9) = "PXEClient"; next-server 192.168.2.11; if option arch = 00:07 { filename "uefi/shim.efi"; } else { filename "pxelinux.0"; } }
dhcp发放记录在/var/lib/dhcpd/dhcpd.leases
Tftp
1 2 # uefi files grub.cfg grubx64.efi initrd.img vmlinuz shim.efi
initrd.img vmlinuz
和之前一样,从/mnt/images/pxeboot/
下获取。
1 2 3 4 5 cp /mnt/images/pxeboot/initrd.img /x cp /mnt/images/pxeboot/vmlinuz /x cp /mnt/EFI/BOOT/grubx64.efi /x cp /boot/efi/EFI/centos/shim.efi /x cp /boot/efi/EFI/centos/grub.cfg /x
1 2 3 4 # modified part of grub.cfg linuxefi uefi/pxeboot/vmlinuz ks="http://192.168.2.11/centos7.cfg" nofb text biosdevname=0 ksdevice=bootif initrdefi uefi/pxeboot/initrd.img
Kickstart
autopart比较方便,自动分区。除非有特殊需求,不然autopart挺好用的。
packages使用core就足够了。
Reference