本人环境:CentOS7.3(192.168.2.1)
保证当前网段可以通信(192.168.2.0)
[root@localhost pxeboot]# systemctl stop firewalld
[root@localhost pxeboot]# setenforce 0准备包(需要装机的ISO镜像):
虚拟机环境只需要mount挂在即可
[root@localhost ~]# mount /dev/sr0 /mnt/
mount: /dev/sr0 写保护,将以只读方式挂载实施环境需要将镜像拷贝到服务器中
mount -o loop /root/iso系统文件.iso /mnt配置阿里源或者配置本地yum源(二选一)
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo
yum clean all
yum makecache本地yum源
[root@localhost ~]# rm -f /etc/yum.repos.d/*
[root@localhost ~]# vi /etc/yum.repos.d/local.repo
[base]
name=local
baseurl=file:///mnt
enabled=1
gpgcheck=0准备软件仓库(PXE引导请求时会到这里下载)
[root@localhost ~]# mkdir -p /var/ftp/centos7
[root@localhost ~]# cp -rp /mnt/* /var/ftp/centos7/安装vsftpd服务(FTP服务提供系统请求)
[root@localhost ~]# yum -y install vsftpd
[root@localhost ~]# systemctl start vsftpd
[root@localhost ~]# systemctl enable vsftpd
Created symlink from /etc/systemd/system/multi-user.target.wants/vsftpd.service to /usr/lib/systemd/system/vsftpd.service.安装TFTP服务(提供内核和引导文件)
[root@localhost ~]# yum -y install tftp-server
[root@localhost ~]# systemctl start tftp
[root@localhost ~]# systemctl enable tftp
Created symlink from /etc/systemd/system/sockets.target.wants/tftp.socket to /usr/lib/systemd/system/tftp.socket.配置文件位于/etc/xinetd.d/tftp,将disable=yes改为no然后重启即可
[root@localhost ~]# vi /etc/xinetd.d/tftp disable = no #tftp默认为关闭wait = no #默认为yes表示一台一台连接,no为客户端可以多台连接(根据个人需求)[root@localhost ~]# systemctl restart tftp准备linux内核,初始化文件
也就是我们镜像文件中的image下
[root@localhost ~]# cd /mnt/images/pxeboot/
[root@localhost pxeboot]# ls
initrd.img TRANS.TBL vmlinuz
[root@localhost pxeboot]# cp vmlinuz initrd.img /var/lib/tftpboot/准备PXE引导程序,启动菜单文件
[root@localhost pxeboot]# yum -y install syslinux
[root@localhost pxeboot]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/编写启动菜单(此处不需要填写,创建即可,到kickstart的时候根据个人需要来添加内容)
[root@localhost ~]# mkdir /var/lib/tftpboot/pxelinux.cfg
[root@localhost ~]# vi /var/lib/tftpboot/pxelinux.cfg/default
default auto #默认模式
prompt 1 #是否需要登录 1等待用户选择 0执行默认模式
label auto #图像化安装kernel vmlinuzappend initrd=initrd.img method=ftp://192.168.2.1/centos7
label linux text #文本安装(最小化)kernel vmlinuzappend text initrd=initrd.img method=ftp://192.168.2.1/centos7
label linux rescue #安全模式kernel vmlinuzappend rescue initrd=initrd.img method=ftp://192.168.2.1/centos7安装DHCP
[root@localhost ~]# yum -y install dhcp
[root@localhost ~]# vim /etc/dhcp/dhcpd.conf
subnet 192.168.2.0 netmask 255.255.255.0 {option routers 192.168.2.1; #网关option subnet-mask 255.255.255.0;option domain-name "cjx.com";option domain-name-servers 8.8.8.8;default-lease-time 21600;max-lease-time 43200;range 192.168.2.10 192.168.2.100; #分配的网段next-server 192.168.2.1; #tftp服务器地址filename "pxelinux.0"; #指引引导文件
}
[root@localhost ~]# systemctl start dhcpd
[root@localhost ~]# systemctl enable dhcpd安装kickstart无人值守安装
[root@localhost tftpboot]# yum -y install system-config-kickstart
[root@localhost tftpboot]# system-config-kickstart根据个人需求来进行勾选

这里必要选择(勾选即可)

保存到/var/ftp/ks.cfg
[root@localhost ~]# ls /var/ftp/ks.cfg 根据个人需求添加
可以根据需要将/root/anaconda-ks.cfg 的软件包安装脚本复制到/var/ftp/ks.cfg文件中,只需要复制%packages 到%end 部分即可。如要求最小化安装,可复制下面内容:vim ks.cfg,加到末尾即可
%packages
@^minimal
%end配置无人监控安装(实施最小化安装)
root@localhost ~]# vi /var/lib/tftpboot/pxelinux.cfg/default
default linux test
prompt 0
label linux testkernel vmlinuzappend test initrd=initrd.img method=ftp://192.168.2.1/centos7 ks=ftp://192.168.2.1/ks.cfgPXE服务器端就配置完成了
客户端请求即可:
1.保证网段互通
2.服务器端防火墙和selinux都关闭
3.虚拟机安装需要内存大于2G(服务器应该都不会小于2G)
4.服务器端安装如果不自动跳转到网络安装,需要手动进入BOIS调节外网络安装