Create Windows 11 Template
The following tutorial details how to take a Windows 11 installer ISO and create a VM Squared Virtual Machine template. This example parallels the Windows 10 Template creation guide, with a few caveats to bypass a few of the setup checks that prevent installation of the ISO. The final template will be used within VM Squared to create KVM-based Windows Virtual Machines. This tutorial is outlined for the VM Squared GUI with the files either uploaded from a local machine or attached to the images via webserver URL.
ISO Images
Images can be saved in the designated Datastore for use in building Templates; this is doubly important for a Windows Template, due to the lack of virtualization and contextualization drivers needed for instantiating a KVM-realized Windows Environment.
The necessary ISOs can be downloaded from the following links:
- Windows 11 Installation ISO file. If you have a Windows Installation ISO that you want to use, replace that file in the steps laid out in the guide; otherwise, a Windows 11 ISO can be downloaded from:
- VirtIO Drivers for Windows. VirtIO is a virtualization standard for network and disk device drivers. There is an image of the VirtIO drivers needed for Windows in the Public Marketplace that can be imported to the datastore or you can download the stable ISO of the VirtIO drivers and additional software agents for Windows virtual machines running on KVM from:
https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/latest-virtio/virtio-win.iso
- Windows VM Contextualization. An add-on is needed to provide the contextualization package for the Windows guest VMs running in the cloud. With the provided context parameters, the packages prepare the networking for running guest VMs, setting passwords, running custom start scripts, etc. A copy can be found in the Public Marketplace, or downloaded from the link below:
https://github.com/OpenNebula/one-apps/releases/download/v6.8.1/one-context-6.8.1-1.iso
At this point, these files reside on a local machine and need to be uploaded to the VM Squared cluster for further use. This can be achieved via a straightforward upload to the datastore or, without downloading to a local machine, by directing the Image Creation Wizard to the designated URL for direct download and import into the Datastore.
Register and Create Images in the Datastore
If the files were directly downloaded from a URL, the wizard has registered and created them in the Datastore, and this step can be bypassed; however, if the files were first downloaded or stored on a local machine, then uploaded to the VM Squared storage, proceed with the steps below.
Under the Storage → Images Menu, select Create Image button and start the GUI Wizard. The first Image to create is the Windows Installation ISO which will be classified as a CD-ROM. The Image is given a Name, Description (Optional), Type, designate the Datastore, and identify where the media is found. Below, the disk image media was downloaded to a local machine and then uploaded to the VM Squared cluster via the Image creation GUI.
Reminder
A URL can also be provided in that field; such as, for the Contextualization drivers needed (per URLs provided), preventing the need to first download to the local machine.
The VirtIO and the Contextualization Drivers will be the same procedure; similarly, you will use the CD-ROM Image Type designation.
These Images will not be immediately available for use as the system is loading and registering them in the Datastore; this process takes a few moments, but the Status will revert from LOCKED to READY, as seen below as Green Dots.
Finally, create an empty disk used for the installation of the operating system; therefore, be sure to define enough space to install OS and generalized applications. This will need to be classed as an Operating System image, but select the contents to be empty and mark as Persistent. This persistence severs the link between the original Image and any clones, allowing any modifications made to the clone to persist after Termination of the virtual device, and will allow the creation of the Template.
A Persistent Disk can only be used by only one device at a time.
Create a VM Template for Installation
Now that the Images have been registered in the Datastore, a VM will be needed to facilitate the merger of all the images into a singular Template that can be used to instantiate future VMs with ease.
General
Navigate to the Templates → VM Templates menu and click the Create button in the top ribbon to bring up the Wizard. Here you will need to enter the Name, Memory, and CPU allocations. Provide enough resources to install and run the OS (e.g. 16 GB RAM and 4 vCPUs, or more). Proceed to the next tab, Storage, to select the disks that will become associated with this Template.
Memory and disk size require values in the units of MB.
Storage
On the Storage tab, add the Images as Disks to the Template.
- Disk 0: Windows 11 ISO
- Disk 1: VirtIO Drivers
- Disk 2: Contextualization Drivers
- Disk 3: Windows 11 (empty Datablock)
Caution
For the Datablock Disk attachment (Disk 3, per example), you will need to select Advanced options, located below the list of available Images, and select VirtIO in the BUS dropdown menu.
Network
In the Network tab, select the Virtual Network to be associated with the VM and enter virtio
as the Default hardware model for the NIC.
OS & CPU
If you are working with nested VMs, navigate to the CPU Model submenu under the OS & CPU tab, and select Host Passthrough
from the dropdown menu to assign the prior level Host Architecture and parameters. Also, if nested, the load-time in VNC will be slower.
After finalizing the template, make sure it is selected in the template list and click Update. Return to the OS & CPU tab to mark the Windows 10 ISO as the boot disk; as well as, the empty datablock. This has the installation media that will set up the OS and after the initial boot the datablock will be used as the Template and VM installation media.
You can also select these disks as part of the boot order when instantiating the VM from the template. The list of attached disks that can be selected will be under the tab OS Booting.
Input/Output
On the Input/Output tab, under the Graphics section, click on VNC tab and make sure the listening IP is 0.0.0.0.
Under the Inputs section, select Tablet (Type) and USB (Bus) from their respective dropdown menus, which will allow interaction within the VNC window. Click the Add button to confirm and load these selections.
The Template is now ready to be created by pressing the Finish button in the top right of the window. The Windows 10 VM Template is now available to be instantiated from the Templates → VMs menu.
Ensure that there are enough resources on the desired Host(s) before instantiating or the process of booting and installing will not progress.
Boot VM and Install Windows
From the VM Templates page, select the newly created Windows 11 Template and deploy the box. After a few moments, connect through VNC to the machine.
The VM and VNC will boot up and there will be several instances throughout the process that may take a while to progress.
Modify Registry
At the screen below, based on keyboard layout, press shift + fn + F10 (Or, shift + F10) to bring up the command prompt.
Once the command prompt has loaded, type in regedit
and press enter.
With the Registry Editor open:
- Navigate to
HKEY_LOCAL_MACHINE\SYSTEM\Setup
. - Right-click on the
Setup
folder to create a new registry key and name itLabConfig
. - Right-click on the new key and create two (2)
DWORD
s with the following names:BypassTPMCheck
BypassSecureBootCheck
- Double-click the new DWORDs and assign the value of 1 to each of them.
After editing the registry, you can close the two windows and resume the installation wizard.
Custom Install
Select Custom Installation, this will allow for the selection of the drivers attached via the created Images.
Load Drivers for Empty Disk
No discs will be available and you will need to load the drivers. Click the Load Driver button and select all VirtIO drivers (you may need to browse the directories to load the required drivers); these will need to be installed to access the Windows Datablock Disk. The setup will progress and install the OS, this will take some time. Afterwards, the Wizard will restart the machine and proceed to the next step in the installation.
The Datablock Image is now available as an Unallocated Space drive. Select this drive and click Next to continue the installation.
Install Context Drivers
After the installation completes and the desktop environment is loaded, navigate to the PC and open the drive with the contextualization driver installer on it and double click to install them.
Install VirtIO Drivers
A few VirtIO drivers will be installed as well, for the network card and PCI device, that controls the memory ballooning. This will be achieved via the Device Manager under the Control Panel, right click on the Ethernet Controller and click Update Driver, then navigate to the VirtIO drive and have the manager search for the drivers. Repeat this process for the PCI Device.
Once the drivers have been installed, the instance can be wiped of all PC-specific information from the Windows installation by Sysprep to allow a blank slate for newly instantiated VMs with the generalized template. The OS can be shut down and the VM Terminated (Hard). This installation was performed on the empty Datablock Image that was classified as Persistent; therefore, these modifications will remain even with the shutting down of the VM. Now, we can go into the Images Menu and alter the Image’s Persistence to Non Persistent.
Finalize Windows VM Template
The ISO (CD-ROM), VirtIO, and Contextualization Images can be removed as disks under the Storage Tab within the VM Template, leaving the new OS Image (formerly Disk 3, generic storage datablock) as the only disk available to the Template, and the success can be tested by instantiating a new VM with the updated Template.