5.6 PXE高效批量网络系统安装
1.系统装机的三种引导方式
- u盘
- 光盘 硬盘
- 网络装机
linux安装光盘的安装相关文件
在系统光盘的isolinux目录下有和安装相关的文件 boot.cat: 相当于grub的第一阶段 isolinux.bin:光盘引导程序,在mkisofs的选项中需要明确给出文件路径 文个文件属于SYSLINUX项目 isolinux.cfg: 会自动去找isolinux.cfg文件 启动菜单的配置文件,当光盘启动后(即运行isolinux.bin\vesamenu.c32:是光盘启动后的启动菜单图形界面,也属于SYSLINUX项目 menu.c32提供纯文本的菜单yum install syslinux(引导) memtest:内存检测程序 splash.png:光盘启动菜单界面的背景图 ymlinuz:是内核映像 initrd.img:ramfs文件(精简版的linux系统,文件系统驱动等)
四大文件
内核 驱动 grub 配置文件 网络引导 grub程序 syslinux (软件集合 ) pxelinux.0
四大服务
initrd.img pxelinux.0 pxelinux.cfg vmlinuz
PXE安装步骤
1.需要4大配置
1.网卡需要查找相关的dhcp服务器(获取地址时间)
2.找到后dhcp服务器提供ip地址,和引导程序(boot loader)的地址 还提供给客户机TFTPserver地址(dhcp本身不提供tftp服务)
3.网卡使用tftp客户端吧引导程序加载到内存中来
4.bios执行引导程序
5.引导程序会去TFTP去查找配置文件
6.根据配置文件去引导安装系统
7.系统安装过程
2.PXE设置全流程:
[root@localhost ~]#yum install tftp-server vsftpd syslinux dhcp -y
配置文件模板位置:/usr/share/doc/dhcp*/dhcpd.conf.example
[root@localhost ~]# cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf #覆盖配置文件
y
[root@localhost ~]# vim /etc/dhcp/dhcpd.conf
subnet 192.168.21.0 netmask 255.255.255.0 {
range 192.168.21.10 192.168.21.100 ;
option routers 192.168.21.10;
next-server 192.168.21.10;
filename "pxelinux.0"
}
#next-server 192.168.21.100; #指定tftp的服务器地址
#filename "pxelinux.0" #指定启动文件
[root@localhost isolinux]# yum install tftp-server -y
[root@localhost isolinux]# rpm -ql tftp-server |grep tftp
主要文件:
#/etc/xinetd.d/tftp //配置文件 tftp
#/var/lib/tftpboot //站点
[root@localhost isolinux]# vim /etc/xinetd.d/tftp
#14行改成no,启动服务
rpm -ql syslinux |grep pxelinux.0
完成后找到该文件的地址
/usr/share/syslinux/gpxelinux.0
/usr/share/syslinux/pxelinux.0 #需要的文件地址
[root@localhost isolinux]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/ //拷贝到站点文件里
[root@localhost centos7]#rpm -ql vsftpd
/var/ftp
[root@localhost ~]# cd /var/ftp/
[root@localhost ftp]# mkdir centos7
[root@localhost centos7]# mount /dev/sr0 /var/ftp/centos7/
[root@localhost centos7]#cd /var/ftp/centos7/images/pxeboot
[root@localhost centos7]#ls
initrd.img TRANS.TBL vmlinuz
#将4大配置文件中的initrd.img vmlinuz 复制到/var/lib/tftpboot/中
[root@localhost pxeboot]# cp initrd.img vmlinuz /var/lib/tftpboot/
[root@localhost pxeboot]# cd /var/lib/tftpboot/
[root@test2 tftpboot]# mkdir pxelinux.cfg #写四大配置文件之一
[root@test2 tftpboot]# cd pxelinux.cfg/
[root@test2 pxelinux.cfg]# vim default
default linux
timeout 600
label linux
kernel vmlinuz
append initrd=initrd.img method=ftp://192.168.21.10/centos7 ks=ftp://192.168.21.10/ks.cfg
label linux text
kernel vmlinuz
append text initrd =initrd.img method=ftp://192.168.21.10/centos7
label linux rescue
kernel vmlinuz
append rescue initrd=initrd.img method=ftp://192.168.21.10/centos7
[root@localhost pxeboot]# systemctl stop firewalld.service
[root@localhost pxeboot]# setenforce 0
[root@localhost pxeboot]# systemctl start dhcpd tftp vsftpd
[root@localhost pxeboot]# systemctl status dhcpd tftp vsftpd
[root@localhost tftpboot]#yum install system-config-kickstart -y
#安装图形化工具
进入图形化界面点
系统工具/kickstart
基本配置/默认语言 中文 时区 上海 root密码 安装后重启 在文本模式中执行安装
安装方法/执行全新安装 FTP FTP服务器:ftp://192.168.21.10/ FTP目录:centos7
引导/安装新引导 在主引导
分区信息/ 清除 删除所有 初始化 /boot swap /
防火墙/禁用
显示设置/取消
保存/文件系统/var/ftp