Linux系统一样,除了支持光盘引导安装外,还支持基于PXE的网络引导与安装。PXE只是网络安装的引导方式,自动化的核心依赖于kickstart/autoyast/autounattend等生成的自动应答文件
实验环境
centos6.9_x64
实验软件
dhcp-4.1.1-63.P1.el6.centos.x86_64
tftp-server-0.49-8.el6.x86_64
xinetd-2.3.14-40.el6.x86_64
httpd-2.2.15-69.el6.centos.x86_64
软件安装
yum install -y dhcp ntp httpd tftp-server xinetd syslinux system-config-kickstart
cp -pv /etc/sysconfig/network /etc/sysconfig/network.bak
echo GATEWAY=192.168.10.2 >> /etc/sysconfig/network 10.2为网关
ntpdate 192.168.10.14 && clock -w
cp -pv /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf
cat /etc/dhcp/dhcpd.conf
subnet 192.168.10.0 netmask 255.255.255.0 {
range 192.168.10.20 192.168.10.30;
max-lease-time 7200;
next-server 192.168.10.14;
filename "pxelinux.0";
}
server dhcpd configtest
sed -i.bak 's/yes/no/g' /etc/xinetd.d/tftp
sed -i.bak 's/#ServerName/ServerName/g' /etc/httpd/conf/httpd.conf
mkdir -pv /var/www/html/centos6
mount -o loop /root/CentOS-6.9-x86_64-bin-DVD1.iso /var/www/html/centos6/
cp -pv /root/ks.cfg /var/www/html/ks6.cfg
chmod 777 /var/www/html/ks6.cfg 安装centos7相同操作
mkdir -pv /var/lib/tftpboot/pxelinux.cfg
cp -pv /var/www/html/centos6/isolinux/{initrd.img,TRANS.TBL,vmlinuz} /var/lib/tftpboot/
cp -pv /var/www/html/centos6/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default 安装centos7相同操作
cp -pv /usr/share/syslinux/{pxelinux.0,vesamenu.c32} /var/lib/tftpboot/
kickstart文件生成方式有了两种
1.复制模板/root/anaconda-ks.cfg
2.使用system-config-kiskstart来生成,建议使用/root/anaconda-ks.cfg 模板生成,system-config-kiskstart需要桌面环境
cp -pv /var/lib/tftpboot/pxelinux.cfg/default /var/lib/tftpboot/pxelinux.cfg/default.bak
cat /var/lib/tftpboot/pxelinux.cfg/default
label linux
menu label ^Install or upgrade an existing system
menu default
kernel vmlinuz
append initrd=initrd.img ks=http://192.168.10.14/ks6.cfg
service dhcpd configtest && service dhcpd restart && chkconfig --level 35 dhcpd on
service httpd restart && chkconfig --level 35 httpd on
service xinetd restart && chkconfig --level 35 xinetd on
service ntpd restart && chkconfig --level 35 ntpd on
netstat -tuplna | grep dhcp
udp 0 0 0.0.0.0:67 0.0.0.0:* 5885/dhcpd
netstat -tuplna | grep 69
udp 0 0 0.0.0.0:69 0.0.0.0:* 59953/xinetd
netstat -tuplna | grep 80
tcp 0 0 192.168.10.14:43444 39.155.141.16:80 ESTABLISHED 4031/python
tcp 0 0 :::80 :::* LISTEN 4122/httpd
udp 0 0 fe80::20c:29ff:fe45:1769:123 :::* 1290/ntpd