目录
一、概述
(一)PXE是什么?
批量装机系统,网络安装linux操作系统。需要客户端的网卡支持pxe网络启动。
(二)PXE的组件:
vsftpd/httpd/nfs:负责提供系统的安装文件
tftp:负责提供系统安装前的引导文件与内核文件
dhcp:负责提供客户端的IP地址分配与pxe引导文件,及pxe服务器地址
二、配置
(一)配置vsftpd
关闭防火墙与selinux

vim /etc/selinux/config


安装vsftpd

启动vsftpd

(二)配置tftp
安装tftp-server
yum install -y tftp-server

启动tftp
vim /etc/xinit.d/tftp
disable=no

systemctl start tftp

(三)准备pxelinx.0文件、引导文件、内核文件
准备pxelinux.0文件
yum install -y syslinux

cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot

准备引导文件、内核文件
cd /光盘挂载路径/images/pxeboot/

cp initrd.img vmlinuz /var/lib/tftpboot

(四)配置dhcp
安装dhcp服务
yum install -y dhcp

配置dhcp配置文件
cd /etc/dhcp/
cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf

vim dhcpd.conf
找到subnet字段,分别把2行、4行、5行对应的行数subnet全部删除。保留一下subnet:
subnet 192.168.44.0 netmask 255.255.255.0 {
range 192.168.44.10 192.168.44.20;
option domain-name-servers ns1.internal.example.org;
option domain-name "internal.example.org";
option routers 192.168.44.128;
option broadcast-address 192.168.44.255;
default-lease-time 600;
max-lease-time 7200;
next-server 192.168.44.128;
filename "pxelinux.0";
}

启动dhcp服务
systemctl start dhcpd

(五)创建default文件
cd /var/lib/tftpboot
mkdir pxelinux.cfg
cd pxelinux.cfg

vim default
default auto 默认安装标签
prompt 1 等待用户确认,1表示等待,0表示不等待
label auto 定义标签
kernel vmlinuz 指定内核
append initrd=initrd.img method=ftp://192.168.44.128/centos7 指定引导镜像文件与系统安装文件


(六)在/var/ftp/创建centos7目录
拷贝系统文件到/var/ftp/centos7

启动 ysftp,并将磁盘挂在到 centos7
systemctl restart vsftpd
mount /dev/sr0 var/ftp/centos7

(七)配置pxe无人值守安装
配置ks文件
使用图形界面配置
yum install -y system-config-kickstart.noarch

system-config-kickstart
选择语言中文 时区上海 root密码



设置分区


添加网络

添加安装后的脚本

保存的/root下


从/root/anaconda-ks.cfg文件中拷贝软件安装字段到ks.cfg
%packages
@^graphical-server-environment
@base
@core
@desktop-debugging
@development
@dial-up
@fonts
@gnome-desktop
@guest-agents
@guest-desktop-agents
@hardware-monitoring
@input-methods
@internet-browser
@multimedia
@print-client
@x11
%end

cp /root/ks.cfg /var/ftp

修改default文件
vim /var/lib/tftpboot/pxelinux.cfg/default
default auto
prompt 0
label auto
kernel vmlinuz
append initrd=initrd.img method=ftp://192.168.44.128/centos7 ks=ftp://192.168.44.128/ks.cfg

三、开启客户端验证



