使用 PXE 从网络准备安装
本部分介绍如何在 PXE 服务器上配置 TFTP 和 DHCP 以启用 PXE 引导和网络安装。
网络安装概述
网络安装允许您将 Circle Linux 安装到可以访问安装服务器的系统。网络安装至少需要两个系统:
PXE服务器: 运行 DHCP 服务、TFTP 服务和 HTTP、HTTPS、FTP 或 NFS 服务的系统。虽然每个服务可以在不同的物理系统上运行,但本部分中的步骤假定单个系统正在运行所有服务。
客户端: 您要安装 Circle Linux 的系统。安装开始后,客户端将查询 DHCP 服务器,从 TFTP 服务器接收引导文件,并从 HTTP、HTTPS、FTP 或 NFS 服务器下载安装映像。与其他安装方法不同,客户端不需要任何物理引导介质即可启动安装。
要从网络启动客户端,请在 BIOS/UEFI 或快速引导菜单中对其进行配置。在某些硬件上,从网络引导的选项可能被禁用或不可用。 |
使用 PXE 从网络准备安装 Circle Linux 的工作流程步骤如下:
-
将安装 ISO 映像(或安装树)导出到 NFS、HTTPS、HTTP 或 FTP 服务器。
-
配置 TFTP 服务和 DHCP 服务,并在 PXE 服务器上启动 TFTP 服务。
-
引导客户端,并启动安装。
GRUB2 引导加载程序除了支持 TFTP 服务器之外,还支持从 HTTP 进行网络引导。通过 TFTP 协议发送引导文件(内核和初始 RAM 磁盘 —— vmlinuz 和 initrd)可能会很慢,并且会导致超时失败。HTTP 服务器没有这种风险,但是建议您在发送启动文件时使用 TFTP 服务器。 |
为基于 BIOS 的客户端配置 TFTP 服务器
以下步骤介绍如何为基于 BIOS 的 AMD 和 Intel 64 位系统配置 TFTP 服务器和 DHCP 服务器,并在 PXE 服务器上启动 TFTP 服务。
步骤
-
以 root 身份安装
tftp-server
软件包:# yum install tftp-server
-
允许防火墙中
tftp service
服务的传入连接:# firewall-cmd --add-service=tftp
此命令在下次重新启动服务器之前启用临时访问。要启用永久访问,请将
--permanent
选项添加到命令中。 -
配置您的 DHCP 服务器以使用 SYSLINUX 打包的引导映像。
/etc/dhcp/dhcpd.conf
文件中的示例配置可能如下所示:option space pxelinux; option pxelinux.magic code 208 = string; option pxelinux.configfile code 209 = text; option pxelinux.pathprefix code 210 = text; option pxelinux.reboottime code 211 = unsigned integer 32; option architecture-type code 93 = unsigned integer 16; subnet 10.0.0.0 netmask 255.255.255.0 { option routers 10.0.0.254; range 10.0.0.2 10.0.0.253; class "pxeclients" { match if substring (option vendor-class-identifier, 0, 9) = "PXEClient"; next-server 10.0.0.1; if option architecture-type = 00:07 { filename "uefi/shim.efi"; } else { filename "pxelinux/pxelinux.0"; } } }
-
从 DVD1 ISO 映像文件中的
SYSLINUX
软件包访问pxelinux.0
文件:# mount -t iso9660 /path_to_image/name_of_image.iso /mount_point -o loop,ro
# cp -pr /mount_point/BaseOS/Packages/syslinux-tftpboot-version-architecture.rpm /publicly_available_directory
# umount /mount_point
-
解压缩包:
# rpm2cpio syslinux-tftpboot-version-architecture.rpm | cpio -dimv
-
在
tftpboot/
内创建一个pxelinux/
目录,并将需要的文件复制到其中,例如:pxelinux.0
libcom.c32
、ldlinux.c32
、vesamenu.c32
:# mkdir /var/lib/tftpboot/pxelinux
# cp publicly_available_directory/tftpboot/pxelinux.0 /var/lib/tftpboot/pxelinux
-
在
pxelinux/
目录中创建目录pxelinux.cfg/
:# mkdir /var/lib/tftpboot/pxelinux/pxelinux.cfg
-
将默认配置文件添加到
pxelinux.cfg/
目录。/var/lib/tftpboot/pxelinux/pxelinux.cfg/default
中的示例配置文件可能如下所示:default vesamenu.c32 prompt 1 timeout 600 display boot.msg label linux menu label ^Install system menu default kernel images/Circle Linux-8.4/vmlinuz append initrd=images/Circle Linux-8.4/initrd.img ip=dhcp inst.repo=http://10.32.5.1/Circle Linux-8.4/x86_64/iso-contents-root/ label vesa menu label Install system with ^basic video driver kernel images/Circle Linux-8.4/vmlinuz append initrd=images/Circle Linux-8.4/initrd.img ip=dhcp inst.xdriver=vesa nomodeset inst.repo=http://10.32.5.1/Circle Linux-8.4/x86_64/iso-contents-root/ label rescue menu label ^Rescue installed system kernel images/Circle Linux-8.4/vmlinuz append initrd=images/Circle Linux-8.4/initrd.img rescue label local menu label Boot from ^local drive localboot 0xffff
-
如果没有其运行时映像,安装程序将无法启动。使用
inst.stage2
引导选项指定映像的位置。或者,您可以使用inst.repo=
选项指定映像和安装源。 -
用于
inst.repo
的安装源位置必须包含有效的.treeinfo
文件。 -
选择 Circle Linux 8 安装 DVD 作为安装源时,
.treeinfo
文件指向 BaseOS 和 AppStream 仓库。您可以使用单个inst.repo
选项加载两个仓库。
-
-
创建子目录以将引导镜像文件存储在
/var/lib/tftpboot/
目录中,并将引导镜像文件复制到该目录。在本例中,使用目录/var/lib/tftpboot/pxelinux/images/Circle Linux-8.4/
:# mkdir -p /var/lib/tftpboot/pxelinux/images/Circle Linux-8.4/ # cp /path_to_x86_64_images/pxeboot/{vmlinuz,initrd.img} /var/lib/tftpboot/pxelinux/images/Circle Linux-8.4/
-
启动并启用
dhcpd
服务:# systemctl start dhcpd # systemctl enable dhcpd
-
启动并启用管理
tftp
服务的xinetd
服务:# systemctl start xinetd # systemctl enable xinetd
PXE 引导服务器现在已准备好为 PXE 客户机提供服务。您可以启动客户机(要安装 Circle Linux 的系统),在提示指定引导源时选择 PXE Boot,然后开始网络安装。
为基于 UEFI 的客户端配置 TFTP 服务器
以下步骤介绍如何为基于 UEFI 的 AMD64、Intel 64 和 64 位 ARM 系统配置 TFTP 服务器和 DHCP 服务器,并在 PXE 服务器上启动 TFTP 服务。
步骤
-
以 root 身份安装
tftp-server
软件包:# yum install tftp-server
-
允许防火墙中
tftp service
的传入连接:# firewall-cmd --add-service=tftp
此命令在下次重新启动服务器之前启用临时访问。要启用永久访问,请将
--permanent
选项添加到命令中。 -
将您的 DHCP 服务器配置为使用 shim 打包的引导映像。
/etc/dhcp/dhcpd.conf
文件中的示例配置可能如下所示:option space pxelinux; option pxelinux.magic code 208 = string; option pxelinux.configfile code 209 = text; option pxelinux.pathprefix code 210 = text; option pxelinux.reboottime code 211 = unsigned integer 32; option architecture-type code 93 = unsigned integer 16; subnet 10.0.0.0 netmask 255.255.255.0 { option routers 10.0.0.254; range 10.0.0.2 10.0.0.253; class "pxeclients" { match if substring (option vendor-class-identifier, 0, 9) = "PXEClient"; next-server 10.0.0.1; if option architecture-type = 00:07 { filename "shim.efi"; } else { filename "pxelinux/pxelinux.0"; } } }
-
从
shim
包访问shim.efi
文件,从 DVD1 ISO 映像文件中的grub2-efi
包访问grubx64.efi
文件:# mount -t iso9660 /path_to_image/name_of_image.iso /mount_point -o loop,ro
# cp -pr /mount_point/BaseOS/Packages/shim-version-architecture.rpm /publicly_available_directory
# cp -pr /mount_point/BaseOS/Packages/grub2-efi-version-architecture.rpm /publicly_available_directory
# umount /mount_point
-
解压软件包:
# rpm2cpio shim-version-architecture.rpm | cpio -dimv
# rpm2cpio grub2-efi-version-architecture.rpm | cpio -dimv
-
从您的引导目录复制 EFI 引导映像。
# cp publicly_available_directory/boot/efi/EFI/redhat/shimx64.efi /var/lib/tftpboot/uefi/
# cp publicly_available_directory/boot/efi/EFI/redhat/grubx64.efi /var/lib/tftpboot/uefi
复制
shimx64.efi
文件后,必须将其重命名为shim.efi
。 -
将名为
grub.cfg
的配置文件添加到tftpboot/
目录。位于`/var/lib/tftpboot/uefi/grub.cfg` 的示例配置文件可能如下所示:set timeout=60 menuentry 'Circle Linux 8' { linuxefi images/Circle Linux-8.4/vmlinuz ip=dhcp inst.repo=http://10.32.5.1/Circle Linux-8.4/x86_64/iso-contents-root/ initrdefi images/Circle Linux-8.4/initrd.img }
-
如果没有其运行时映像,安装程序将无法启动。使用
inst.stage2
引导选项指定映像的位置。或者,您可以使用inst.repo=
选项指定映像和安装源。 -
用于
inst.repo
的安装源位置必须包含有效的.treeinfo
文件。 -
选择 Circle Linux 8 安装 DVD 作为安装源时,
.treeinfo
文件指向 BaseOS 和 AppStream 仓库。您可以使用单个inst.repo
选项加载两个仓库。
-
-
创建子目录以将引导镜像文件存储在
/var/lib/tftpboot/
目录中,并将引导镜像文件复制到该目录。在本例中,使用目录/var/lib/tftpboot/images/Circle Linux-8.4/
:# mkdir -p /var/lib/tftpboot/images/Circle Linux-8.4/ # cp /path_to_x86_64_images/pxeboot/{vmlinuz,initrd.img} /var/lib/tftpboot/images/Circle Linux-8.4/
-
启动并启用
dhcpd
服务:# systemctl start dhcpd # systemctl enable dhcpd
-
启动并启用管理
tftp
服务的xinetd
服务:# systemctl start xinetd # systemctl enable xinetd
PXE 引导服务器现在已准备好为 PXE 客户机提供服务。您可以启动客户机(要安装 Circle Linux 的系统),在提示指定引导源时选择 PXE Boot,然后开始网络安装。
其他资源
-
有关shim的更多信息,请参阅上游文档: 使用shim程序。