实验:用一个PXE系统既支持centos6又能支持centos7系统安装,如何实现?
用一个干净的centos6系统来做,用两个光盘,分别挂载centos6和centos7的光盘。
echo “- – -” > /sys/class/scsi_host/host0/scan 识别光盘 lsblk查看
第一步:查看selinux及防火墙是否关闭
第二步:安装包
yum install dhcp httpd tftp-server syslinux
chkconfig dhcpd on 将dhcpd设为开启启动
chkconfig httpd on 将httpd设为开机启动
chkconfig tftp on 将tftp设为开机启动
service xinetd start 启动xinetd服务
service httpd start 启动httpd服务
第三步:修改dhcpd配置文件
cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf
vim /etc/dhcp/dhcpd.conf
option domain-name-servers 8.8.8.8;
default-lease-time 6000;
max-lease-time 72000;
subnet 192.168.30.0 netmask 255.255.255.0 {
range 192.168.30.50 192.168.30.100;
option routers 192.168.30.254;
next-server 192.168.30.42;
filename “pxelinux.0”;
}
service dhcpd start
第四步:准备YUM源
mkdir /var/www/html/centos/{6,7} -pv
vim /etc/fstab
/dev/sr1 /var/www/html/centos/6 iso9660 defaults 0 0
/dev/sr0 /var/www/html/centos/7 iso9660 defaults 0 0
mount -a
第五步:准备ks文件
mkdir /var/www/html/ksdir -pv
将事先准备好的centos6和centos7的应答文件复制到/var/www/html/ksdir下
第六步:准备PXE相关文件
cd /var/lib/tftpboot
mkdir pxelinux.cfg
mkdir centos{6,7}
cp /var/www/html/centos/6/isolinux/{vmlinuz,initrd.img} /var/lib/tftpboot/centos6
cp /var/www/html/centos/7/isolinux/{vmlinuz,initrd.img} /var/lib/tftpboot/centos7
cp /var/www/html/centos/6/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
复制centos6光盘中的菜单文件
cp /usr/share/syslinux/menu.c32 /var/lib/tftpboot/ 复制简洁的菜单栏背景
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot
vim /var/lib/tftpboot/pxelinux.cfg/default
default menu.c32
#prompt 1
timeout 600
label centos7
menu label ^Install desktop centos 7
kernel centos7/vmlinuz
append initrd=centos7/initrd.img ks=http://192.168.30.42/ksdir/ks7_desktop.cfg
label centos6
menu label Install mini centos 6
kernel centos6/vmlinuz
append initrd=centos6/initrd.img ks=http://192.168.30.42/ksdir/ks6_mini.cfg
label local
menu label Boot from ^local drive
menu default
localboot 0xffff
总结:在centos7上实现PXE安装cnetos6,7
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
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/
├── centos6
│ ├── initrd.img
│ └── vmlinuz
├── centos7
│ ├── initrd.img
│ └── vmlinuz
├── menu.c32
├── pxelinux.0
└── pxelinux.cfg
└── default
3 directories, 7 files
6 客户端测试安装
本文来自投稿,不代表Linux运维部落立场,如若转载,请注明出处:http://www.178linux.com/99639