-
安装所需服务
yum install dhcp xinetd syslinux tftp-server httpd
-
配置dhcp服务
vi /etc/dhcp/dhcpd.confsubnet 192.168.100.0 netmask 255.255.255.0 { range 192.168.100.201 192.168.100.240; #动态地址范围 option subnet-mask 255.255.255.0; #子网掩码 option routers 192.168.100.1; #网关地址192.168.100.1 # 指定引导服务器,即本机IP next-server 192.168.100.150; #本机ip192.168.100.150 # 引导文件 filename "pxelinux.0"; }
-
重启dhcpd服务
systemctl restart dhcpd systemctl enable dhcp
-
编辑tftp文件
vi /etc/xinetd.d/tftp
disable = no
-
重启服务
systemctl restart xinetd systemctl restart tftp systemctl enable xinetd systemctl enable tftp
-
挂载需要安装的镜像到http访问目录
mkdir /var/www/html/centos/7 mount -o loop /home/CentOS7.2.iso /var/www/html/centos/7/
-
拷贝ks.cfg文件到http访问目录
mkdir /var/www/html/centos/ks7/ cp /home/ks.cfg /var/www/html/centos/ks7/
-
复制引导内核文件initrd.img和vmlinuz到tftp目录
mkdir /var/lib/tftpboot/centos7 cp /var/www/html/centos/7/images/pxeboot/initrd.img /var/lib/tftpboot/centos7/ cp /var/www/html/centos/7/images/pxeboot/vmlinuz /var/lib/tftpboot/centos7/
-
设置syslinux加载器
cp /usr/share/syslinux/menu.c32 /var/lib/tftpboot cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot
-
创建pxelinux.cfg目录并创建default引导菜单文件:
mkdir /var/lib/tftpboot/pxelinux.cfg
vi /var/lib/tftpboot/pxelinux.cfg/default
default menu.c32 prompt 0 timeout 300 ONTIMEOUT local menu title ########## PXE Boot Menu ########## label 1 menu label ^1) Install CentOS 7 x64 ^Minimal kernel centos7/vmlinuz append initrd=centos7/initrd.img ks=http://192.168.100.150/centos/ks7/ks.cfg10
-
关闭防火墙
systemctl stop firewalld systemctl start tftp
-
yum install system-config-kickstart
ks.cfg
#platform=x86, AMD64, or Intel EM64T #version=DEVEL # Install OS instead of upgrade install #开头 # Keyboard layouts keyboard 'us' # 设置系统键盘类型为us # Root password root密码 rootpw --iscrypted $1$TBt8ea9M$HLbnZFucYSJyQRE2qK2bD/ # System language 语言 lang zh_CN # System authorization information auth --useshadow --passalgo=sha512 # 系统认证信息,这里要是写密文密码需加 设置密码加密方式为sha512 启用 # Use graphical install graphical firstboot --disable # SELinux configuration selinux --disabled # Firewall configuration firewall --disabled # Network information network --bootproto=dhcp --device=ens33 #network --bootproto=static --device=eth0 --gateway=10.0.0.254 --ip=10.0.0.202 --nameserver=223.5.5.5 --netmask=255.255.255.0 --activate #静态设置网卡 # Reboot after installation reboot # System timezone 时区 timezone Asia/Shanghai # Use network installation 镜像地址 url --url="http://192.168.2.171/centos/7/" # System bootloader configuration bootloader --location=mbr # Clear the Master Boot Record # 清除mbr引导信息 zerombr # Partition clearing information clearpart --all --initlabel #清空分区 # Disk partitioning information 分区 part /boot --fstype="xfs" --asprimary --size=1024 part / --fstype="xfs" --asprimary --size=20480 part swap --fstype="swap" --asprimary --size=1024 part /home --fstype="xfs" --asprimary --size=10240 #最小安装 %packages --nobase @core %end
##需启动的服务tftp、dhcpd、xined、httpd
##需关闭的firewalld、selinux