系统初始化
systemctl disable --now firewalld.service
setenforce 0
vim /etc/selinux/config
安装软件
yum install -y tftp-server xinetd dhcp vsftpd syslinux
复制 vmlinuz initrd.img pxelinux.0 到 /var/lib/tftpboot/ 目录
[root@localhost ~]# cd /mnt/
[root@localhost mnt]# ls
CentOS_BuildTag EULA images LiveOS repodata RPM-GPG-KEY-CentOS-Testing-7
EFI GPL isolinux Packages RPM-GPG-KEY-CentOS-7 TRANS.TBL
[root@localhost mnt]# cd images/
[root@localhost images]# ls
efiboot.img pxeboot TRANS.TBL
[root@localhost images]# cd pxeboot/
[root@localhost pxeboot]# ls
initrd.img TRANS.TBL vmlinuz
[root@localhost pxeboot]# cp vmlinuz initrd.img /var/lib/tftpboot/ #复制 vmlinuz initrd.img到/var/lib/tftpboot/ 目录
cp:是否覆盖"/var/lib/tftpboot/vmlinuz"? yes
cp:是否覆盖"/var/lib/tftpboot/initrd.img"? yes
[root@localhost pxeboot]# cd /usr/share/syslinux/
[root@localhost syslinux]# ls
altmbr.bin dosutil ifcpu64.c32 kbdmap.c32 pcitest.c32 syslinux.com
altmbr_c.bin elf.c32 ifcpu.c32 linux.c32 pmload.c32 syslinux.exe
altmbr_f.bin ethersel.c32 ifplop.c32 ls.c32 poweroff.com ver.com
cat.c32 gfxboot.c32 int18.com lua.c32 pwd.c32 vesainfo.c32
chain.c32 gptmbr.bin isohdpfx.bin mboot.c32 pxechain.com vesamenu.c32
cmd.c32 gptmbr_c.bin isohdpfx_c.bin mbr.bin pxelinux.0 vpdtest.c32
config.c32 gptmbr_f.bin isohdpfx_f.bin mbr_c.bin reboot.c32 whichsys.c32
cpuid.c32 gpxecmd.c32 isohdppx.bin mbr_f.bin rosh.c32 zzjson.c32
cpuidtest.c32 gpxelinux.0 isohdppx_c.bin memdisk sanboot.c32
diag gpxelinuxk.0 isohdppx_f.bin memdump.com sdi.c32
disk.c32 hdt.c32 isolinux.bin meminfo.c32 sysdump.c32
dmitest.c32 host.c32 isolinux-debug.bin menu.c32 syslinux64.exe
[root@localhost syslinux]# cp pxelinux.0 /var/lib/tftpboot/ #复制pxelinux.0 到 /var/lib/tftpboot/ 目录
[root@localhost syslinux]# ls /var/lib/tftpboot/
initrd.img pxelinux.0 vmlinuz
在 /var/lib/tftpboot/ 目录里准备 PXE 启动菜单配置文件 pxelinux.cfg/default
mkdir pxelinux.cfg
cd pxelinux.cfg/
vim default
default auto prompt 0
label auto kernel vmlinuz
append initrd=initrd.img method=ftp://192.168.80.100/centos7 ks=ftp://192.168.80.100/ks.cfglabel linux text
kernel vmlinuz
append text initrd=initrd.img method=ftp://192.168.80.100/centos7 ks=ftp://192.168.80.100/ks.cfglabel linux rescue
kernel vmlinuz
append rescue initrd=initrd.img method=ftp://192.168.80.100/centos7 ks=ftp://192.168.80.100/ks.cfg
cd /etc/xinetd.d/
vim tftp
4)修改服务配置文件,启动 tftp-server xinetd dhcpd vsftpd 服务启动tftp xinetd systemctl enable --now tftp xinetd
dhcp 用于自动分配地址、指定PXE引导文件位置 next-server filename
cd /usr/share/doc/dhcp-4.2.5/
\cp -f dhcpd.conf.example /etc/dhcp/dhcpd.conf
cd /etc/dhcp/
vim dhcpd.conf
systemctl enable --now dhcpd
systemctl enable --now vsftpd
5)安装 system-config-kickstart ,准备 kickstart 自动应答文件,修改 PXE 启动菜单配置文件
yum install -y system-config-kickstar
打开服务器图形界面进行 kickstart 设置
复制ks.cfg文件到/var/ftp/ cp ks.cfg /var/ftp/
创建centos7空目录,准备把安装源挂载到
[root@localhost ftp]# mkdir centos7
[root@localhost ftp]# mount /dev/sr0 centos7/
mount: /dev/sr0 写保护,将以只读方式挂载
[root@localhost ftp]# ls centos7
CentOS_BuildTag EULA images LiveOS repodata RPM-GPG-KEY-CentOS-Testing-7
EFI GPL isolinux Packages RPM-GPG-KEY-CentOS-7 TRANS.TBL
准备一台虚拟机centos7-5进行测试