PXE批量部署Linux五:使用iPXE代替PXELINUX

PXELINUX基本已经没有人在维护了,iPXE在支持HTTP等高级传输协议的同时还支持动态语言php之类的解析,同时还可以烧录在网卡上替代网卡出厂设置。
唯一比PXELINUX复杂的是这玩意需要自己编译,官方释出的版本会一直重复一个死循环。官方网站给的依赖包有问题,同时iPXE有自己的语法,pxeliux.cfg下的文件不能直接拿来用。这次重复搞这些东西基本上把以前踩过的坑重新都踩了一次,记录一下免得下次又浪费时间

 http://ipxe.org/cmd

 Download and boot a Linux kernel with an initrd

kernel http://192.168.0.1/vmlinuz
initrd http://192.168.0.1/initrd.img
boot

 [root@kickstart ks]# uname -a

Linux kickstart.share.demo 3.10.0-957.el7.x86_64 #1 SMP Thu Nov 8 23:39:32 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
yum -y install gcc binutils make perl liblzma xz-devel mtools mkisofs

[root@kickstart ~]# cd ipxe/src/
[root@kickstart src]# cat demo.ipxe
#!ipxe
dhcp
chain http://kickstart.share.demo/ks/boot.ipxe

[root@kickstart src]# make bin/undionly.kpxe EMBED=demo.ipxe

[root@kickstart src]# cat /var/www/html/ks/boot.ipxe
#!ipxe

echo product...........: ${product}
echo manufacturer......: ${manufacturer}
echo platform..........: ${platform}
echo chip .............: ${chip}
echo serial............: ${serial}
echo asset.............: ${asset}
echo mac...............: ${mac}
echo ip................: ${ip}
echo netmask...........: ${netmask}
echo gateway...........: ${gateway}
echo dns...............: ${dns}
echo domain............: ${domain}
echo dhcp-server.......: ${dhcp-server}
echo filename..........: ${filename}
echo next-server.......: ${next-server}
echo boot menu will show in 5 seconds
sleep 5

#login
#iseq ${username} fire && goto start || goto error

:start
menu
item --gap -- Vetting CentOS
item --key 7 CentOS7 7---- CentOS 7
item --key 6 CentOS6 6---- CentOS 6

choose --default CentOS7 --timeout 6000 target && goto ${target}

:CentOS7
kernel http://kickstart.share.demo/centos7/images/pxeboot/vmlinuz ks=http://kickstart.share.demo/ks/cenos7_text.ks
initrd http://kickstart.share.demo/centos7/images/pxeboot/initrd.img
boot
:CentOS6
kernel http://kickstart.share.demo/centos6/images/pxeboot/vmlinuz ks=http://kickstart.share.demo/ks/centos6_text.ks
initrd http://kickstart.share.demo/centos6/images/pxeboot/initrd.img
boot

:local
sanboot --no-describe --drive 0x80 || goto start
:shell
shell || goto start
:reboot
reboot || goto start
:error
echo You are not intened to be here
echo This is for TEST use only
echo Which will destory ALL YOU HARDDISK DATA
echo If you still believe you need credentials
echo blame jere@
echo Warning will be disappeared in 30 seconds
echo And your computer will start from local hard disk automatically
sleep 30
local || reboot

转载于:https://blog.51cto.com/jerkou/2339308

  • 1
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值