pxe原理
環境準備
window軟件:VMware workstations
操作系統:圖形化centos7
靜態IP地址:10.10.1.10
網絡模式:僅主機模式
pxe服務器軟件:dhcp tftp-server vsftp system-config-kickstart
安裝dhcp並配置
[root@localhost ~]# yum -y install dhcp
[root@localhost ~]# cat /etc/dhcp/dhcpd.conf
allow booting;
allow bootp;
ddns-update-style interim;
ignore client-updates;
subnet 10.10.1.0 netmask 255.255.255.0 {
option subnet-mask 255.255.255.0;
option domain-name-servers 10.10.1.10;
range dynamic-bootp 10.10.1.100 10.10.1.200;
default-lease-time 21600;
max-lease-time 43200;
next-server 10.10.1.10;
filename "pxelinux.0";
}
安裝tftp並配置
[root@localhost ~]# yum install tftp-server
[root@localhost ~]# cat /etc/xinetd.d/tftp
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /var/lib/tftpboot
disable = no
per_source = 11
cps = 100 2
flags = IPv4
}
安裝syslinux並配置
[root@localhost ~]# yum install syslinux
[root@localhost ~]# cd /var/lib/tftpboot
[root@localhost tftpboot]# cp /usr/share/syslinux/pxelinux.0 ./
[root@localhost tftpboot]# cp /media/cdrom/images/pxeboot/{vmlinuz,initrd.img} ./
[root@localhost tftpboot]# cp /media/cdrom/isolinux/{vesamenu.c32,boot.msg} ./
[root@localhost tftpboot]# mkdir pxelinux.cfg
[root@localhost tftpboot]# cp /media/cdrom/isolinux/isolinux.cfg pxelinux.cfg/default ./
[root@localhost tftpboot]# cat pxelinux.cfg/default
default vesamenu.c32
timeout 100 # 設置進入默認選項的等待時間(單位ms)
…………省略…………
label linux
menu label ^Install CentOS Linux 7
menu default #設置Install CentOS Linux 7標籤爲默認選項(刪除其他標籤中設置的menu default)
kernel vmlinuz
# append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 quiet
append initrd=initrd.img inst.stage2=ftp://10.10.1.10 ks=ftp://10.10.1.10/pub/ks.cfg quiet #系統在ftp的根目錄下,應答文件在ftp的pub目錄下
…………省略…………
安裝vsftpd並配置
[root@localhost ~]# yum -y install vsftpd
[root@localhost ~]# mount -o loop iso鏡像名 掛載目錄
[root@localhost ~]# cp -r 掛載目錄 /var/ftp/
安裝kickstart並配置
[root@localhost ~]# yum -y install system-config-kickstart
[root@localhost ~]# cat /etc/yum.repos.d/develop.repo #repo文件名可以任意
[development] #倉庫名必須是development
name=development
baseurl=ftp://10.10.1.10
enable=1
gpgcheck=0
生成ks.cfg應答文件
方式一:
[root@localhost ~]# system-config-kickstart #執行kickstart,生成ks.cfg文件
將應答文件保存到/var/ftp/pub/下
方式二
複製用戶家目錄下的anaconda-ks.cfg文件,根據實際情況修改爲自己的ks.cfg
cp ~/anaconda-ks.cfg /var/ftp/pub/ks.cfg
啓動所有服務
systemctl start vsftpd tftp dhcpd #啓動tftp之後,檢查tftp和tftp.socket這兩個服務,只要tftp.socket服務在運行且69端口爲打開狀態就行
systemctl enable vsftpd tftp dhcpd