Document navigation

Prepare the Environment

Prerequisites

Before creating a Kylin V10 SP3 or V11 template, obtain the installation ISO and add it to ZStack Cloud.
  • Obtain the image from the official website and comply with its license.
  • The examples use Kylin-Server-V10-SP3-General-Release-2303-X86_64.iso and Kylin-Server-V11-2503-Release-General-20250715-X86_64.iso.

Procedure

  1. Add the installation image.

    In the main menu, choose Resource Center > Cloud Resource Pool > Compute Configuration > Image, then click Add Image.

    Configure the following parameters:

    • Name: Enter an image name.
    • Description: Enter a description.
    • Image Type: Select System Image.
    • Image Format: Select iso.
    • CPU Architecture: Select x86_64.
    • Platform: Select Linux.
    • Operating System: Select Kylin 10 for V10 SP3 or Kylin 11 for V11.
    • Virtio: Enable Virtio.
    • Image Storage: Select an image storage added to the platform.
    • Image URL: Provide a URL or upload a local file.
    • BIOS Mode: Select Legacy or UEFI. The original V10 SP3 example uses Legacy; the V11 example uses UEFI.
    Note: Use the same boot mode for the source VM instance and VM instances created from the template.
    Figure 1. V11 Installation Image


Create a Template

Install the Operating System

About this task

Install the operating system as follows:

  1. Create a VM instance.
  2. Install Kylin V10 SP3 or V11.

Procedure

  1. Create a VM instance.

    Create a VM instance on ZStack Cloud and boot it from the installation image. For details, see the Create a VM Instance chapter of the User Guide.

  2. Install Kylin V10 SP3.
    1. Select the boot option.

      Open the console and select Install Kylin Linux Advanced Server V10 to start installation.

      Figure 2. Kylin V10 SP3 Installation


    2. Select the installation language.

      Select a language for the installer and operating system. The following screenshots use English.

    3. Configure the installation summary.

      Configure the following settings as needed:

      • Localization: Keyboard, language support, time and date.
      • Software: Installation source and software selection.
      • System: Installation destination, network and host name.
      • User settings: Root password and user creation.
      Figure 3. Installation Summary


    4. Optional: Configure disk partitions.

      This tutorial uses automatic partitioning. To customize partitions, click Installation Destination on the Installation Summary page.

      Figure 4. Disk Partitioning


    5. Install the operating system.

      Return to Installation Summary and click Begin Installation. When installation completes, click Reboot System. Review and accept the license information to enter the system.

  3. Install Kylin V11.

    Create a VM instance from the V11 ISO. This example uses 2 CPU cores, 4 GB of memory, a 40 GB root volume, and UEFI. Open the console and select Install Kylin Linux Advanced Server V11.

    Select English (United States). On the Installation Summary page, select Minimal Install under Software Selection, select the target disk and Automatic partitioning under Installation Destination, enable the network interface under Network & Host Name, and set the root password.

    Figure 5. V11 Installation Summary


    Figure 6. V11 Disk Partitioning


    Click Begin Installation. When installation completes, click Reboot System, detach the installation ISO, and log in.

Configure the Template System

Prerequisites

Run the following commands as root from the VM instance console.

About this task

Configure the template system as follows:

  1. Set the hostname.
  2. Configure the network.
  3. Check SELinux.
  4. Optional: Install GuestTools.
  5. If GuestTools is installed, check the installation result.
  6. Optional: Install cloud-init.

Procedure

  1. Set the hostname.

    Run hostnamectl set-hostname localhost.localdomain to set the default hostname of the template.

  2. Configure the network.

    List connections, run the read command, and enter the required connection name. Configure DHCP and automatic connection. These commands remove manual IPv4 addresses, routes, and DNS settings and use the platform-assigned NIC MAC. Do not apply them to a network that requires static settings. In particular, enable automatic connection after installing V10 SP3.

    nmcli connection show
    read -r KYLIN_CONNECTION
    nmcli connection modify "$KYLIN_CONNECTION" \
        connection.autoconnect yes ipv4.method auto \
        ipv4.addresses "" ipv4.gateway "" ipv4.dns "" \
        ipv4.routes "" ipv4.ignore-auto-routes no ipv4.never-default no \
        ipv4.ignore-auto-dns no 802-3-ethernet.mac-address "" \
        802-3-ethernet.cloned-mac-address permanent
    nmcli connection up "$KYLIN_CONNECTION"
    Note: Activating the connection can interrupt SSH. Use the console. Keep connection settings matched to the target NIC name and preserve IPv6 settings for your network.
  3. Check SELinux.

    Run getenforce to check the SELinux status. Preserve the current configuration unless an application explicitly requires a change.

  4. (Optional) Install VM GuestTools
    1. Attach GuestTools ISO to the VM instance.
      Click to install GuestTools on the VM details page and install the GuestTools ISO.
    2. Run installation commands.
      Run the following command on the VM instance console to finish the installation.
      [root@localhost ~]# mkdir /mnt/cdrom    #Create a monut point.
      [root@localhost ~]# mount /dev/cdrom /mnt/cdrom    #Attach CD-ROM image.
      [root@localhost ~]# cd /mnt/cdrom/
      bash ./zs-tools-install.sh     #Install GuestTools.
      [root@localhost ~]# cd ~
      umount /mnt/cdrom    #Unmount CD-ROM (optional).
    Note: Notice the following points:
    • Run yum install tar -y to install the tar command before installing the GuestTools.
    • If you attach data volumes to the Linux system image created, do not write the attachment information of the data volumes into /etc/fstab. Otherwise, the VM instances created with this template may fail to start.
    • If you want to attach the data volumes to a VM instance when it starts, we recommend the following method:
      [root@localhost ~]# echo "mount -t ext4 -U "d0shC2-2GO1-Vyuc-XKXf-Pb3c-uvG5-92Fzeu" /mnt" >> /etc/rc.d/rc.local
      [root@localhost ~]# # -t indicates the file system of the disk; -U indicates using UUID to attach the disk;/mnt indicates the mount path
      [root@localhost ~]# # run blkid to obtain the device UUID
      [root@localhost ~]# chmod +x /etc/rc.d/rc.local
      [root@localhost ~]# # We recommend you to attach the disk with the device UUID instead of the disk symbol such as /dev/vdb.
  5. If GuestTools is installed, check the installation result.
    Figure 7. V11 GuestTools Installation Result


    Note: The V11 installer may report zs-tools is not verified for os: kylinV11. Successful installation does not mean that the vendor has verified full compatibility with this version.
  6. Optional: Install cloud-init.

    Install and configure cloud-init for User Data and SSH public key initialization. The initialization cleanup commands in the next chapter apply to templates with this configuration.

    Install cloud-init from the official repository for the selected release to initialize hostnames, user data, and SSH public keys. Preserve existing SELinux, firewall, and password policies.

    dnf install cloud-init

    Edit /etc/cloud/cloud.cfg.d/99-template.cfg and merge these settings, preserving other required configuration. NetworkManager manages the network:

    network:
      config: disabled
    preserve_hostname: false
    ssh_deletekeys: true
    ssh_pwauth: false
    Note: This configuration disables SSH password authentication. Confirm the account used for initialization public keys and retain a working console login.

    Enable the services and reboot:

    systemctl enable cloud-init-local.service cloud-init.service cloud-config.service cloud-final.service
    systemctl reboot
    Log in again and run
    cloud-init status --long
    to confirm that initialization completes without errors.

Create a System Template

About this task

Create a system template as follows:

  1. Clean initialization state and shut down.
  2. Create an image.
  3. Export the image.

Procedure

  1. Clean initialization state and shut down.

    If cloud-init is installed, use the commands below. Otherwise, retain the SSH host keys, run truncate -s 0 /etc/machine-id, and shut down normally. The machine ID file conditions below also apply.

    If cloud-init is installed, confirm that it has completed initialization, /etc/cloud/cloud.cfg includes the ssh initialization module, and ssh_deletekeys: true is retained. These commands require the D-Bus machine ID to link to /etc/machine-id, which must not be a separate mount point. Adapt cleanup first if these conditions do not hold. Boot parameters must not set a fixed systemd.machine_id=.

    V10 SP3: cloud-init 19.4 does not support --machine-id. Clean its cache and manually empty the machine ID file:

    (
        set -e
        test "$(id -u)" -eq 0
        test -f /etc/machine-id
        test ! -L /etc/machine-id
        test -L /var/lib/dbus/machine-id
        test "$(readlink -f /var/lib/dbus/machine-id)" = /etc/machine-id
        command -v mountpoint >/dev/null
        if mountpoint -q /etc/machine-id; then
            exit 1
        fi
        cloud-init clean --logs
        truncate -s 0 /etc/machine-id
        rm -f /etc/ssh/ssh_host_*_key /etc/ssh/ssh_host_*_key.pub
        sync
        systemctl poweroff
    )

    V11: cloud-init 23.4.1 supports --machine-id. Use this branch:

    (
        set -e
        test "$(id -u)" -eq 0
        test -f /etc/machine-id
        test ! -L /etc/machine-id
        test -L /var/lib/dbus/machine-id
        test "$(readlink -f /var/lib/dbus/machine-id)" = /etc/machine-id
        command -v mountpoint >/dev/null
        if mountpoint -q /etc/machine-id; then
            exit 1
        fi
        cloud-init clean --logs --machine-id
        rm -f /etc/ssh/ssh_host_*_key /etc/ssh/ssh_host_*_key.pub
        sync
        systemctl poweroff
    )
    Note: Do not restart the source VM instance after cleanup. When cloud-init is configured as described above, it regenerates SSH host keys on the first boot of new VM instances. Do not preconfigure fixed host keys in configuration or user data.
  2. Create an image.

    Confirm that the VM instance is stopped and detach the installation ISO. Do not restart the source after cleanup. On the VM instance details page, choose Actions > Image and ISO > Create Image.

    Configure the following parameters:

    • Name: Enter an image name.
    • Description: Optional.
    • Image Type: Select System Image.
    • Image Storage: Select an existing image storage.
    Figure 8. Create a V10 SP3 Image


    Figure 9. Create a V11 Image


  3. Export the image.

    Export the image to use it on another cloud platform. The procedure depends on the image storage type:

    • ImageStore: On the Image page, choose Actions > Export Image. Copy the exported image URL on the Overview page to download the image, or copy the URL or download directly from Export Records.
    • Ceph: Export from the UI in the same way, or copy the Install Path from the image Overview page and run rbd export on the Ceph server. For example:
      rbd export bak-t-cac5eee23a204c1a914d1743f1584644/7232237c0059409babcd1c7a69452b98 /root/export-test.qcow2

      The first argument is the image installation path and the second is the output path and filename. Omit the ceph:// prefix.

What to do next

The Kylin V10 SP3 or V11 system template is ready. Use the image to create VM instances in batches.
System Template Creation Tutorial | 5.5.38 | ZStack Cloud · ZCF | ZStack Resource Center