Document navigation

Overview

A Windows template is a VM image where a Windows VM instance with installed necessary software such as drives and QGA removes and then regenerates its security identifier (SID, a unique identifier of a user, user group, or computer account). This template can be mainly used to create VM instances in bulk in a custom manner.

  • This tutorial uses Windows 10 Enterprise Evaluation 22H2 x64 as an example.
  • This tutorial applies to ZStack Cloud V5.5.38.

Environment Preparation

Prepare the following software and tools for template creation:

  • Cloud platform:ZStack Cloud V5.5.38
  • Windows image:Obtain the Windows image from the Microsoft website and follow the license terms. This tutorial uses Windows 10 Enterprise Evaluation 22H2 x64.
  • GuestTools:Use the GuestTools media provided by the cloud platform. This tutorial uses version 5.5.0.

Template Creation

To encapsulate a Windows template, follow these steps:
  1. Add an image.
  2. Install an operating system.
  3. Install GuestTools and other software.
  4. Prepare the operating system.
  5. Create a system template.

The following details the whole process of how to encapsulate a Windows 10 template.

Add an Image

Add a Windows 10 image to ZStack Cloud. This image is used to install the operating system.

On the main menu of ZStack Cloud, choose Resource Center > Resource Pool > Compute Configuration > Image. On the Image page, click Add Image. Then, the Add Image page is displayed. On the Add Image page, set the following parameters:
  • Name: Enter a name for the image.
  • Description: Optional. Enter a description for the image.
  • Image Type: Select an image type. Here, select System Image.
  • Image Format: Select an image format. Here, select iso.
  • CPU Architecture: Select x86_64.
  • Platform: Select an image platform. Here, select Windows.
  • OS: Select Windows 10.
  • VirtIO: Disable Virtio.
  • Image Storage: Select an image storage.
  • Image Path: Specify an image URL or upload a local file.
    Note:
    • The URL can be either in the HTTP/HTTPS/FTP/SFTP format or the file:/// format. Currently, the file:/// format supports only ImageStorage backup storages.
    • To upload a local file, make sure that this file can be accessed by your browser. ImageStore image storage are supported.
  • BIOS Mode: Select UEFI.
Figure 1. Installation Image Ready


Install an Operating System

Create a VM instance and install the operating system by using the Windows 10 image you added in the previous step.

Create a VM Instance

On the main menu of ZStack Cloud, choose Resource Center > Resource Pool > Virtual Resource > VM Instance. On the VM Instance page, click Create VM Instance. On the displayed, click on Standard Creation. Then, follow these steps to create a VM instance.
  1. Complete the basic configurations.
    Set the following parameters:
    • Name: Enter a name for the VM instance.
    • Description: Optional. Enter a description for the VM instance.
    • Quantity: Enter the number of VM instances to be created. You can create VM instances in bulk.
    • Tag: Optional. Bind one or more tags to the VM instance.
    • Group:Choose a group for the VM instance. If not selected, the VM instance will go to the default group.
    • Set the VM offering by using one of the following methods:
      • Basic Offering: Set the VM offering by selecting an existing instance offering and disk offering.
        • Instance Offering: Select an existing instance offering.
        • Image: Select an existing image.
        • BIOS Mode: Select an BIOS mode for the VM instance. By default, the VM BIOS mode is consistent with the image.
        • Data Volume: Optional. Choose whether to create a data volume and attach it to the VM instance. Here, you do not need to create a data volume.
      • Custom Offering: Set the VM offering by customizing the following VM configurations:
        • CPU: Set the number of CPU cores of the VM instance.
        • Memory: Set the memory size of the VM instance.
        • Image: Select an existing image.
        • BIOS Mode: Select an BIOS mode for the VM instance. By default, the VM BIOS mode is consistent with the image.
        • Data Volume: Optional. Choose whether to create a data volume and attach it to the VM instance. Here, you do not need to create a data volume.
  2. Complete the resource configurations.
    Set the following parameters:
    • Network Configurations: Select an L3 network used by the VM instance and complete the network configurations.
      • Network: Select an L3 network used by the VM instance. Supported network types: public network, flat network, and VPC network.
      • Make Default: If you add multiple network configurations, set one of the networks as the default network.
      • Enable SR-IOV: Optional. Choose whether to use SR-IOV to generate a VF NIC and pass it through to the VM instance.
      • Assign IP: Optional. Choose whether to assign an IP address to the VM NIC.
      • MAC Address: Optional. Choose whether to configure a MAC address for the VM instance.
      • Security Group: Optional. Associate a security group with the VM instance.
    • Cluster: Optional. Specify a cluster for the host on which the VM instance is to be started.
    • Storage Allocation Policy: Specify how the Cloud allocates a primary storage.
    • Host: Optional. Select the host on which the VM instance is to be started. If you specified a cluster, select a host from the cluster.
    • vDrive: Optional. Add a virtual drive (vDrive) for the VM instance.
    • GPU: Add a GPU device for the VM instance by specifying a GPU specification or device. The GPU device can be either a physical GPU (pGPU) or a virtual GPU (vGPU).
    • CPU Pinning: Specify the association between the pCPU of the host and the vCPU of the VM instance. Then, the Cloud allocates a pCPU to the VM instance accordingly. This helps to improve the VM performance.
  3. Complete the system configurations.
    Set the following parameters:
    • Hostname: Set a hostname for the VM instance.
    • User Data: Optional. Inject user-defined parameters or scripts to customize configurations for the VM instance or to accomplish specific tasks.
    • Console Password: Set a console password for the VM instance.
    • Console Mode: Set the console mode. Options: VNC, SPICE, and VNC+SPICE. Default: VNC.
  4. Confirm the information.

    View the information about the VM instance. You can edit the information by clicking the Edit icon.

On the Preview page, click OK. Then, the Windows 10 VM instance is created.

In this example, select 2 vCPUs, 4 GiB memory, an 80 GiB root volume, and UEFI. Disable VirtIO.

Figure 2. Source VM Instance Configuration

Source VM Instance Configuration

Install the Operating System

Click Launch Console on the VM instance details page. Select the language and keyboard settings and accept the license terms as applicable. Select Custom: Install Windows only (advanced), select the new root volume, and click Next.

Figure 3. Select Custom Installation

Select Custom Installation
Figure 4. Select the Installation Target Disk

Select the Installation Target Disk

The system restarts during installation. Reopen the console if disconnected. At OOBE, press Ctrl+Shift+F3 to restart into Audit Mode. When the Sysprep dialog appears, click Cancel and continue with GuestTools installation.

Install GuestTools and other Software

GuestTools is a performance optimization tool used by ZStack Cloud to improve the performance of Windows VM instances. The following table lists the tools and drivers contained in GuestTools.
Type Name Functionality
VirtIO driver SCSI controller Storage controllers of the VirtIO type can effectively improve the disk performance of a VM instance in a virtualization environment.
PCI simple communications controller After you install a PCI simple communications controller, a Windows VM instance can communicate with the underlying KVM virtualization.
PCI device After you install a PCI device and enable its internal monitoring, Windows will support the balloon memory scaling.
Ethernet adapter A VirtIO Ethernet adapter can effectively improve the network performance of a VM instance in a virtualization environment.
Commonly-used tools QEMU Guest Agent (QGA)

QGA is an application where mutual interactions between a host and a VM instance can be achieved. These interactions do not rely on networks, thereby greatly improving the VM performance and functionality.

QGA helps check the state of GuestTools and VirtIO drivers in a VM instance.

After QGA is installed, the VM instance enables you to change its password online.

Cloudbase-Init The VM instance that has Cloudbase-Init installed enables you to import User Data and achieve other custom functionalities.
Agent internal monitoring

After an agent is installed, you can check the internal monitoring data of a VM instance.

Install GuestTools

  1. After installing the operating system, use the GuestTools installation action on the VM instance details page to attach the GuestTools ISO.
  2. Open the GUESTTOOLS-5.5.0 CD drive in the VM instance console and run the installer. Follow the wizard to install drivers and the Visual C++ runtime. This version then installs QEMU Guest Agent and configures Cloudbase-Init 1.1.8 automatically.
  3. Keep Reboot the computer to finish installation! selected and click Finish to restart and apply the settings.
Figure 5. GuestTools Setup Complete

GuestTools Setup Complete

After restarting, confirm that GuestTools is Installed on the VM instance details page.

Figure 6. GuestTools Status on the Platform

GuestTools Status on the Platform

Install Other Software (Optional)

Install other software as needed. If Device Manager reports Code 28 for ACPI\QEMU0002, attach virtio-win-0.1.302.iso and update the device with the signed driver in qemufwcfg\w10\amd64.

Prepare the Operating System

Operating system preparation is designed for generalizing and removing system-specific information such as hardware of a computer via Windows-native System Preparation Tool (Sysprep). To prepare the operating system, follow these steps:

  1. Remove temporary files, test data, and personal information. Complete system updates and restart.
  2. Open Command Prompt as administrator and run the following commands. This example uses the Cloudbase-Init answer file. Adjust the path if installed elsewhere.
    cd /d "C:\Program Files\Cloudbase Solutions\Cloudbase-Init"
    %WINDIR%\System32\Sysprep\Sysprep.exe /generalize /oobe /shutdown ^
      /unattend:"%CD%\conf\Unattend.xml"
  3. Wait for Sysprep to complete and shut down the VM instance automatically. If it fails, resolve the error; a manual shutdown does not replace system preparation. Detach installation and tool ISOs, keep the VM instance stopped, and create the image.

Create a System Template

After you create the operating system template successfully, you can create VM instances in bulk in a custom manner by using this image. Also, you can export this image to create VM instances in other cloud platforms.

Create a VM Image

On the VM Instance page, select the target VM instance and choose Actions > Snapshot and Image > Create Image.

On the Create Image page, set the following parameters:
  • Name: Enter a name for the image.
  • Description: Optional. Enter a description for the image.
  • Image Type: Select system image.
  • Image Storage: Select an existing image storage.
Click OK. Wait for the creation task to complete and confirm that the image is available.
Figure 7. Create Image


Note: Keep the source VM instance stopped after system preparation to avoid triggering first-boot initialization again.

Export the Image

Exported images can be used directly by other cloud platforms to create VM instances. The export method varies based on the image storage type.
  • ImageStore image storage

    On the Image page, click Actions > Export Image. Then, an image is exported.

    After the image is generated, you can download the exported image by copying the image URL on the Overview tab page of the image details page. You can also copy the URL or download the image from Export Records.

  • Ceph image storage

    To export from the UI, choose Actions > Export Image on the Image page. Download the exported image from Overview or Export Records.

    To export from the image storage server: On the Overview tab page of the created image, copying Image Storage Path will prompt you for the corresponding information such as pool and image in the Ceph image storage. After you copy this image path, you can export the Ceph image by running rbd on the Ceph image storage. Assume that the storage path of the Ceph image storage is ceph://bak-t-c9923f982/61ece0adc72, run the following command:
    [root@ceph-node1 ~]#rbd export bak-t-c9923f982/61ece0adc72 /root/export-test.image
    #bak-t-c9923f982 is the image pool name
    #61ece0adc72 is the image name
    #/root/export-test.image is the target export file
Windows 10 System Template Tutorial (GuestTools) | 5.5.38 | ZStack Cloud · ZCF | ZStack Resource Center