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
-
Add the installation image.
In the main menu, choose , 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:
- Create a VM instance.
- Install Kylin V10 SP3 or V11.
Procedure
-
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.
-
Install Kylin V10 SP3.
-
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:
- Set the hostname.
- Configure the network.
- Check SELinux.
- Optional: Install GuestTools.
- If GuestTools is installed, check the installation result.
- Optional: Install cloud-init.
Procedure
-
Set the hostname.
Run hostnamectl set-hostname localhost.localdomain to set the default hostname of the template.
-
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. -
Check SELinux.
Run getenforce to check the SELinux status. Preserve the current configuration unless an application explicitly requires a change.
-
(Optional) Install VM GuestTools
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.
-
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. -
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-initEdit /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 rebootLog in again and run
to confirm that initialization completes without errors.cloud-init status --long
Create a System Template
About this task
Create a system template as follows:
- Clean initialization state and shut down.
- Create an image.
- Export the image.
Procedure
-
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
sshinitialization module, andssh_deletekeys: trueis 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 fixedsystemd.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. -
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 .
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 
-
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 . 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.qcow2The first argument is the image installation path and the second is the output path and filename. Omit the
ceph://prefix.



