第 3 章 在虚拟机中运行 bootc 镜像


使用可引导容器镜像作为安装源来设置 Red Hat Enterprise Linux (RHEL)虚拟机。

重要

RHEL 的镜像模式只是一个技术预览功能。技术预览功能不受红帽产品服务等级协议(SLA)支持,且功能可能并不完整。红帽不推荐在生产环境中使用它们。这些技术预览功能可以使用户提早试用新的功能,并有机会在开发阶段提供反馈意见。

有关红帽技术预览功能支持范围的更多信息,请参阅技术预览功能支持范围

3.1. 创建 Kickstart 文件

您必须创建要在安装过程中使用的 Kickstart 文件。

先决条件

  • 您有 root-user 访问权限。
  • 您已登录到物理 hypervisor 主机。

流程

  1. 运行以下命令,设置 AUTH_CONFIG 环境变量来引用 kickstart.ks 文件中的 secret 文件,以验证私有容器 registry 访问:

    $ AUTH_CONFIG=~/.quay-auth.json
    Copy to Clipboard Toggle word wrap
  2. 运行以下命令,设置 PULL_SECRET 环境变量来引用 kickstart.ks 文件中的 secret 文件,以验证 OpenShift Container Platform registry 访问:

    $ PULL_SECRET=~/.pull-secret.json
    Copy to Clipboard Toggle word wrap
  3. 运行以下命令,将 IMAGE_REF 环境变量设置为引用要在安装过程中使用的容器镜像的镜像模式:

    $ IMAGE_REF="quay.io/<myorg>/<mypath>/microshift-4.18-bootc" 
    1
    Copy to Clipboard Toggle word wrap
    1
    <myorg/<mypath > 替换为您的远程 registry 机构名称和路径。
  4. 通过运行以下脚本来创建在安装过程中使用的 kickstart.ks 文件:

    $ cat > kickstart.ks <<EOFKS
    lang en_US.UTF-8
    keyboard us
    timezone UTC
    text
    reboot
    
    # Partition the disk with hardware-specific boot and swap partitions, adding an
    # LVM volume that contains a 10GB+ system root. The remainder of the volume will
    # be used by the CSI driver for storing data.
    zerombr
    clearpart --all --initlabel
    # Create boot and swap partitions as required by the current hardware platform
    reqpart --add-boot
    # Add an LVM volume group and allocate a system root logical volume
    part pv.01 --grow
    volgroup rhel pv.01
    logvol / --vgname=rhel --fstype=xfs --size=10240 --name=root
    
    # Lock root user account
    rootpw --lock
    
    # Configure network to use DHCP and activate on boot
    network --bootproto=dhcp --device=link --activate --onboot=on
    
    %pre-install --log=/dev/console --erroronfail
    
    # Create a 'bootc' image registry authentication file
    mkdir -p /etc/ostree
    cat > /etc/ostree/auth.json <<'EOF'
    $(cat "${AUTH_CONFIG}")
    EOF
    
    %end
    
    # Pull a 'bootc' image from a remote registry
    ostreecontainer --url "${IMAGE_REF}"
    
    %post --log=/dev/console --erroronfail
    
    # Create an OpenShift pull secret file
    cat > /etc/crio/openshift-pull-secret <<'EOF'
    $(cat "${PULL_SECRET}")
    EOF
    chmod 600 /etc/crio/openshift-pull-secret
    
    %end
    EOFKS
    Copy to Clipboard Toggle word wrap
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

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

让开源更具包容性

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

關於紅帽

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

Theme

© 2025 Red Hat