Configure a VM

You can adjust a VM's compute, storage, and network resources, add or modify devices, and configure boot options, encryption, and time synchronization to meet workload requirements.

When creating a VM, you can also pass custom parameters or scripts through User Data to customize operating system initialization.

Configure CPU and Memory

Adjust the CPU, memory, and resource usage settings of an existing VM to meet workload requirements. Increase the core count or memory to resize the VM. The CPU mode determines which CPU features the VM can use. Resource priorities control allocation preferences during resource contention, and the CPU clock speed limit caps CPU usage.

Resize CPU and Memory

Before you begin, make sure that the host has sufficient allocatable resources and check the VM CPU and memory hot plug settings. If hot plug is disabled, shut down a running VM before changing its core count or memory capacity. Even when hot plug is enabled, verify that the guest operating system supports the intended change.

  1. In the navigation pane, select Inventory > VM and Host, select the target VM, and click Modify Configuration.
  2. In the Hardware section, select CPU and adjust Cores. To change the socket layout, shut down the VM and adjust Cores per Socket. The total core count must be divisible by the number of cores per socket.
    Note:
    Changing the CPU core count cancels existing CPU NUMA binding. If binding is still required, configure it again after resizing the VM.
  3. Select Memory, enter the target memory capacity, and check the unit.
  4. Review the changes and click OK. If a restart confirmation appears, review the settings that require a restart before proceeding.
  5. If the VM is stopped, power it on. Check the specifications displayed on the platform and verify that the guest operating system recognizes the CPU and memory changes.

Configure CPU and Memory Hot Plug

CPU and memory hot plug support resizing while the VM is running. These settings have constraints related to CPU NUMA binding, and hot plug is not supported by all operating systems.

  1. Shut down the VM and open Modify Configuration.
  2. Under CPU, configure CPU Hot Plug. Memory hot plug is enabled or disabled together with CPU hot plug and cannot be toggled separately.
  3. If CPU NUMA binding is configured, cancel the binding before enabling hot plug. Check the guest operating system against the list of supported systems provided in the interface.
  4. Save the configuration and power on the VM before resizing it.

VM CPU Modes

ZSphere supports the following CPU modes:

  • None: The VM CPU model is simulated by QEMU and inherits a limited set of CPU features from the host. This mode is recommended for migration scenarios.
  • Compatible: The VM CPU model is close to or consistent with the host CPU model. For example, both can be displayed as Haswell Intel CPU. Compared with None mode, this mode allows the VM to inherit more CPU features from the host and can be used for migration scenarios. This setting is not supported for aarch architecture clusters or VMs.
  • Passthrough: The VM CPU model is consistent with the host CPU model. VM CPU features are also consistent with host CPU features, such as extended page tables, huge pages, and virtualization. Compared with None, Compatible, and Custom modes, this mode inherits the most host CPU features and is suitable for workloads with high VM feature requirements.
  • Custom (a specific CPU model): The VM is configured with the specified custom CPU model. After a custom CPU model is configured, the VM might have CPU features that differ from the previous custom model.

Configure VM CPU Mode

ZSphere provides CPU mode settings at the VM level and cluster level. VM-level settings take precedence over cluster-level settings. The following procedure uses VM-level settings as an example:

  1. On the target VM page, click Shut Down to shut down the VM.
  2. Click Modify Configuration and select Hardware > CPU > CPU Mode, and then select the required CPU mode.
  3. Click OK to complete CPU mode configuration. You can click Power On to power on the VM again.

Set Resource Priorities and the CPU Usage Limit

When host load is high and multiple VMs compete for resources, you can assign higher CPU or memory resource priority to critical VMs. Priorities do not increase the physical resources of the host or replace capacity planning.

  1. Open Modify Configuration for the target VM.
  2. Set CPU Resource Priority under CPU and Memory Resource Priority under Memory as needed. Select High only for workloads that require preferential resource allocation.
  3. To cap CPU usage, set CPU Clock Speed Limit under CPU. The valid range is 1% to 100%. A value of 100% or a blank value means no limit.
  4. Click OK. Evaluate the changes based on VM load and workload behavior, and adjust the settings as needed.

Configure CPU Binding and NUMA

Use CPU NUMA binding to specify which host pCPUs the VM vCPUs can use. Use EmulatorPin to specify which pCPUs can run the related threads other than vCPU and I/O threads. Configure these bindings separately. They do not increase the CPU core count or raise resource priority.

Bind vCPUs to pCPUs

CPU NUMA binding: CPU pinning assigns the virtual CPUs (vCPUs) of a virtual machine to specific physical CPUs (pCPUs) of the host, which improves VM performance.

Consider CPU binding in the following scenarios to improve VM performance:
  • CPU-intensive small-application scenario:

    CPU-intensive applications require substantial CPU resources. If many CPU-intensive small applications run on VMs, CPU resource contention might occur. CPU binding allows applications to run on specific physical CPUs, controlling the physical CPUs available to each application.

  • Uneven multi-core CPU load scenario:

    If multiple applications are concentrated on one or a few CPUs, use CPU binding to manually adjust CPU load distribution.

Before configuring binding, make sure that a runtime host is specified for the VM and check the host NUMA topology. CPU NUMA binding has constraints related to CPU and memory hot plug. Cancel the binding before enabling hot plug.

To configure CPU binding:
  1. On the target VM page, click Shut Down to shut down the VM.
  2. Click Modify Configuration and select Hardware > CPU > CPU NUMA Binding, and then select Intelligent Binding or Manual Binding as needed:
    • Intelligent Binding: Binds VM vCPUs to pCPUs in pNUMA nodes one to one in descending order of pNUMA node ID. After all pCPUs in a pNUMA node are bound to VM vCPUs, pCPUs in the next pNUMA node are bound in sequence. If all pCPUs are bound but some vCPUs are still unbound, the system loops back to the first bound pNUMA node and continues one-to-one binding.
    • Manual Binding: Manually bind vCPUs to pCPUs based on the host pNUMA topology. All vCPUs must be bound.
      • A vCPU can be bound to one or more pCPUs, and a pCPU can be bound to one or more vCPUs. All pCPUs bound to one vCPU must belong to the same pNUMA node.
      • The average usage of each pCPU in the last 15 minutes is displayed to help you select the best pCPU for binding.
    Note:
    • If CPU overcommitment is configured, the number of vCPUs might be greater than the number of pCPUs. In this case, make sure the number of vCPUs does not exceed the number of bound pCPUs. Otherwise, VM performance might be significantly affected.
    • After CPU NUMA binding is configured, modifying the number of VM CPU cores automatically cancels CPU NUMA binding.
  3. Click OK to complete CPU NUMA binding. You can click Power On to power on the VM again.

Configure EmulatorPin

EmulatorPin: EmulatorPin assigns all other threads than virtual CPU (vCPU) threads and IO threads of a virtual machine to physical CPUs (pCPUs) of the host so that these threads run on assigned pCPUs.

Consider EmulatorPin in the following scenario:
  • Parallel multi-service scenario:

    When multiple VMs run different workloads on one host, they consume different amounts of resources. EmulatorPin binds the VM QEMU main thread to pCPUs, isolating primary service processes across VMs and controlling where the related threads can run.

To configure EmulatorPin binding:
  1. On the target VM page, click Actions > Advanced Settings > Modify Other Options, and then select EmulatorPin: Bind VM threads other than vCPU and I/O threads to host pCPUs based on the host pNUMA topology.
  2. Click OK to save the configuration. To cancel EmulatorPin, clear all pCPU selections and save. The system resumes scheduling the related threads.

Manage Virtual Disks

Add disks to an existing VM, expand disks, adjust disk properties, or limit I/O. Before you begin, distinguish system disks from data disks and understand the different results of detaching and deleting a disk.

Add a Disk

  1. Select the target VM in Inventory > VM and Host and click Modify Configuration.
  2. In the Hardware section, click Add Hardware > Disk and select the new disk entry.
  3. Select a creation method based on the data source.
    MethodRequired Configuration
    New DiskSelect the storage location and set the capacity. Make sure that the target data storage is available and has sufficient capacity.
    Disk ImageSelect an existing disk image and the target storage. The disk capacity must be at least the image capacity.
    Existing DiskSelect an available disk from the candidate list. The disk retains its encryption state, which cannot be changed during attachment.
    RDM DiskSelect an available storage device. RDM disks do not support disk encryption, and their operations and settings differ from those of regular virtual disks.
  4. Configure the available options, such as bus type, provision method, and caching mode, based on the storage type and workload requirements. Shared-disk mode and disk encryption are mutually exclusive. Shared disks do not support bus type changes or QoS settings.
  5. Review the configuration and click OK. Wait for the task to complete, check that the guest operating system recognizes the disk, and configure partitions, file systems, and mount points as required by the operating system.

Expand a Disk and Adjust Disk Properties

  1. Open Modify Configuration for the target VM and select the disk to modify.
  2. To expand the disk, set Capacity to a value greater than the current capacity. Check the capacity unit and the available space on the target storage. This operation does not support shrinking a disk.
  3. Adjust available options, such as bus type, caching mode, or AIO acceleration, as needed. Some options cannot be changed while the VM is running and require the VM to be shut down first. To change the storage location of an existing disk, use a migration task.
  4. Click OK and wait for the task to complete. After expansion, check the disk capacity in the guest operating system and extend partitions or file systems as needed. Expanding a disk on the platform does not automatically expand the available file system space in the guest operating system.

To change the disk storage location, see Change Data Storage. To change the encryption state, see Modify VM and Disk Encryption.

Limit Disk Bandwidth and IOPS

To configure disk QoS:
  1. On the target VM page, click Modify Configuration and select Hardware Info > Disk {$n} > QoS, and enable the QoS switch to configure QoS for Disk n, such as Disk 1.
    Disk QoS supports bandwidth limits and IOPS limits. After QoS is enabled, configure at least one type of limit:
    • Bandwidth Limit: Sets the upper limit of disk read/write throughput per second. Basic units include MB/s and GB/s. Do not set this value too low to avoid VM exceptions.
      • Total Speed: Sets the upper limit of total disk read/write throughput.
      • Read/Write Speed: Sets the upper limits of read throughput and write throughput separately.
    • IOPS Limit: Sets the upper limit of disk read/write operations per second.
      • Total IOPS: Sets the upper limit of total disk read/write IOPS.
      • Read/Write IOPS: Sets the upper limits of read IOPS and write IOPS separately.
  2. Click OK to complete disk QoS configuration.

Detach or Delete a Disk

Detaching a disk removes its association with the VM. Deleting it or moving it to the recycle bin affects the disk resource itself. Before detaching a disk, stop I/O to it and make sure that the workload no longer uses it. Before deleting a disk, make sure that its data is no longer needed.

  1. Open Modify Configuration, select the target disk, and choose Detach Disk or a deletion action from the disk action menu. Depending on the disk deletion policy, the deletion action is displayed as Move to Recycle Bin or Delete Disk.
  2. Shut down the VM before detaching or deleting its system disk. A disk with snapshots cannot be deleted directly. RDM disks do not provide the deletion action available for regular disks. If a menu action is unavailable, check the corresponding conditions first.
  3. Review the disk information and impact described in the confirmation dialog and confirm the operation. Then click OK in the Modify Configuration dialog to submit the changes.
  4. Wait for the task to complete and check the VM hardware list and workload status. Manage a detached disk separately according to its intended use.

Configure Virtual NICs

Add NICs to an existing VM, select their networks, adjust address settings, or limit network bandwidth. A port group provides network connectivity. Whether address settings take effect in the guest operating system also depends on DHCP, VMTools, and operating system configuration.

Add a NIC and Select a Network

  1. Select the target VM in Inventory > VM and Host and click Modify Configuration.
  2. In the Hardware Info section, click Add Hardware > NIC and select the new NIC entry.
  3. Select the NIC Model and Port Group. Make sure that the port group is available at the VM runtime location and that the guest operating system has a driver for the selected NIC. To use a ZNS network, switch to ZNS Network in the port group selection window. These networks do not support SR-IOV NICs.
  4. Configure available options, such as enabled state, multiple queues, addresses, DNS, and security groups, as needed. Address options vary with the selected port group. ZNS NICs cannot be associated with security groups, and the NIC QoS bandwidth limits here do not apply to them. For SR-IOV, also select an available NIC device.
  5. Click OK and wait for the task to complete. Check the NIC and addresses in the guest operating system and verify connectivity to the networks required by the workload.

Modify an Existing NIC

Changing the connected network, IP address, or MAC address might interrupt the current network connection. If you use this NIC for remote access to the VM, prepare another access method, such as the console, before proceeding.

  1. Open Modify Configuration and select the target NIC.
  2. Adjust the port group, enabled state, and editable address settings as needed.

    An existing NIC can switch only to a port group in its original network category. It cannot switch directly between Flat Network and ZNS Network. To connect to another category, add a NIC on the target network and verify connectivity before handling the old NIC.

    Some model and multiple-queue settings require the VM to be shut down first. An existing regular NIC cannot be changed directly to SR-IOV. An existing SR-IOV NIC cannot be changed directly to a regular model or switched to another port group.

  3. If DHCP is disabled on the port group, applying address settings through the platform requires the relevant VMTools components to be installed and running properly. If DHCP is enabled, online address changes require DHCP lease renewal or configuration through VMTools running properly.
  4. Click OK and wait for the task to complete. Check addresses, routes, and DNS in the guest operating system and verify workload connectivity.

Limit NIC Bandwidth

The NIC QoS configuration in this section does not apply to ZNS NICs. This NIC limitation does not affect VM disk QoS.

To configure network QoS:
  1. On the target VM page, click Modify Configuration and select Hardware Info > NIC {$n} > NIC QoS, and enable the QoS switch to configure QoS for NIC n, such as NIC 1.
    QoS supports send bandwidth and receive bandwidth. Basic units include Kbps, Mbps, and Gbps. After QoS is enabled, configure at least one bandwidth limit:
    • Transmit Bandwidth: Upper limit of network bandwidth uploaded from the VM.
    • Receive Bandwidth: Upper limit of network bandwidth downloaded to the VM.
  2. Click OK to complete network QoS configuration.

Disable or Remove a NIC

Disabling a NIC retains its configuration. Removing a NIC removes its association with the VM. Before you begin, make sure that the network connections carried by the NIC are no longer required.

ZNS NICs can be removed, including the VM's last NIC. Removal while the VM is running requires hot-unplug support in the guest operating system and driver.

  1. Open Modify Configuration and select the target NIC.
  2. To temporarily disable the NIC, turn off State. To remove it, use the removal control on the NIC entry. The enabled state of an SR-IOV NIC is restricted by the device type and cannot be toggled in the same way as a regular NIC.
  3. Click OK and wait for the task to complete. Then check the remaining NICs and workload network connections.

Configure CD/DVD Drives and ISOs

Use a CD/DVD drive to mount ISO media for operating system installation or maintenance tools. The drive is virtual hardware, and the ISO is the image file mounted in it. Unmounting an ISO does not remove the drive or delete the original file from image storage.

Add a CD/DVD Drive

  1. Shut down the VM, select it in Inventory > VM and Host, and click Modify Configuration.
  2. In the Hardware section, click Add Hardware > CD/DVD Drive. A VM supports up to 3 CD/DVD drives.
  3. Select the new drive and choose an ISO in Image File as needed. You can also leave the drive empty. The candidate list shows only eligible ISO system images that are enabled, ready, and in the same data center.
  4. Click OK. To boot from the ISO, configure the boot order as described in Configure Boot Options before powering on the VM.

Mount, Replace, or Unmount an ISO

  1. Open Modify Configuration for the target VM and select an existing CD/DVD drive.
  2. To mount or replace an ISO, select the target image in Image File. To unmount it, clear the current image selection. If the media is being used for operating system installation or file access, stop those operations first.
  3. Click OK, wait for the task to complete, and check that the guest operating system recognizes the media change. Replacing an ISO does not automatically change the boot order.

Remove a CD/DVD Drive

  1. Shut down the VM, open Modify Configuration, and select the target drive.
  2. Use the removal control on the drive entry and click OK.
  3. Wait for the task to complete and verify that the drive is removed from the virtual hardware list.

Configure GPU, USB, and PCIe Devices

Attach available GPU, USB, or PCIe devices to an existing VM. Complete the required host configuration first, select an eligible device from the VM candidate list, and install the required drivers in the guest operating system.

Before You Begin

  • Make sure that the device is not in use by another workload. Check the VM runtime location and where the device is available. GPU and PCIe passthrough depend on host capabilities such as IOMMU. For vGPU, partition the physical GPU first.
  • The device type and current configuration restrict online addition, replacement, or detachment. If a change cannot be made online, schedule a VM shutdown first. Online operations supported by one device type do not necessarily apply to other types.
  • Devices might restrict VM migration. Before you begin, check which devices and runtime location the workload must retain. Stop using a device in the guest operating system before detaching it.

Configure GPUs and vGPUs

  1. Select the target VM in Inventory > VM and Host and click Modify Configuration.
  2. In the Hardware section, click Add Hardware > GPU Device and select the new GPU entry.
  3. Set GPU Type to Physical GPU or vGPU and select an eligible device. You cannot add another GPU entry to a VM that already has a vGPU. You cannot add or replace a vGPU while the VM is running.
  4. Click OK and wait for the task to complete. Power on the VM and check the device and driver in the guest operating system.

To detach a GPU, open Modify Configuration, select Detach GPU from the action menu of the existing GPU entry, and submit the changes. Shut down the VM before detaching a vGPU. Partitioning or restoring a physical GPU remains a host-side operation.

Configure USB Devices

  1. Open Modify Configuration for the target VM and click Add Hardware > USB Device.
  2. Select the Attachment Mode and an eligible USB Device. Direct connection passes the device through to the VM, while forwarding provides access through redirection. Available devices depend on both the attachment mode and the VM runtime location. This configuration entry supports adding up to 1 USB device.
  3. Click OK, wait for the task to complete, and check the USB device in the guest operating system.

You cannot change the attachment mode of an existing USB device directly. To replace it, select Detach USB on the existing USB entry and configure a new device. Detaching the device interrupts its I/O. Stop using it in the guest operating system first.

Configure PCIe Devices

  1. Make sure that the required IOMMU support is enabled on the host and that the target device is available for passthrough. For host-side device preparation, see PCIe Devices.
  2. Open Modify Configuration for the VM and click Add Hardware > PCIe Device.
  3. Select a PCIe device that can be attached to the VM. For GPU devices, use the GPU configuration entry.
  4. Click OK and follow the confirmation prompts. Wait for the task to complete and check the device and driver in the guest operating system.

To detach a PCIe device, select Detach PCIe from the action menu of the existing PCIe entry and submit the changes. Online changes depend on PCI Hot Plug and device support. Shut down the VM first if the change cannot be made online.

Configure Boot Options

Before you begin

To configure boot options, make sure the VM is stopped.

Procedure

  1. On the target VM page, click Advanced Settings.
  2. On the Advanced Settings tab, select Boot Options.
  3. Click Edit and configure the boot order, BIOS mode, Secure Boot, and BIOS post delay as needed.

    Boot options include the following settings:

    Option Description
    Boot Order Defines the priority sequence for loading the operating system during VM startup.
    For example, if you set the boot order to (1) Disk 1, (2) CD/DVD Drive, and (3) Network, the VM boots as follows:
    1. The VM first attempts to boot from Disk 1. If the boot succeeds, the VM does not try the CD/DVD drive.
    2. If booting from Disk 1 fails, the VM attempts to boot from the CD/DVD drive. If the boot succeeds, the VM does not try the network.
    3. If booting from the CD/DVD drive fails, the VM attempts to boot from the network. If the system loads successfully from the network, boot succeeds. Otherwise, boot fails and the system cannot start.

    If the CD/DVD drive or network is first in the boot order, you can enable the option provided in the interface to use this order only for the next boot.

    BIOS Mode Select the BIOS boot mode based on the selected image format:
    • Legacy: Uses traditional BIOS boot.
    • UEFI: Uses UEFI boot and is required for aarch64 architecture. For operating systems such as Windows 7/2008, also configure the compatibility support module (CSM) as required by the interface.

    A mismatched BIOS mode might cause the VM to malfunction:

    • For qcow2 or raw images, select the same BIOS mode used when the image was created.
    • For iso images, select a BIOS mode as needed. The system boots and installs based on the selected mode.
    Secure Boot For an x86 VM, you can enable Secure Boot after selecting UEFI. Secure Boot verifies digital signatures of boot components during startup. Make sure that the operating system and bootloader support it. A VM with a TPM device supports only UEFI.
    BIOS Post Delay Specifies how long the BIOS screen stays open automatically. The valid range is 1 to 60 seconds. If no operation is performed within the specified time, the system automatically proceeds from the BIOS screen to system boot.
  4. Click OK to save the configuration. Power on the VM and verify that it boots into the expected operating system or installation media.

Modify VM and Disk Encryption

Enable or disable encryption for an existing VM, or change the encryption state of individual disks.

Before you begin

  • The VM is shut down.
  • An available default key provider is configured. If you use the Native Key Provider, back it up first. For more information, see Encryption Keys and How Encryption Works.
  • Shared disks and RDM disks do not support disk encryption. Before changing encryption settings, make sure that the target disk is neither a shared disk nor an RDM disk.

Procedure

  1. In the navigation pane, choose Inventory > VM and Host.
  2. Select the target VM and click Modify Configuration.
  3. In the Basic Info section of the Modify Configuration dialog, enable or disable VM Encryption as needed.
    • Enabling VM encryption encrypts runtime data written to disk, such as memory and GPU state, by using a key from the default key provider. It also automatically enables Disk Encryption for the existing disks.
    • Disabling VM encryption does not automatically disable Disk Encryption. You can keep individual disks encrypted or disable disk encryption in the next step.
  4. In the Hardware Info section, select a disk and enable or disable Disk Encryption as needed.
    Disk encryption protects all data stored on the selected disk. You can encrypt an individual disk even when VM encryption is disabled.
  5. Review the configuration and click OK.
    Note:
    Changing the encryption state of an existing VM or disk requires processing existing data and usually takes longer than enabling encryption during VM creation. Source data retained during conversion is displayed on the Data Cleanup tab of the data storage. After verifying that the converted VM works as expected, clean up the source data as needed.

Configure VM Time Synchronization

Time consistency between VMs and hosts is important for workloads running on the platform. ZSphere provides two time synchronization mechanisms: BIOS clock synchronization and VM time synchronization.

BIOS Clock Synchronization

BIOS clock synchronization is designed for Windows VMs. For a Windows VM, hardware clock time comes from the host, and system time is equivalent to hardware clock time. You can enable BIOS clock synchronization to keep the Windows VM hardware time, system time, and host hardware time consistent.

For an existing Windows VM, shut down the VM, open Advanced Settings > Boot Options, click Edit, configure BIOS Time Synchronization, and save the configuration.

Time Synchronization

Time synchronization is designed to synchronize the system time of Windows and Linux VMs with the host system time. For a Linux VM, hardware time comes from the host, while system time is calculated separately. System time is synchronized with hardware time only at specific moments, such as when the system starts. At other times, system time is independent of hardware time.

VM time synchronization mechanism:
  • Network: Unlike NTP time synchronization, this mechanism does not depend on a specific external network. It involves only communication between the host and the VM.
  • Time zone: The VM periodically synchronizes the time zone of the host where it runs to keep them consistent.
  • Synchronization interval: By default, synchronization is performed every 60 seconds. You can modify the synchronization interval by using the CLI. Supported values are 60 seconds (1 minute), 600 seconds (10 minutes), 1800 seconds (30 minutes), 3600 seconds (1 hour), 7200 seconds (2 hours), 21600 seconds (6 hours), 43200 seconds (12 hours), and 86400 seconds (1 day).
    # Modify the synchronization interval by using the CLI
    [root@localhost ~]# UpdateResourceConfig vm=<vm_uuid> category=vm \
    name=vm.clock.sync.interval.in.seconds value=<intervalInSeconds>
    
    # vm_uuid is the VM UUID
    # intervalInSeconds is the synchronization interval to set, in seconds
  • Synchronization policy: The current policy is immediate consistency. Regardless of whether the VM time is ahead of or behind the host time, when synchronization is triggered, the VM time immediately becomes consistent with the host time.
To configure time synchronization for a single VM:
  1. Make sure QEMU Guest Agent (QGA) is installed on the VM and is running. For more information, see Install and Use VMTools.
  2. Disable other time source synchronization policies on the VM. This is recommended.
  3. On the VM Advanced Settings page, select VMTools, click Edit, enable Time Synchronization, and save. By default, the host system time is synchronized automatically every 60 seconds.
  4. Check the time and workload behavior in the guest operating system to verify that synchronization works as expected.

Import User Data to a Linux VM

User Data is user-defined data. You can use custom parameters or scripts to customize a Linux VM or perform specific tasks when creating the VM.

Before you begin

  • Before importing User Data, make sure cloud-init is installed in the VM image. Recommended versions are 0.7.9, 17.1, 19.4, or later.
  • If you use User Data to set the hostname and SSH login password, do not set the hostname and password again on the platform to avoid conflicts.
  • When creating a Linux VM from an image that has cloud-init installed, you must import User Data. Otherwise, the cloud-init task waits until timeout.

Procedure

  1. Prepare the User Data script for the required functions.
    Script example:
    #cloud-config
    users:
     - name: test
       shell: /bin/bash
       groups: users
       sudo: ['ALL=(ALL) NOPASSWD:ALL']
       ssh-authorized-keys:
           - ssh-rsa AAAAB3NzaC1LXCJfjroD1lT root@10-0-0-18
    bootcmd:
     - mkdir /tmp/temp
    write_files:
     - path: /tmp/Cloud_config
       content: |
           Hello,world!
       permissions: '0755'
    fqdn: Perf-test
    disable_root: false
    ssh_pwauth: yes
    chpasswd:
      list: |
          root:word
      expire: False
    runcmd:
     - echo ls -l / >/root/list.sh
    The preceding example implements the following functions:
    1. Creates the user test and uses an SSH key when the VM is created.
    2. Writes the file /etc/hosts, creates the /tmp/temp directory, and creates a file with content during startup.
    3. Sets the hostname, enables the root user, allows SSH password login, and changes the root password.
    4. Runs the echo ls -l / command.
  2. In the navigation pane, select Inventory.
  3. In the inventory, right-click a cluster, host, or image, and then click New Virtual Machine.
  4. In the New Virtual Machine dialog, select Advanced Settings > General Options.
  5. Paste the script into the User Data input box.
  6. Complete the VM creation process to import User Data.

Import User Data to a Windows VM

User Data is user-defined data. You can use custom parameters or scripts to customize a Windows VM or perform specific tasks when creating the VM.

Before you begin

  • Before importing User Data, make sure Cloudbase-init is installed in the VM image. The recommended version is 0.9.11. For more information about Cloudbase-init, see Cloudbase official documentation.
  • If you use User Data to set the hostname and SSH login password, do not set the hostname and password again on the platform to avoid conflicts.
  • When creating a Windows VM from an image that has Cloudbase-init installed, you must import User Data. Otherwise, the Cloudbase-init task waits until timeout.

Procedure

  1. Prepare the User Data script for the required functions.
    Script example:
    #cloud-config
    write_files:
       -   encoding: b64
           content: NDI=
           path: C:\b64
           permissions: '0644'
       -   encoding: base64
           content: NDI=
           path: C:\b64_1
           permissions: '0644'
       -   encoding: gzip
           content: !!binary |
               H4sIAGUfoFQC/zMxAgCIsCQyAgAAAA==
           path: C:\gzip
           permissions: '0644'

    The preceding example creates the following three files on drive C during VM startup: b64, b64_1, and gzip.

  2. In the navigation pane, select Inventory.
  3. In the inventory, right-click a cluster, host, or image, and then click New Virtual Machine.
  4. In the New Virtual Machine dialog, select Advanced Settings > General Options.
  5. Paste the script into the User Data input box.
  6. Complete the VM creation process to import User Data.