×

要使用bootupd更新RHCOS节点上的引导加载程序,您必须手动在RHCOS机器上运行bootupctl update命令,或者提供带有systemd单元的机器配置。

grubby或其他引导加载程序工具不同,bootupd不管理内核空间配置,例如传递内核参数。要配置内核参数,请参阅向节点添加内核参数

您可以使用bootupd更新引导加载程序以防止BootHole漏洞。

手动更新引导加载程序

您可以使用bootupctl命令行工具手动检查系统状态并更新引导加载程序。

  1. 检查系统状态

    # bootupctl status
    x86_64的示例输出
    Component EFI
      Installed: grub2-efi-x64-1:2.04-31.el8_4.1.x86_64,shim-x64-15-8.el8_1.x86_64
      Update: At latest version
    aarch64的示例输出
    Component EFI
      Installed: grub2-efi-aa64-1:2.02-99.el8_4.1.aarch64,shim-aa64-15.4-2.el8_1.aarch64
      Update: At latest version
  1. 最初安装在4.4版及更早版本的OpenShift Container Platform集群需要显式的采用阶段。

    如果系统状态为Adoptable,请执行采用

    # bootupctl adopt-and-update
    示例输出
    Updated: grub2-efi-x64-1:2.04-31.el8_4.1.x86_64,shim-x64-15-8.el8_1.x86_64
  2. 如果有可用更新,请应用更新,以便更改在下一次重新启动时生效

    # bootupctl update
    示例输出
    Updated: grub2-efi-x64-1:2.04-31.el8_4.1.x86_64,shim-x64-15-8.el8_1.x86_64

通过机器配置自动更新引导加载程序

使用bootupd自动更新引导加载程序的另一种方法是创建一个systemd服务单元,该单元将在每次启动时根据需要更新引导加载程序。此单元将在引导过程中运行bootupctl update命令,并将通过机器配置安装在节点上。

此配置默认情况下未启用,因为更新操作的意外中断可能导致节点无法启动。如果启用此配置,请确保在引导加载程序更新进行期间避免中断节点的引导过程。引导加载程序更新操作通常很快完成,因此风险很低。

  1. 创建一个Butane配置文件99-worker-bootupctl-update.bu,其中包含bootupctl-update.service systemd单元的内容。

    有关Butane的信息,请参见“使用Butane创建机器配置”。

    示例输出
    variant: openshift
    version: 4.17.0
    metadata:
      name: 99-worker-chrony (1)
      labels:
        machineconfiguration.openshift.io/role: worker (1)
    systemd:
      units:
      - name: bootupctl-update.service
        enabled: true
        contents: |
          [Unit]
          Description=Bootupd automatic update
    
          [Service]
          ExecStart=/usr/bin/bootupctl update
          RemainAfterExit=yes
    
          [Install]
          WantedBy=multi-user.target
    1 在控制平面节点上,在这两个位置将worker替换为master
  2. 使用Butane生成一个MachineConfig对象文件99-worker-bootupctl-update.yaml,其中包含要交付给节点的配置

    $ butane 99-worker-bootupctl-update.bu -o 99-worker-bootupctl-update.yaml
  3. 通过以下两种方式之一应用配置

    • 如果集群尚未运行,在生成清单文件后,将MachineConfig对象文件添加到<installation_directory>/openshift目录,然后继续创建集群。

    • 如果集群已运行,请应用该文件

      $ oc apply -f ./99-worker-bootupctl-update.yaml