PXE for UEFI
PXE for UEFI
为使用 UEFI 的 AMD64 和 Intel 64 客户端配置 PXE 服务器
-
安装 tftp 软件包。请作为 root 运行以下命令完成此步骤:
~]# yum install tftp-server
-
在 /etc/xinet.d/tftp 配置文件中,将 disabled 参数从 yes 改为 no。
~]# vim /etc/xinetd.d/tftp
# default: off
# description: The tftp server serves files using the trivial file transfer \
# protocol. The tftp protocol is often used to boot diskless \
# workstations, download configuration files to network-aware printers, \
# and to start the installation process for some operating systems.
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /var/lib/tftpboot
disable = no
per_source = 11
cps = 100 2
flags = IPv4
}这个配置文件中还有其他控制 tftp 服务器行为的选项。可用选项请查看 xinetd.conf (5) 手册页。
-
在防火墙中允许 tftp 服务的进入连接:
~]# firewall-cmd --add-service=tftp
~]# firewall-cmd --add-service=tftp --permanent -
安装配置 DHCP 服务器
~]# yum install dhcp
~]# vim /etc/dhcp/dhcpd.conf
#
# DHCP Server Configuration file.
# see /usr/share/doc/dhcp*/dhcpd.conf.example
# see dhcpd.conf(5) man page
#
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 192.168.184.0 netmask 255.255.255.0 {
option routers 192.168.184.254;
range 192.168.184.2 192.168.184.253;
class "pxeclients" {
match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
next-server 192.168.184.129;
if option architecture-type = 00:07 {
filename "uefi/shim.efi";
} else {
filename "pxelinux/pxelinux.0";
}
}
} -
现在您需要 shim 软件包中的 shim.efi 文件,以及 ISO 映像文件中 grub2-efi 软件包的 grubx64.efi 文件。要访问该文件,请作为 root 运行以下命令:
~]# mount -t iso9660 /path_to_image/name_of_image.iso /mount_point -o loop,ro
~]# cp -pr /mount_point/Packages/shim-version-architecture.rpm /publicly_available_directory
~]# cp -pr /mount_point/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 -
在 tftpboot/ 目录中为 EFI 引导映像创建名为 uefi/ 的目录,并从您的 boot 目录复制它们:
~]# mkdir /var/lib/tftpboot/uefi
~]# cp publicly_available_directory/boot/efi/EFI/redhat/shim.efi /var/lib/tftpboot/uefi/
~]# cp publicly_available_directory/boot/efi/EFI/redhat/grubx64.efi /var/lib/tftpboot/uefi/ -
在 uefi/ 目录中添加名为 grub.cfg 的配置文件。
/var/lib/tftpboot/uefi/grub.cfg配置文件示例类似如下:set timeout=60
menuentry 'RHEL 7' {
linuxefi uefi/vmlinuz ip=dhcp inst.repo=http://192.168.184.129/mnt/archive/RHEL-7/7.1/Server/x86_64/os/
initrdefi uefi/initrd.img
} -
将引导映像复制到您的 uefi/ 目录下:
~]# cp /path/to/x86_64/os/images/pxeboot/{vmlinuz,initrd.img} /var/lib/tftpboot/uefi/
-
最后,如果没有运行 xinetd 和 dhcp 服务,则需要启动该服务;如果该服务已运行,则需重新载入 tftp、xinetd 和 dhcp。
如果这些服务之前没有运行,则需启动这些服务:
~]# systemctl start xinetd.service dhcpd.service
如果要永久启用这些服务以便每次系统重启后自动启动,则还需要执行以下命令:
~]# systemctl enable xinetd.service dhcpd.service
要重新载入已运行服务的配置,请使用
systemctl reload命令。
All articles on this blog are licensed under CC BY-NC-SA 4.0 unless otherwise stated.
