由于手动给每个盒子安装系统太慢了,因此需要使用PXE进行安装。

准备

先按照这个教程安装环境。


由于原版镜像没有适配uefi,因此在这里使用的是自己的镜像。

pxe服务器IP是10.1.0.10

rm -rf /var/lib/tftpboot/*
rm -rf /var/www/html/*
umount /dev/sro

由于客户端使用centos7.4作为底层镜像,因此在这里我使用centos7.4作为底层镜像。
本系统为pxe安装使用的系统,非标准系统,因此没做U盘安装兼容。
准备好

CentOS-7-x86_64-Minimal-1708.iso
zetta-boxOS-6.6.1-210625.iso

将以CentOS-7-x86_64-Minimal-1708.iso为底层进行配置
安装之前请将zetta-boxOS-6.6.1-210625.iso制作成U盘给机器测试安装,只不过因为有些机器只支持uefi,以及硬盘的特殊性,这个镜像兼容性已经不太好了.不能按照也没事.

测试最小系统安装

准备httpd与tftp、dhcpd服务

我在最开始配置好了,这里就只重启一下。

systemctl restart httpd
systemctl restart dhcpd
systemctl restart xinetd

制作基础ks.cfg

打开zetta-boxOS-6.6.1-210625\isolinux内的ks.cfg文件,但不使用这个ks.cfg文件。
主要是参考执行格式化的方式,安装的软件包,执行的脚本。
打开kickstart程序,进行定制。
root密码:123

内容如下:

#platform=x86, AMD64, 或 Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
keyboard 'us'
# Root password
rootpw --iscrypted $1$jUb.OUmY$itJtCCRj4M/0dExNxaFt1.
# System language
lang en_US
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use text mode install
text
# Run the Setup Agent on first boot
firstboot --enable
# SELinux configuration
selinux --disabled


# Firewall configuration
firewall --disabled
# Network information
network  --bootproto=dhcp --device=eth0
# Reboot after installation
reboot
# System timezone
timezone Asia/Shanghai
# Use network installation
url --url="http://10.1.0.10/pub"
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part /boot/efi --fstype="xfs" --size=500
part /boot --fstype="xfs" --size=500
part / --fstype="xfs" --grow --size=1

将其保存在/root根目录下即可。

虽然网上都说要手动分配硬盘为gpt分区,但使用了clearpart --all --initlabel会自动将标签初始化为符合系统架构的默认值。因此不用手动设置gpt分区。

准备http文件

CentOS-7-x86_64-Minimal-1708.iso镜像挂载到系统上,将所有文件拷贝到http服务目录内。

mount /dev/sr0 /media
mkdir /var/www/html/pub/
cp -r /media/* /var/www/html/pub/

将上面准备的ks.cfg拷贝到http服务目录内

mkdir /var/www/html/ks/
cp /root/ks.cfg /var/www/html/ks/

准备grub文件

将EFI文件夹复制到tftp目录内,pxe启动会先访问BOOTX64.EFI,然后会访问同目录的grub.cfg文件,因此关键的这两个文件要在一个目录内。

cp -r /var/www/html/pub/EFI /var/lib/tftpboot/

准备内核与驱动文件

将isolinux与images复制到tftp目录内,里面存在linux内核文件.

cp -r /var/www/html/pub/isolinux /var/lib/tftpboot/
cp -r /var/www/html/pub/images /var/lib/tftpboot/

编辑dhcp配置

vim /etc/dhcp/dhcpd.conf

在前两行输入:

next-server 10.1.0.10;
filename "/EFI/BOOT/BOOTX64.EFI";

(虽然说要根据pxe-system-type来判断使用的EFI,但终端都是x64的,即使是华为的也都用相同的文件,我就不搞复杂了)

编辑grub.cfg文件

vim /var/lib/tftpboot/EFI/BOOT/grub.cfg

它的规则和isolinux.cfg差不多

1.删掉所有目录
2.修改default=1内的数字为0
3.修改timeout 60内的数字为1
4.新增目录

menuentry 'Install CentOS 7' --class fedora --class gnu-linux --class gnu --class os {
        linuxefi /images/pxeboot/vmlinuz ks=http://10.1.0.10/ks/ks.cfg
        initrdefi /images/pxeboot/initrd.img
}

测试最小系统是否可以安装

chmod 777 -R /var/lib/tftpboot/
chmod 777 -R /var/www/html/

systemctl restart httpd
systemctl restart dhcpd
systemctl restart xinetd

systemctl status httpd
systemctl status dhcpd
systemctl status xinetd

打开终端机器,测试最小安装是否成功.

安装终端

准备终端使用的cfg文件

由于公司的客户端需要自动执行,因此还需要自动化安装客户端.
还需要自定义一些规则.
最后ks.cfg文件在同文件内

准备zetta-boxOS-6.6.1-210625.iso文件

由于zetta-boxOS-6.6.1-210625.iso文件内zVisionClient文件夹自带权限,因此直接传递整个镜像。
使用wget按文件传输后传递镜像的时候,会出现:xfce4-session is installed incorrectly报错

Unable to load failsafe session
Unable to determine a failsafe session name. Possible causes:
xfconfd isn't running (D-Bus setup problem);
environment variable $XDG_CONFIG_DIRS is set incorrectly (must include "/etc"),
or xfce4-session is installed incorrectly

即使后面手动安装也会报错,使用log文件记录安装过程也没发现任何错误。

将zetta-boxOS-6.6.1-210625.iso镜像复制到/var/www/html/client/

mkdir /var/www/html/client/

用sftp上传文件。

测试是否可以安装

chmod 777 -R /var/lib/tftpboot/
chmod 777 -R /var/www/html/

systemctl restart httpd
systemctl restart dhcpd
systemctl restart xinetd

systemctl status httpd
systemctl status dhcpd
systemctl status xinetd

打开终端机器,测试是否成功.


参考:
RHEL/CentOS 8 Kickstart example | Kickstart Generator
centos7.6搭建UEFI PXE环境(x86和Taishan)
实战-使用 Cobbler 定制化安装指定系统
IEEE 802.21 Service Type (MoS DHCPv4 Address and FQDN Sub-Options)
Protocol Registries
What is the PXE Client System Architecture Type “BC EFI (7)” from RFC 4578?

最后修改:2021 年 07 月 04 日
如果觉得我的文章对你有用,请随意赞赏