7.2.4. 创建 Windows 虚拟机


您可以通过上传 Windows 镜像到持久性卷声明 (PVC) 来创建 Windows 虚拟机,然后使用 OpenShift Container Platform web 控制台创建虚拟机时克隆 PVC。

重要

您必须在 Windows 虚拟机上安装 VirtIO 驱动程序。仅从红帽官方来源下载 VirtIO 驱动程序。

先决条件

流程

  1. 将 Windows 镜像上传为新 PVC:

    1. 在 web 控制台中进入到 Storage PersistentVolumeClaims。
    2. 点 Create PersistentVolumeClaim With Data upload form。
    3. 浏览 Windows 镜像并选择它。
    4. 输入 PVC 名称,选择存储类和大小,然后点 Upload。

      Windows 镜像上传到 PVC。

  2. 通过克隆上传的 PVC 来配置新虚拟机:

    1. 进入到 Virtualization Catalog。
    2. 选择 Windows 模板标题并点 Customize VirtualMachine。
    3. 从 Disk source 列表中选择 Clone (clone PVC)。
    4. 选择 PVC 项目、Windows 镜像 PVC 和磁盘大小。
  3. 将回答文件应用到虚拟机:

    1. 点 Customize VirtualMachine 参数。
    2. 在 Scripts 选项卡的 Sysprep 部分,点 Edit。
    3. 浏览到 autounattend.xml 回答文件,然后点保存。
  4. 设置虚拟机的 run 策略:

    1. 清除 Start this VirtualMachine after creation,以便虚拟机不会立即启动。
    2. 点 Create VirtualMachine。
    3. 在 YAML 标签页中,将 running:false 替换为 runStrategy: RerunOnFailure,点 Save。
  5. 点 Options 菜单 kebab 并选择 Control Start。

    虚拟机从包含 autounattend.xml 回答文件的 sysprep 磁盘引导。

7.2.4.1. 常规化 Windows 虚拟机镜像

在使用镜像创建新虚拟机前,您可以常规化 Windows 操作系统镜像删除所有特定于系统的配置数据。

在常规调整虚拟机前,您必须确保 sysprep 工具在无人值守的 Windows 安装后无法检测到应答文件。

先决条件

  • 正在运行的 Windows 虚拟机安装有 QEMU 客户机代理。

流程

  1. 在 OpenShift Container Platform 控制台中点 Virtualization VirtualMachines。
  2. 选择 Windows 虚拟机以打开 VirtualMachine 详情页。
  3. 点 Configuration Disks。
  4. 点 sysprep 磁盘 旁边的 Options 菜单并选择 Detach。
  5. 单击 Detach。
  6. 重命名 C:\Windows\Panther\unattend.xml 以避免 sysprep 工具对其进行检测。
  7. 运行以下命令启动 sysprep 程序:

    %WINDIR%\System32\Sysprep\sysprep.exe /generalize /shutdown /oobe /mode:vm
  8. sysprep 工具完成后,Windows 虚拟机将关闭。VM 的磁盘镜像现在可作为 Windows 虚拟机的安装镜像使用。

结果

现在,您可以对虚拟机进行特殊化。

Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

關於紅帽

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

让开源更具包容性

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

关于红帽文档

Legal Notice

Theme

© 2026 Red Hat
返回顶部