%WINDIR%\System32\Sysprep\sysprep.exe /generalize /shutdown /oobe /mode:vm
You can use Microsoft DVD images and sysprep
to automate the installation, setup, and software provisioning of Windows virtual machines.
Microsoft does not provide disk images for download, but you can create a disk image using a Windows DVD. This disk image can then be used to create virtual machines.
In the OKD Virtualization web console, click Storage → PersistentVolumeClaims → Create PersistentVolumeClaim With Data upload form.
Select the intended project.
Set the Persistent Volume Claim Name.
Upload the VM disk image from the Windows DVD. The image is now available as a boot source to create a new Windows VM.
After creating a disk image using a Windows DVD, you can then use that disk image to install Windows on your VM.
Use the OKD Virtualization web console VM wizard to create a new Windows VM, using the template available for your version of Windows.
Select the DVD image as the boot source.
Uncheck Clone available operating system source to this Virtual Machine.
Clear the Start this virtual machine after creation checkbox.
Click Customize virtual machine → Advanced.
Under Sysprep, specify the autounattend.xml
answer file settings by following Microsoft guidelines.
In the YAML, replace running:false
with runStrategy: RerunOnFailure
, and save. The VM will start automatically. The sysprep
disk containing the autounattend.xml
answer file is now attached to the VM.
Generalizing an image allows that image to remove all system-specific configuration data when the image is deployed on a virtual machine.
Before generalizing the VM, you must ensure the sysprep
tool cannot detect an answer file after the unattended Windows installation.
Remove the sysprep
disk.
In the web console, select Virtualization → Virtual Machines, and select the relevant VM.
Click Disks.
Click the Options menu for the
sysprep
disk, then click Delete.
Click Detach in the Detach sysprep disk dialog.
Rename C:\Windows\Panther\unattend.xml
to avoid detection by the sysprep
tool.
Start the sysprep
program by running the following command:
%WINDIR%\System32\Sysprep\sysprep.exe /generalize /shutdown /oobe /mode:vm
After the sysprep
tool completes, the Windows VM shuts down. The disk image of the VM is now available to use as an installation image for Windows VMs.
You can now specialize the VM.
Specializing a virtual machine configures the computer-specific information from the image onto the VM.
You must generalize the root disk before specializing the virtual machine. |
Use the OKD Virtualization web console VM wizard to create a new Windows VM.
When selecting the Boot Source
, choose Clone existing PVC
, and clone the PVC from the initial VM root disk.
Click Customize virtual machine → Advanced
Under Sysprep, specify the unattend.xml
answer file settings following Microsoft guidelines.
Add filler information to the autounattend.xml
answer file settings.
Start the VM. On first boot, Windows will use the unattend.xml
answer file to specialize the VM. The VM is now ready to use.