2.6. 从现有 rpm-ostree 安装切换到 RHEL 9.6 的镜像模式


您可以使用 bootc switch 命令,在现有 RHEL for Edge 系统上使用 RHEL 的镜像模式。

在不同的主机构建间切换时,您可以使用 bootc switch 命令将现有部署的系统迁移到基于 bootc 的系统。

重要

rhel-bootc 镜像 和 RHEL for Edge 之间的一些用户和组 ID 有所不同。这会影响多个组和用户,如 ssh_keys。因此,私钥属于错误配置的 ID 的组,您将无法使用公钥来访问边缘系统。

镜像模式统使用 altfiles 来管理 /user/lib/passwd 中的用户和 /user/lib/group 中的组。要临时解决这个问题,您必须提取现有 RHEL for Edge 系统的组和用户信息,并将它们作为 Containerfile 的一部分进行修复。配置 Containerfile,来将本地 lib/group 文件复制到容器镜像中。

您可以手动更改私钥的权限,/etc 文件夹在边缘系统中是可变的。但是,它没有解决问题,因为在运行 bootc switch 命令后,基于镜像模式的系统有使用 ID 999 配置的 ssh_keys 组。这个值来自 RHEL bootc 基础镜像,这个从 ID 101 到 ID 999 的漂移导致无法通过 SSH 访问边缘系统。要修复这个问题,请按照以下步骤操作:

先决条件

  • 一个现有的基于 RHEL for Edge rpm-ostree 的系统。
  • 您有一个订阅的 RHEL 9 系统。如需更多信息,请参阅 RHEL 系统注册入门文档
  • 您有一个容器注册中心。您可以在本地创建注册中心,或者在 Quay.io 服务上创建一个免费帐户。要创建 Quay.io 帐户,请参阅 Red Hat Quay.io 页面。
  • 您有一个具有生产或开发人员订阅的红帽帐户。Red Hat Enterprise Linux Overview 页面上提供了免费的开发人员订阅。
  • 您已认证到 registry.redhat.io 。如需更多信息,请参阅 红帽容器注册中心身份验证 文章。

流程

  1. 从 RHEL for Edge 系统中提取用户和组的信息。

    $ mkdir -p ./usr/lib
    $ ssh admin@192.168.100.50 'cat /lib/passwd' > ./usr/lib/passwd
    $ ssh admin@192.168.100.50 'cat /lib/group' > ./usr/lib/group
    Copy to Clipboard Toggle word wrap
  2. 通过在 Containerfile 中指定它们,在基于 bootc 的系统中包括缺少的 RHEL for Edge 软件包。另外,使用 COPY 命令包括从 RHEL for Edge 系统中提取的 grouppasswd 内容。以下是一个示例:

    FROM registry.redhat.io/rhel9/rhel-bootc
    WORKDIR /tmp
    RUN dnf -y install ModemManager \
                       NetworkManager-wifi \
                       NetworkManager-wwan \
                       audit \
                       checkpolicy \
                       clevis \
                       clevis-dracut \
                       clevis-luks \
                       clevis-pin-tpm2 \
                       clevis-systemd \
                       containernetworking-plugins \
                       dnsmasq \
                       dracut-config-generic \
                       fdo-client \
                       fdo-owner-cli \
                       firewalld \
                       firewalld-filesystem \
                       greenboot \
                       greenboot-default-health-checks \
                       grubby \
                       ignition \
                       ignition-edge \
                       ipset \
                       iwl100-firmware \
                       iwl1000-firmware \
                       iwl105-firmware \
                       iwl135-firmware \
                       iwl2000-firmware \
                       iwl2030-firmware \
                       iwl3160-firmware \
                       iwl5000-firmware \
                       iwl5150-firmware \
                       iwl6050-firmware \
                       iwl7260-firmware \
                       libsecret \
                       pinentry \
                       policycoreutils-python-utils \
                       python3-distro \
                       python3-setools \
                       rsync \
                       setools-console \
                       tmux \
                       traceroute \
                       usbguard \
                       usbguard-selinux \
                       wireless-regdb \
                       wpa_supplicant
    
    COPY etc /etc
    # You can find the passwd and group content that were extracted from the RHEL for Edge system usr/lib/ in your current working directory. You can copy the content into the container image with the following step:
    COPY usr /usr
    Copy to Clipboard Toggle word wrap
  3. 构建 bootc 镜像,并将其推送到注册中心:

    $ podman build -f Containerfile -t quay.io/<namespace>/<image>:<tag> .
    $ podman push quay.io/<namespace>/<image>:<tag>
    Copy to Clipboard Toggle word wrap
  4. 对新创建的可引导容器镜像运行 bootc switch 命令。

    $ ssh admin@192.168.100.50
    $ sudo bootc switch quay.io/<namespace>/<image>:<tag>
    $ sudo reboot
    Copy to Clipboard Toggle word wrap

验证

在将边缘系统重新引导到可引导容器镜像后,确认 /lib/passwd/lib/group 的内容是否与从 OSTree 系统提取的内容匹配。

  1. 检查 /lib/passwd 的内容。

    $ cat /lib/passwd
    Copy to Clipboard Toggle word wrap
  2. 检查 /lib/group 的内容。

    $ cat /lib/group
    Copy to Clipboard Toggle word wrap

使用您使用原始镜像安装的现有 9.6 RHEL for Edge 切换到 RHEL 的镜像模式。

先决条件

  • 一个现有的使用原始镜像安装的 9.6 RHEL for Edge。

流程

  1. 更新您的镜像。请参阅 更新 RHEL for Edge 镜像
  2. 将现有镜像从 RHEL 镜像构建器切换到镜像模式。

    1. 从 rhel-bootc 构建一个镜像。例如:

      $ cat Containerfile
      FROM registry.redhat.io/rhel9/rhel-bootc:latest
      RUN dnf install -y  \
          clevis  \
          clevis-dracut  \
          clevis-luks  \
          fdo-client  \
          fdo-owner-cli
      Copy to Clipboard Toggle word wrap
  3. 使用当前目录中的 Containerfile 构建 <image> 镜像:

    $ podman build -t quay.io/<namespace>/<image>:<tag> .
    Copy to Clipboard Toggle word wrap
    1. 将镜像推送到注册中心

      $ podman push quay.io/<namespace>/<image>:_<tag>_
      Copy to Clipboard Toggle word wrap
    2. 在设备上运行 bootc switch

      $ bootc switch quay.io/<namespace>/<image>:_<tag>_
      Copy to Clipboard Toggle word wrap
    3. 运行 systemctl reboot

      $ sudo systemctl reboot
      Copy to Clipboard Toggle word wrap

验证

  • 连接到 RHEL for Edge 系统,并使用 bootc status

    # bootc status
    Copy to Clipboard Toggle word wrap

使用您使用 simplified-installer 镜像安装的现有 9.6 RHEL for Edge。

先决条件

  • 使用 simplified-installer 镜像安装的现有 9.6 RHEL for Edge。

流程

  1. 检查是否已安装了 bootc

    $ rpm -qa | bootc
    Copy to Clipboard Toggle word wrap

    将您的镜像更新至最新的 rpm-ostree 安装。请参阅 更新 RHEL for Edge 镜像

    1. rhel-bootc 构建镜像。例如:

      $ cat Containerfile
      FROM registry.redhat.io/rhel9/rhel-bootc:latest
      RUN dnf install -y  \
          clevis  \
          clevis-dracut  \
          clevis-luks  \
          fdo-client  \
          fdo-owner-cli
      Copy to Clipboard Toggle word wrap
  2. 使用当前目录中的 Containerfile 构建 <image> 镜像:

    $ podman build -t quay.io/<namespace>/<image>:<tag> .
    Copy to Clipboard Toggle word wrap
    1. 将镜像推送到注册中心。

      $ podman push quay.io/<namespace>/<image>:_<tag>_
      Copy to Clipboard Toggle word wrap
    2. 运行 bootc switch,将设备切换到您推送到注册中心的镜像。

      $ bootc switch quay.io/<namespace>/<image>:_<tag>_
      Copy to Clipboard Toggle word wrap
    3. 运行 systemctl reboot。

      $ sudo systemctl reboot
      Copy to Clipboard Toggle word wrap
  3. 验证

    • 连接到 RHEL for Edge 系统,并使用 bootc status

      # bootc status
      Copy to Clipboard Toggle word wrap
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat