yum install -y httpd tftp-server dhcpd2.配置dhcp服务
3.配置tftp服务器subnet 192.168.247.0 netmask 255.255.255.0 { range 192.168.247.10 192.168.247.99; # 地址池 option subnet-mask 255.255.255.0; # 子网掩码 option routers 192.168.247.2; # 网关 option domain-name "example.con"; # 搜索域 option domain-name-servers 114.114.114.114; # DNS default-lease-time 3600; filename "pxelinux.0"; # pxe启动文件 next-server 192.168.247.5; # 本机ip }vim /etc/dhcp/dhcp.conf
4.拷贝PXE服务器的相关文件编辑 /etc/xinetd/tftp --------> disable = no
重启 systemctl restart tftp
# 引导文件 cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/ # 菜单文件 cp /usr/share/syslinux/menu.c32 /var/lib/tftpboot/
拷贝挂在光盘的系统文件 vmlinuz 和initrd.img 到/var/lib/tftpboot/
5 创建pxe启动的文件# 安装引导文件1 cp /mnt/isolinux/vmlinuz /var/lib/tftpboot/ # 安装引导文件2 cp /mnt/isolinux/initrd.img /var/lib/tftpboot/
mkdir /var/lib/tftpboot/pxelinux.cfg && touch default
6. 配置web服务vim default default menu.c32 timeout 300 prompt 0 label 1 menu label ^1) install centos7 menu default kernel vmlinuz append initrd=initrd.img method=http://192.168.247.5/Centos7 ks=http://192.168.247.5/ks.cfg制作安装的菜单文件
将光盘文件挂在到http服务
mount /dev/cdrom /var/www/html/Centos7
将文件拷贝root/anaconda-ks.cfg /var/www/html/ks.cfg 进行更改
chmod +r /var/www/html/ks.cfg vim /var/www/html/ks.cfg
#version=DEVEL # System authorization information auth --enableshadow --passalgo=sha512 # Use CDROM installation media # cdrom url --url http://192.168.247.5/Centos7 # Use graphical install #graphical text # Run the Setup Agent on first boot firstboot --enable ignoredisk --only-use=sda # Keyboard layouts keyboard --vckeymap=us --xlayouts='us' # System language lang en_US.UTF-8 # Network information network --bootproto=dhcp --device=eno16777728 --ipv6=auto --activate network --hostname=localhost.localdomain # Root password rootpw --iscrypted $6$ZueDaq6Rviw1ROWs$a7hxyqvtB48pFO5gLoqJxEAWWU4eCVhs77rt.2uJe1zk8pGTWDs2mSci3vkQLsGofWhoeJqkbzxnntEdD7xuV. # System services services --disabled="chronyd" # System timezone timezone Asia/Shanghai --isUtc --nontp # System bootloader configuration bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=sda autopart --type=lvm # Partition clearing information #clearpart --none --initlabel clearpart --all --initlabel %packages @^minimal @core kexec-tools %end %addon com_redhat_kdump --enable --reserve-mb='auto' %end reboot
配置vmware关闭网卡的dhcp
重启所有服务
systemctl restart httpd tftp-server dhcpd二、测试新建虚拟机
启动
可以进行安装



