网络启动二:之PXE:企业应用
前几天写了IPXE简单应用内容,今天详细介绍使用PXE在企业中的应用,部署Linux系统和Windows系统。
一、搭建环境
1.1.操作系统:CentOS6.9 Min / CentOS7.4 Min 172.16.30.59
安装文件存放服务器 http://172.16.30.121 目录有centos6.9 centos7.3 ubuntu16 eg..
安装过程略。
1.2.安装 tftp-server dhcp
sudo yum install tftp-server dhcp
1.3.配置tftp和dhcp
1.3.1.dhcp
vi /etc/dhcp/dhcpd.conf
-------------------------------
echo "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 client-system-arch code 93 = unsigned integer 16;
#option domain-name-servers 8.8.8.8, 195.235.96.90;
allow booting;
allow bootp;
default-lease-time 600;
max-lease-time 7200;
#ddns-update-style interim;
subnet 172.16.30.0 netmask 255.255.255.0 {
range 172.16.30.50 172.16.30.70;
option routers 172.16.30.59;
class "pxeclients" {
match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
next-server 172.16.30.59;
if option client-system-arch = 00:07 or option client-system-arch = 00:09 {
#filename "pxelinux/BOOTX64.efi";
filename "pexlinux/efi64/syslinux.efi";
} else {
filename "pxelinux/pxelinux.0";
#filename "pxelinux/BOOTX64.efi";
}
}
#server-name "pingu";
#next-server 172.16.30.100;
}
" >>/etc/dhcp/dhcpd.conf
-------------------
chkconfig --level 345 dhcpd on
service start dhcpd
1.3.2.tftp
1.修改tftp配置文件
echo "in.tftpd: 172.16.*.* :ALLOW" >>/etc/hosts.allow
sed -i '/disable/s/yes/no/' /etc/xinetd.d/tftp
service start xinetd
基础环境完毕,下一步安装syslinux,此处我们不采用CentOS安装盘里面的软件包,而采用官网最新包。
1.4官方网站syslinux
http://www.syslinux.org/
https://www.kernel.org/pub/linux/utils/boot/syslinux/Testing/6.04/syslinux-6.04-pre1.tar.gz
下载最新版本即可,目前为syslinux6.04
文件下载位置 /home/yluser/
1.3.安装依赖包
官方指定的依赖包
sudo yum install perl gcc nasm libuuid-devel
cd /home/yluser
tar zxvf syslinux-6.04-pre1.tar.gz
cd syslinux-6.04
具体编译情况,请查阅syslinux-6.04/doc/building.txt文档,
make 默认编译所有类型。
make
sudo make install
默认安装位置/usr/share/syslinux
根据dhcp的配置tftp目录,拷贝以下文件到指定目录
mkdir -p /var/lib/tftpboot/pxelinux/{pxelinux.cfg,centos7,centos6,ubuntu16,esxi6,win7,win10,winserver}
cp /usr/share/syslinux/{pxelinux.0,menu.c32,vesamenu.c32,memdisk,ldlinux.c32,libutil.c32,libcom32.c32} /var/lib/tftpboot/pxelinux
cp -R /usr/share/syslinux/{efi32,efi64} /var/lib/tftpboot/pxelinux
wget http://172.16.30.121/centos7.4/isolinux/splash.png -P /var/lib/tftpboot/pxelinux
wget http://172.16.30.121/centos7.4/isolinux/{initrd.img,vmlinuz} -P /var/lib/tftpboot/pxelinux/centos7.4
wget http://172.16.30.121/centos6.9/isolinux/{initrd.img,vmlinuz} -P /var/lib/tftpboot/pxelinux/centos6
vi pxelinux.cfg/default
------------------------
default vesamenu.c32
#prompt 1
timeout 600
display boot.msg
menu background splash.png
menu title PXE Dep Linux and Windows
menu color border 0 #ffffffff #00000000
menu color sel 7 #ffffffff #ff000000
menu color title 0 #ffffffff #00000000
menu color tabmsg 0 #ffffffff #00000000
menu color unsel 0 #ffffffff #00000000
menu color hotsel 0 #ff000000 #ffffffff
menu color hotkey 7 #ffffffff #ff000000
menu color scrollbar 0 #ffffffff #00000000
label linux
menu label ^Centos6.9 Min
menu default
kernel centos6/vmlinuz
append initrd=centos6/initrd.img ip=dhcp repo=http://172.16.30.121/centos6.9 ks=http://172.16.30.121/kickstarts/Centos-6.x-min.cfg ksdevice=eth1
label linux
menu label ^Centos7.4 Min
kernel centos7.4/vmlinuz
append initrd=centos7.4/initrd.img ip=dhcp repo=http://172.16.30.121/centos7.4 ks=http://172.16.30.121/kickstarts/Centos-7.x-min.cfg
label linux
menu label ^Windows 10
kernel memdisk raw iso
append initrd=win10/W10X32_CN_PE.iso
-----------------------
具体配置参数,请参考syslinux官网文档,或与我联系。
以上步骤即可成功部署Windows或者Linux、Esxi。
参考网址 https://www.cnblogs.com/boowii/p/6475921.html