0 selinux ,firewall 关闭
1 安装包
yum install dhcp tftp-server httpd syslinux
systemctl enable dhcpd httpd tftp.socket
systemctl start httpd
2 准备YUM源
mkdir /var/www/html/centos/{6,7}/ -pv
vim /etc/fstab 加下面行
/dev/sr0 /var/www/html/centos/7 iso9660 defaults 0 0
/dev/sr1 /var/www/html/centos/6 iso9660 defaults 0 0
mount -a
df
3 准备ks文件
mkdir /var/www/html/ksdir/{6,7} -pv
cp /root/anaconda-ks.cfg /var/www/html/ksdir/7/ks7_desktop.cfg
chmod +r /var/www/html/ksdir/7/ks7_desktop.cfg
[root@centos7 tftpboot]#tree /var/www/html/ksdir/
/var/www/html/ksdir/
├── ks6_mini.cfg
└── ks7_desktop.cfg
4 配置dhcp服务
cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf
vim /etc/dhcp/dhcpd.conf
[root@centos7 tftpboot]#cat /etc/dhcp/dhcpd.conf
option domain-name "magedu.org";
option domain-name-servers 114.114.114.114,1.1.1.1;
option routers 192.168.30.200;
default-lease-time 86400;
max-lease-time 100000;
subnet 192.168.30.0 netmask 255.255.255.0 {
range 192.168.30.10 192.168.30.100;
option routers 192.168.30.254;
option domain-name-servers 8.8.8.8;
next-server 192.168.30.17;
filename "pxelinux.0";
}
systemctl start dhcpd
5 准备PXE相关文件
rpm -ql syslinux
mkdir /var/lib/tftpboot/pxelinux.cfg/
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
cp /usr/share/syslinux/menu.c32 /var/lib/tftpboot/
mkdir /var/lib/tftpboot/centos{6,7}
cp /var/www/html/centos/7/isolinux/{vmlinuz,initrd.img} /var/lib/tftpboot/centos7/
cp /var/www/html/centos/6/isolinux/{vmlinuz,initrd.img} /var/lib/tftpboot/centos6/
cp /var/www/html/centos/7/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
vim /var/lib/tftpboot/pxelinux.cfg/default
cat /var/lib/tftpboot/pxelinux.cfg/default
cat /var/lib/tftpboot/pxelinux.cfg/default
default menu.c32
timeout 600
menu title www.magedu.com
label centos7
menu label ^Install Desktop CentOS 7
kernel centos7/vmlinuz
append initrd=centos7/initrd.img ks=http://192.168.30.17/ksdir/ks7_desktop.cfg
label centos6
menu label install ^Mini CentOS 6
menu default
kernel centos6/vmlinuz
append initrd=centos6/initrd.img ks=http://192.168.30.17/ksdir/ks6_mini.cfg
label local
menu label Boot from ^local drive
localboot 0xffff
menu end
tree /var/lib/tftpboot/
/var/lib/tftpboot/
├── centos6
│?? ├── initrd.img
│?? └── vmlinuz
├── centos7
│?? ├── initrd.img
│?? └── vmlinuz
├── menu.c32
├── pxelinux.0
└── pxelinux.cfg
└── default
3 directories, 7 files
6 客户端测试安装
标签:www,lib,cfg,centos7,centos6,tftpboot,html,var,PXE From: https://www.cnblogs.com/xuxuxu-2022/p/17554802.html