Red Hat Training

A Red Hat training course is available for Red Hat Enterprise Linux

第 24 章 准备网络安装

使用安装服务器进行网络安装可让您安装 Red Hat Enterprise Linuxnbsp;Hat Enterprise Red Hat Enterprise Linuxnbsp; 在使用 网络引导服务器 的多个系统中的 Linux。这样,所有被配置为这样做的系统都将使用这个服务器提供的镜像引导,并自动启动安装程序。
注意
红帽卫星能够自动设置 PXE 服务器。如需更多信息,请参阅 Red Hat Satellite 文档
网络安装至少需要两个系统:
  • 服务器 - 运行 DHCP 服务器的系统、用于提供引导文件的 TFTP 服务器,以及托管安装镜像的 HTTP、FTP 或 NFS 服务器。从理论上讲,每个服务器都可以在不同物理系统上运行;本节中的步骤假设所有服务器都运行于一个系统来实现简单性。
  • 客户端 - 您要安装的系统 Red Hat Enterprise Linuxnbsp;Hat Enterprise Enterprise Linuxnbsp;Linux to.安装开始时,客户端将查询 DHCP 服务器,从 TFTP 服务器获取引导文件,并从 HTTP、FTP 或 NFS 服务器下载安装映像。
与大多数其他安装方式不同,不需要在客户端(即您要安装到的系统)中插入物理引导介质来开始安装。本章描述了准备网络安装必须执行的步骤。
要准备网络安装,必须执行以下步骤:
  1. 配置网络服务器(NFSHTTPSHTTP 或者 FTP)以导出安装树或安装 ISO 镜像。有关描述配置的步骤,请参阅 第 3.3.3 节 “网络中的安装源”
  2. tftp 服务器上配置网络 引导所需的文件,配置 DHCP,并在 PXE 服务器上启动 tftp 服务。详情请查看 第 24.1 节 “配置网络引导服务”
    重要
    GRUB2 引导装载程序除支持 tftp 服务器外还支持从 HTTP 进行网络引导。但是,通过此协议获取引导文件(安装程序的内核和初始 RAM 磁盘)非常慢,并存在超时失败的风险。建议使用 tftp 服务器来提供引导文件。
    这个警告只适用于内核和初始 RAM 磁盘(vmlinuzinitrd)。从 HTTP 服务器获取 安装源 不会带来这个风险。
  3. 引导客户端(您要安装 Red Hat Enterprise Linuxnbsp;Hat Enterprise Linuxnbsp;Linux on)并开始安装。
注意
本章的步骤论述了在 Red Hat Enterprise Linuxnbsp 中设置网络引导服务器;使用企业 Red Hat Enterprise Linuxnbsp;Linux 7 系统。有关在 Red Hat Enterprise Linuxnbsp 的早期版本中配置网络引导的详情,请参考该发行版本的适当 安装指南

24.1. 配置网络引导服务

设置包含要在安装中使用的软件包存储库的网络服务器后,下一步是配置 PXE 服务器本身。这个服务器将包含引导 Red Hat Enterprise Linuxnbsp;Hat Enterprise Linuxnbsp;Linux 和启动安装所需的文件。此外,必须配置 DHCP 服务器,并且必须启用并启动所有必要的服务。
注意
网络引导步骤根据您要安装 Red Hat Enterprise Linuxnbsp 的 AMD64/Intel 64 系统;Hat Enterprise Red Hat Enterprise Linuxnbsp;Hat Enterprise Red Hat Enterprise Linuxnbsp;Linux on use BIOS 或 UEFI 的不同而有所不同。查阅硬件文档,查看硬件上使用了哪些系统,然后按照本章中的相应步骤进行操作。
为从使用 GRUB2 引导装载程序的网络位置引导 IBM Power 系统提供了一个单独的步骤。详情请查看 第 24.1.3 节 “使用 GRUB2 为 IBM Power 系统配置网络引导”
有关配置网络引导服务器以进行无外设系统(没有直接连接的显示器、键盘和鼠标的系统)的更多信息,请参阅 第 26 章 无外设系统

24.1.1. 为基于 BIOS 的 AMD64 和 Intel 64 客户端配置 TFTP 服务器

以下流程将准备 PXE 服务器以引导基于 BIOS 的 AMD64 和 Intel 64 系统。有关基于 UEFI 的系统的详情请参考 第 24.1.2 节 “为基于 UEFI 的 AMD64/Intel 64 和 ARM 客户端配置 TFTP 服务器”

过程 24.1. 为基于 BIOS 的系统配置 TFTP 引导服务器

  1. 安装 tftp-server 软件包。要做到这一点,以 root 用户身份输入以下命令:
    # yum install tftp-server
  2. 允许到防火墙中的 tftp 服务的传入连接:
    # firewall-cmd --add-service=tftp
    注意
    以上命令仅启用访问,直到下次服务器重启为止。要永久允许访问,请添加 --permanent 选项。有关防火墙配置的更多信息,请参阅 Red Hat Enterprise Linux 7 安全指南
  3. 将您的 DHCP 服务器配置为使用与 SYSLINUX 打包的引导镜像。如果您没有安装 Red Hat Enterprise Linux 7 网络指南,请参阅 Red Hat Enterprise Linux 7 网络指南
    /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";
    	  }
    	}
    }
    
  4. 现在,您需要完整安装 DVD 的 ISO 镜像文件中 SYSLINUX 软件包中的 pxelinux.0 文件。要访问它,以 root 身份输入以下命令:
    # mount -t iso9660 /path_to_image/name_of_image.iso /mount_point -o loop,ro
    # cp -pr /mount_point/Packages/syslinux-version-architecture.rpm /publicly_available_directory
    # umount /mount_point
    解压软件包:
    # rpm2cpio syslinux-version-architecture.rpm | cpio -dimv
  5. tftpboot / 中创建 pxelinux / 目录,并将 pxelinux.0 文件复制到其中:
    # mkdir /var/lib/tftpboot/pxelinux
    # cp publicly_available_directory/usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/pxelinux
  6. pxelinux/ 目录中创建 pxelinux.cfg / 目录:
    # mkdir /var/lib/tftpboot/pxelinux/pxelinux.cfg
    将名为 default 的配置文件添加到 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/RHEL-7.1/vmlinuz
      append initrd=images/RHEL-7.1/initrd.img ip=dhcp inst.repo=http://10.32.5.1/mnt/archive/RHEL-7/7.x/Server/x86_64/os/
    label vesa
      menu label Install system with ^basic video driver
      kernel images/RHEL-7.1/vmlinuz
      append initrd=images/RHEL-7.1/initrd.img ip=dhcp inst.xdriver=vesa nomodeset inst.repo=http://10.32.5.1/mnt/archive/RHEL-7/7.x/Server/x86_64/os/
    label rescue
      menu label ^Rescue installed system
      kernel images/RHEL-7.1/vmlinuz
      append initrd=images/RHEL-7.1/initrd.img rescue
    label local
      menu label Boot from ^local drive
      localboot 0xffff
    重要
    上例中所示的 inst.repo= Anaconda 选项必须总是用来指定安装程序的镜像和安装源。如果没有这个选项,安装程序将无法引导。有关 Anaconda 引导选项的详情请参考 第 23.1 节 “在引导菜单配置安装系统”
  7. 创建一个子目录,将引导镜像文件复制到 /var/lib/tftpboot/ 目录中,并将引导镜像文件复制到其中。在这个示例中,我们使用目录 /var/lib/tftpboot/pxelinux/images/RHEL-release_number/:
    # mkdir -p /var/lib/tftpboot/pxelinux/images/RHEL-7.1/
    # cp /path_to_x86_64_images/pxeboot/{vmlinuz,initrd.img} /var/lib/tftpboot/pxelinux/images/RHEL-release_number/
  8. 最后,启动并启用服务:
    • dhcpd 服务:
      # systemctl start dhcpd
      # systemctl enable dhcpd
    • xinetd 服务,用于管理 tftpd 服务:
      # systemctl start xinetd
      # systemctl enable xinetd
完成此步骤后,PXE 引导服务器准备好为 PXE 客户端提供服务。现在,您可以启动要安装的系统 Red Hat Enterprise Linuxnbsp;Hat Enterprise Red Hat Enterprise Linuxnbsp;Linux on,在提示指定引导源时选择 PXE 引导并启动网络安装。如需更多信息,请参阅 第 7.1.2 节 “使用 PXE 从网络引导”

24.1.2. 为基于 UEFI 的 AMD64/Intel 64 和 ARM 客户端配置 TFTP 服务器

以下流程将准备 PXE 服务器以引导基于 UEFI 的 AMD64/Intel 64 和 ARM 系统。有关基于 BIOS 的系统的详情请参考 第 24.1.1 节 “为基于 BIOS 的 AMD64 和 Intel 64 客户端配置 TFTP 服务器”

过程 24.2. 为基于 UEFI 的系统配置 TFTP 引导

注意
Red Hat Enterprise Linux 7 UEFI PXE 引导支持基于 MAC 的 grub 菜单文件的小写文件格式。例如,grub2 的 MAC 地址文件格式为 grub.cfg-01-aa-bb-cc-dd-ee-ff
  1. 安装 tftp-server 软件包。要做到这一点,以 root 用户身份输入以下命令:
    # yum install tftp-server
  2. 允许到防火墙中的 tftp 服务的传入连接:
    # firewall-cmd --add-service=tftp
    注意
    以上命令仅启用访问,直到下次服务器重启为止。要永久允许访问,请添加 --permanent 选项。有关防火墙配置的更多信息,请参阅 Red Hat Enterprise Linux 7 安全指南
  3. 将您的 DHCP 服务器配置为使用 shim 打包的 EFI 引导镜像。如果您没有安装 Red Hat Enterprise Linux 7 网络指南,请参阅 Red Hat Enterprise Linux 7 网络指南
    /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";
    		}
      }
    }
    
  4. 现在,您需要 shim 软件包中的 the 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
  5. 从您的引导目录中复制 EFI 引导镜像:
    # cp publicly_available_directory/boot/efi/EFI/redhat/shim.efi /var/lib/tftpboot/
    # cp publicly_available_directory/boot/efi/EFI/redhat/grubx64.efi /var/lib/tftpboot/
  6. 将名为 grub.cfg 的配置文件添加到 tftpboot/ 目录中。/var/lib/tftpboot/grub.cfg 中的配置文件示例可能类似如下:
    set timeout=60
    menuentry 'RHEL 7' {
      linuxefi images/RHEL-7.1/vmlinuz ip=dhcp inst.repo=http://10.32.5.1/mnt/archive/RHEL-7/7.1/Server/x86_64/os/
      initrdefi images/RHEL-7.1/initrd.img
    }
    
    重要
    上例中所示的 inst.repo= Anaconda 选项必须总是用来指定安装程序的镜像和安装源。如果没有这个选项,安装程序将无法引导。有关 Anaconda 引导选项的详情请参考 第 23.1 节 “在引导菜单配置安装系统”
  7. 创建一个子目录,将引导镜像文件复制到 /var/lib/tftpboot/ 目录中,并将引导镜像文件复制到其中。在本例中,我们使用目录 /var/lib/tftpboot/images/RHEL-7.1/:
    # mkdir -p /var/lib/tftpboot/images/RHEL-7.1/# cp /path_to_x86_64_images/pxeboot/{vmlinuz,initrd.img} /var/lib/tftpboot/images/RHEL-7.1/
  8. 最后,启动并启用服务:
    • dhcpd 服务:
      # systemctl start dhcpd
      # systemctl enable dhcpd
    • xinetd 服务,用于管理 tftpd 服务:
      # systemctl start xinetd
      # systemctl enable xinetd
完成此步骤后,PXE 引导服务器准备好为 PXE 客户端提供服务。现在,您可以启动要安装的系统 Red Hat Enterprise Linuxnbsp;Hat Enterprise Red Hat Enterprise Linuxnbsp;Linux on,在提示指定引导源时选择 PXE 引导并启动网络安装。如需更多信息,请参阅 第 7.1.2 节 “使用 PXE 从网络引导”

24.1.3. 使用 GRUB2 为 IBM Power 系统配置网络引导

过程 24.3. 使用 GRUB2 为 IBM Power 系统配置网络引导服务器

  1. 安装 tftp-server 软件包。要做到这一点,以 root 用户身份输入以下命令:
    # yum install tftp-server
  2. 允许到防火墙中的 tftp 服务的传入连接:
    # firewall-cmd --add-service=tftp
    注意
    以上命令仅启用访问,直到下次服务器重启为止。要永久允许访问,请添加 --permanent 选项。有关防火墙配置的更多信息,请参阅 Red Hat Enterprise Linux 7 安全指南
  3. tftp root 中创建 GRUB2 网络引导目录:
    # grub2-mknetdir --net-directory=/var/lib/tftpboot
    Netboot directory for powerpc-ieee1275 created. Configure your DHCP server to point to /boot/grub2/powerpc-ieee1275/core.elf
    请注意命令的输出,其将告知您在 DHCP 配置中需要将哪个文件配置为 文件名。在这个过程中,这将变得更加重要。
  4. 创建 GRUB2 配置文件: /var/lib/tftpboot/boot/grub2/grub.cfg.Red Hat Enterprise Linux 7 系统管理员指南中 描述了 grub.cfg 语法。
    以下是一个配置文件示例:
    set default=0
    set timeout=5
    
    echo -e "\nWelcome to the Red Hat Enterprise Linux 7 installer!\n\n"
    
    menuentry 'Red Hat Enterprise Linux 7' {
      linux grub2-ppc64/vmlinuz ro ip=dhcp inst.repo=http://10.32.5.1/mnt/archive/RHEL-7/7.6-Beta/Server/ppc64/os/
      initrd grub2-ppc64/initrd.img
    }
    
    重要
    上例中所示的 inst.repo= Anaconda 选项必须总是用来指定安装程序的镜像和安装源。如果没有这个选项,安装程序将无法引导。有关 Anaconda 引导选项的详情请参考 第 23.1 节 “在引导菜单配置安装系统”
  5. 将您的 DHCP 服务器配置为使用与 GRUB2 打包的引导镜像。如果您没有安装 Red Hat Enterprise Linux 7 网络指南,请参阅 Red Hat Enterprise Linux 7 网络指南
    /etc/dhcp/dhcpd.conf 文件中的配置示例可能类似如下:
    subnet 192.168.0.1 netmask 255.255.255.0 {
      allow bootp;
      option routers 192.168.0.5;
      group { #BOOTP POWER clients
        filename "boot/grub2/powerpc-ieee1275/core.elf";
        host client1 {
        hardware ethernet 01:23:45:67:89:ab;
        fixed-address 192.168.0.112;
        }
      }
    }
    
    调整示例参数(子网子网掩码路由器固定地址硬件以太网),使其适合您的网络配置。另请注意 filename 参数;这是流程前面通过 grub2-mknetdir 命令的输出的文件名。
  6. 最后,启动并启用服务:
    • dhcpd 服务:
      # systemctl start dhcpd
      # systemctl enable dhcpd
    • 管理 tftp d 服务的 xinet d 服务:
      # systemctl start xinetd
      # systemctl enable xinetd
完成此步骤后,PXE 引导服务器准备好为 PXE 客户端提供服务。现在,您可以按照 第 12 章 在 IBM Power 系统中引导安装 中的步骤从这个服务器引导 Power Systems 客户端。
有关为 IBM Power Systems 客户端设置网络引导的更多信息,请参阅 POWER 的 Netbooting on POWER - 在 IBM DeveloperWorks 网站上的 Netbooting on POWER - 简介