10.9. 使用 sysprep 自动执行 Windows 安装

您可以使用 Microsoft DVD 镜像和 sysprep 自动安装、设置和软件置备 Windows 虚拟机。

10.9.1. 使用 Windows DVD 创建虚拟机磁盘镜像

Microsoft 不提供下载的磁盘镜像,但您可以使用 Windows DVD 创建磁盘镜像。然后,可以使用此磁盘镜像来创建虚拟机。

步骤

  1. 在 OpenShift Virtualization web 控制台中,点 StoragePersistentVolumeClaimsCreate PersistentVolumeClaim With Data upload form
  2. 选择预期的项目。
  3. 设置 持久性卷声明名称
  4. 从 Windows DVD 上传虚拟机磁盘镜像。该镜像现在可作为引导源来创建新的 Windows 虚拟机。

10.9.2. 使用磁盘镜像安装 Windows

您可以使用磁盘镜像在虚拟机上安装 Windows。

先决条件

  • 您必须使用 Windows DVD 创建磁盘镜像。
  • 您必须创建一个 autounattend.xml 回答文件。详情请查看 Microsoft 文档

步骤

  1. 在 OpenShift Container Platform 控制台中,从侧边菜单中点 VirtualizationCatalog
  2. 选择 Windows 模板并点 Customize VirtualMachine
  3. Disk source 列表中选择 Upload(Upload a new file to a PVC),并浏览 DVD 镜像。
  4. Review and create VirtualMachine
  5. 清除 Clone available operating system source to this Virtual Machine
  6. 清除 Start this VirtualMachine after creation
  7. Scripts 选项卡的 Sysprep 部分,点 Edit
  8. 浏览到 autounattend.xml 回答文件,然后点保存
  9. Create VirtualMachine
  10. YAML 标签页中,将 running:false 替换为 runStrategy: RerunOnFailure,点 Save

虚拟机将从包含 autounattend.xml 回答文件的 sysprep 磁盘开始。

10.9.3. 使用 sysprep 常规调整 Windows 虚拟机

常规化镜像允许该镜像在部署虚拟机上时删除所有特定于系统的配置数据。

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

步骤

  1. 在 OpenShift Container Platform 控制台中点 VirtualizationVirtualMachines
  2. 选择 Windows 虚拟机以打开 VirtualMachine 详情页。
  3. Disks 选项卡。
  4. sysprep 磁盘的 Options 菜单 kebab ,然后选择 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 虚拟机的安装镜像使用。

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

10.9.4. 专用 Windows 虚拟机

专用虚拟机(VM)将配置从常规化 Windows 镜像到虚拟机中的计算机特定信息。

先决条件

  • 您必须有一个通用的 Windows 磁盘镜像。
  • 您必须创建一个 unattend.xml 回答文件。详情请查看 Microsoft 文档

流程

  1. 在 OpenShift Container Platform 控制台中点 VirtualizationCatalog
  2. 选择 Windows 模板并点 Customize VirtualMachine
  3. Disk source 列表中选择 PVC(clone PVC)。
  4. 指定通用 Windows 镜像的持久性卷声明项目持久性卷声明名称
  5. Review and create VirtualMachine
  6. Scripts 选项卡。
  7. Sysprep 部分中,点 Edit,浏览到 unattend.xml 回答文件,然后点保存
  8. Create VirtualMachine

在初次启动过程中,Windows 使用 unattend.xml 回答文件来专注于虚拟机。虚拟机现在可供使用。

10.9.5. 其他资源