7.2.4. 创建 Windows 虚拟机
您可以通过上传 Windows 镜像到持久性卷声明 (PVC) 来创建 Windows 虚拟机,然后使用 OpenShift Container Platform web 控制台创建虚拟机时克隆 PVC。
您必须在 Windows 虚拟机上安装 VirtIO 驱动程序。仅从红帽官方来源下载 VirtIO 驱动程序。
先决条件
- 已使用 Windows Media Creation Tool 创建 Windows 安装 DVD 或者 USB。请参阅 Microsoft 文档中的创建 Windows 10 安装介质。
-
您创建了
autounattend.xml回答文件。请参阅 Microsoft 文档中的回答文件(unattend.xml)。
流程
将 Windows 镜像上传为新 PVC:
-
在 web 控制台中进入到 Storage
PersistentVolumeClaims。 -
点 Create PersistentVolumeClaim
With Data upload form。 - 浏览 Windows 镜像并选择它。
输入 PVC 名称,选择存储类和大小,然后点 Upload。
Windows 镜像上传到 PVC。
-
在 web 控制台中进入到 Storage
通过克隆上传的 PVC 来配置新虚拟机:
-
进入到 Virtualization
Catalog。 - 选择 Windows 模板标题并点 Customize VirtualMachine。
- 从 Disk source 列表中选择 Clone (clone PVC)。
- 选择 PVC 项目、Windows 镜像 PVC 和磁盘大小。
-
进入到 Virtualization
将回答文件应用到虚拟机:
- 点 Customize VirtualMachine 参数。
- 在 Scripts 选项卡的 Sysprep 部分,点 Edit。
-
浏览到
autounattend.xml回答文件,然后点保存。
设置虚拟机的 run 策略:
- 清除 Start this VirtualMachine after creation,以便虚拟机不会立即启动。
- 点 Create VirtualMachine。
-
在 YAML 标签页中,将
running:false替换为runStrategy: RerunOnFailure,点 Save。
点 Options 菜单
并选择 Control Start。 虚拟机从包含
autounattend.xml回答文件的sysprep磁盘引导。
7.2.4.1. 常规化 Windows 虚拟机镜像 复制链接链接已复制到粘贴板!
在使用镜像创建新虚拟机前,您可以常规化 Windows 操作系统镜像删除所有特定于系统的配置数据。
在常规调整虚拟机前,您必须确保 sysprep 工具在无人值守的 Windows 安装后无法检测到应答文件。
先决条件
- 正在运行的 Windows 虚拟机安装有 QEMU 客户机代理。
流程
-
在 OpenShift Container Platform 控制台中点 Virtualization
VirtualMachines。 - 选择 Windows 虚拟机以打开 VirtualMachine 详情页。
-
点 Configuration
Disks。 -
点
sysprep磁盘 旁边的 Options 菜单并选择 Detach。 - 单击 Detach。
-
重命名
C:\Windows\Panther\unattend.xml以避免sysprep工具对其进行检测。 运行以下命令启动
sysprep程序:%WINDIR%\System32\Sysprep\sysprep.exe /generalize /shutdown /oobe /mode:vm-
sysprep工具完成后,Windows 虚拟机将关闭。VM 的磁盘镜像现在可作为 Windows 虚拟机的安装镜像使用。
结果
现在,您可以对虚拟机进行特殊化。