Automating Windows installation with sysprep

You can use Microsoft DVD images and sysprep to automate the installation, setup, and software provisioning of Windows virtual machines.

Using a Windows DVD to create a VM disk image

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.

Procedure

  1. In the OKD Virtualization web console, click StoragePersistentVolumeClaimsCreate PersistentVolumeClaim With Data upload form.

  2. Select the intended project.

  3. Set the Persistent Volume Claim Name.

  4. Upload the VM disk image from the Windows DVD. The image is now available as a boot source to create a new Windows VM.

Using a disk image to install Windows

After creating a disk image using a Windows DVD, you can then use that disk image to install Windows on your VM.

Procedure

  1. Use the OKD Virtualization web console VM wizard to create a new Windows VM, using the template available for your version of Windows.

  2. Select the DVD image as the boot source.

  3. Uncheck Clone available operating system source to this Virtual Machine.

  4. Clear the Start this virtual machine after creation checkbox.

  5. Click Customize virtual machineAdvanced.

  6. Under Sysprep, specify the autounattend.xml answer file settings by following Microsoft guidelines.

  7. 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 a Windows VM using sysprep

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.

Procedure

  1. Remove the sysprep disk.

    1. In the web console, select VirtualizationVirtual Machines, and select the relevant VM.

    2. Click Disks.

    3. Click the Options menu kebab for the sysprep disk, then click Delete.

    4. Click Detach in the Detach sysprep disk dialog.

  2. Rename C:\Windows\Panther\unattend.xml to avoid detection by the sysprep tool.

  3. Start the sysprep program by running the following command:

    1. %WINDIR%\System32\Sysprep\sysprep.exe /generalize /shutdown /oobe /mode:vm
  4. 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 Windows 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.

Procedure

  1. Use the OKD Virtualization web console VM wizard to create a new Windows VM.

  2. When selecting the Boot Source, choose Clone existing PVC, and clone the PVC from the initial VM root disk.

  3. Click Customize virtual machineAdvanced

  4. Under Sysprep, specify the unattend.xml answer file settings following Microsoft guidelines.

  5. Add filler information to the autounattend.xml answer file settings.

  6. 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.

Additional resources