拿centos7.5当做服务器,在其上搭建可以基于网络的自动化安装centos6和centos7
本实验基于21.3centos7 PXE自动安装操作系统,其网卡如图1;
图1
另外应答文件ks6.cfg和ks7.cfg基于21.1半自动化安装centos6,centos7中的实验1和实验2;也可以重新制作
0、确认目录
[root@centos7:/var/lib/tftpboot ]# ls
initrd.img menu.c32 pxelinux.0 pxelinux.cfg vmlinuz
[root@centos7:/var/lib/tftpboot ]# mkdir kernel{6,7}
[root@centos7:/var/lib/tftpboot ]# ls
initrd.img kernel6 kernel7 menu.c32 pxelinux.0 pxelinux.cfg vmlinuz
[root@centos7:/var/lib/tftpboot ]# ss -nul
UNCONN 0 0 :::69 :::*
users:(("in.tftpd",pid=3835,fd=0),("systemd",pid=1,fd=23))
1、挂载centos6.9的光盘和centos7.5的光盘到centos7虚拟机上
[root@centos7:/var/lib/tftpboot ]# echo '- - -' > /sys/class/scsi_host/host2/scan
[root@centos7:/var/lib/tftpboot ]# echo '- - -' > /sys/class/scsi_host/host0/scan
[root@centos7:/var/lib/tftpboot ]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 200G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 199G 0 part /
sr0 11:0 1 8.8G 0 rom /run/media/root/CentOS 7 x86_64
sr1 11:1 1 3.7G 0 rom /run/media/root/CentOS_6.9_Final
[root@centos7:/var/lib/tftpboot ]# mkdir /var/www/html/centos/6/os/x86_64 -pv
mkdir: created directory ‘/var/www/html/centos/6’
mkdir: created directory ‘/var/www/html/centos/6/os’
mkdir: created directory ‘/var/www/html/centos/6/os/x86_64’
[root@centos7:/var/lib/tftpboot ]# mount /dev/sr1 /var/www/html/centos/6/os/x86_64/
确认可以访问:浏览器中输入:192.168.31.7/centos/6/os/x86_64/ ;
192.168.31.7/centos/7/os/x86_64/ 都有可以显示各自光盘内容
[root@centos7:/var/lib/tftpboot ]# mv vmlinuz kernel7
[root@centos7:/var/lib/tftpboot ]# mv initrd.img kernel7
ks应答文件
[root@centos7:/var/www/html/ksdir ]# ls
ks7.cfg
[root@centos7:/var/www/html/ksdir ]# rz
[root@centos7:/var/www/html/ksdir ]# ls
ks6.cfg ks7.cfg
[root@centos7:/var/lib/tftpboot ]# cp /var/www/html/centos/6/os/x86_64/isolinux/{vmlinuz,initrd.img} kernel6/
4、查看一下目录
[root@centos7:/var/lib/tftpboot ]# tree
.
├── kernel6
│ ├── initrd.img
│ └── vmlinuz
├── kernel7
│ ├── initrd.img
│ └── vmlinuz
├── menu.c32
├── pxelinux.0
└── pxelinux.cfg
└── default
3 directories, 7 files
[root@centos7:/var/lib/tftpboot ]#
[root@centos7:/var/lib/tftpboot ]# vim pxelinux.cfg/default
default menu.c32
timeout 600
menu title zhaoliying
label auto7
menu label ^Auto Install CentOS 7
kernel kernel7/vmlinuz
append kernel7/initrd=initrd.img ks=http://192.168.31.7/ksdir/ks7.cfg
label auto6
menu label ^Auto Install CentOS 6
kernel kernel6/vmlinuz
append kernel6/initrd=initrd.img ks=http://192.168.31.7/ksdir/ks6.cfg
label menu7
menu label ^Manual install CentOS 7
kernel kernel7/vmlinuz
append kernel7/initrd=initrd.img inst.repo=http://192.168.31.7/centos/7/os/x86_64/
label menu6
menu label ^Manual install CentOS 6
kernel kernel6/vmlinuz
append kernel6/initrd=initrd.img inst.repo=http://192.168.31.7/centos/6/os/x86_64/
label local
menu label Boot from ^local drive
menu default
localboot 0xffff
5、确定一个httpd服务80端口开启,tftp服务69端口开启,dhcpd服务开启且正常监听
6、新建一个虚拟机,网络适配器更改为图1中的仅主机模式,