PXE for BIOS
PXE for BIOS
为使用 BIOS 的 AMD64 和 Intel 64 客户端配置 PXE 服务器
-
安装 tftp 软件包。请作为 root 运行以下命令完成此步骤:
[root@rhel-7 ~]# yum install tftp-server
-
在 /etc/xinet.d/tftp 配置文件中,将 disabled 参数从 yes 改为 no。
[root@rhel-7 ~]# 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 服务的进入连接:
[root@rhel-7 ~]# firewall-cmd --add-service=tftp
[root@rhel-7 ~]# firewall-cmd --add-service=tftp --permanent -
安装配置 DHCP 服务器
[root@rhel-7 ~]# yum install dhcp
[root@rhel-7 ~]# 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";
}
}
} -
现在需要完整安装 DVD 的 ISO 映像文件中 SYSLINUX 软件包中的 pxelinux.0 文件。要访问该文件,请作为 root 运行以下命令:
[root@rhel-7 ~]# mount -t iso9660 /path_to_image/name_of_image.iso /mount_point -o loop,ro
[root@rhel-7 ~]# cp -pr /mount_point/Packages/syslinux-version-architecture.rpm /publicly_available_directory
[root@rhel-7 ~]# umount /mount_point提取软件包:
[root@rhel-7 ~]# rpm2cpio syslinux-version-architecture.rpm | cpio -dimv
-
在 tftpboot 中创建 pxelinux 目录,并将 pxelinux.0 复制到该目录中:
[root@rhel-7 ~]# mkdir /var/lib/tftpboot/pxelinux
[root@rhel-7 ~]# cp publicly_available_directory/usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/pxelinux -
在 pxelinux/ 目录中创建目录 pxelinux.cfg/:
[root@rhel-7 ~]# mkdir /var/lib/tftpboot/pxelinux/pxelinux.cfg
在 pxelinux.cfg/ 目录中添加名为 default 的配置文件。
/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 vmlinuz
append initrd=initrd.img ip=dhcp inst.repo=http://192.168.184.129/mnt/archive/RHEL-7/7.x/Server/x86_64/os/
label vesa
menu label Install system with ^basic video driver
kernel vmlinuz
append initrd=initrd.img ip=dhcp inst.xdriver=vesa nomodeset inst.repo=http://192.168.184.129/mnt/archive/RHEL-7/7.x/Server/x86_64/os/
label rescue
menu label ^Rescue installed system
kernel vmlinuz
append initrd=initrd.img rescue
label local
menu label Boot from ^local drive
localboot 0xffff -
将引导映象复制到您的 tftp/root 目录中:
[root@rhel-7 ~]# cp /path/to/x86_64/os/images/pxeboot/{vmlinuz,initrd.img} /var/lib/tftpboot/pxelinux/
-
最后,如果没有运行 xinetd 和 dhcp 服务,则需要启动该服务;如果该服务已运行,则需重新载入 tftp、xinetd 和 dhcp。
如果这些服务之前没有运行,则需启动这些服务:
[root@rhel-7 ~]# systemctl start xinetd.service dhcpd.service
如果要永久启用这些服务以便每次系统重启后自动启动,则还需要执行以下命令:
[root@rhel-7 ~]# 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.
