Environment Preparation
Prerequisites
- You need to obtain an openEuler 24.03 LTS SP4 installation image from the official website by yourself. Ensure your compliance of relevant authorizations and permissions.
- This Tutorial references openEuler-24.03-LTS-SP4-x86_64-dvd.iso.
Procedure
-
Add an installation image.
On the main menu of ZStack Cloud, choose . On the Image page, click Add Image. Then, the Add Image page is displayed.
On the displayed 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 Linux.
- OS: Select an operating system that is consistent with the image.
- VirtIO: Choose whether to enable VirtIO according to your actual operating system and platform. Here, enable VirtIO.
- Image Storage: Select an image storage added before.
- Image Path: Specify an image URL or upload a local file. This example uploads a local file.
Note: Do not refresh or close the browser or stop management node services during upload. - BIOS Mode: Select a BIOS mode. Here, select Legacy.
Figure 1. Add an Image 
Template
Install an Operating System
About this task
- Create a VM instance.
- Install openEuler 24.03 LTS SP4.
Procedure
-
Create a VM Instance.
Create a VM Instance on ZStack Cloud and boot it from the installation image. For more information, see Create a VM Instance in the User Guide. This example uses 2 vCPUs, 4 GiB of memory, a 40 GiB root volume, and one NIC with IPv4 DHCP.
-
Install openEuler 24.03 LTS SP4.
Configure the Template System
Prerequisites
Sign in as root through the console, or run sudo -i with an account that has sudo privileges. Run the following commands one at a time and resolve failures before continuing.
About this task
Configure the template system by using the following steps:- Set the Hostname.
- (Optional) Install cloud-init.
- Configure networking.
- (Optional) Install GuestTools.
Procedure
-
Set the Hostname.
Run the following command to set the template hostname:
hostnamectl set-hostname localhost.localdomain -
(Optional) Install cloud-init.
To initialize VM Instances with User Data or SSH public keys, install cloud-init from repositories matching the OS release.
dnf install -y cloud-init
Note: For offline installation, use the installation DVD for the same release as a repository and retain package signature verification.
Note: For SSH access, also install and enable openssh-server. Without cloud-init, automatic User Data and SSH public key injection are unavailable. -
Configure networking.
If cloud-init is installed, configure networking as follows. Otherwise, retain the installer network configuration, ensure DHCP and automatic connection are enabled, and skip the cloud-init configuration and cleanup commands in this step.
Use NetworkManager, with IPv4 DHCP and automatic connection at startup. Remove MAC bindings specific to the builder.
nmcli connection show nmcli device statusSet the following in /etc/cloud/cloud.cfg.d/99-network-manager.cfg so cloud-init uses NetworkManager for both rendering and activation.
system_info: network: renderers: ['network-manager'] activators: ['network-manager']If cloud-init has already run, back up the configuration and run cloud-init clean to apply the policy during the next initialization. Cleaning is unnecessary before its first run.
After configuring the network, run systemctl reboot to restart the VM Instance.
-
(Optional) Install GuestTools.
Before installing GuestTools, install the following dependencies:
dnf install -y tarAttach the current platform GuestTools ISO on the VM Instance details page. Confirm that /dev/cdrom refers to it and /mnt/cdrom has no other media mounted, then run the following commands.
mkdir -p /mnt/cdrom mount /dev/cdrom /mnt/cdrom cd /mnt/cdrom bash ./zs-tools-install.shIf the installer asks whether to link python3 to python, enter y. After installation, leave the directory and unmount the media.
cd ~ umount /mnt/cdromFigure 9. GuestTools Installation Result and Compatibility Notice 
Note: A zs-tools is not verified for os message means the tools have not been verified for the OS. Successful installation does not establish official compatibility.
Create a System Template
About this task
- Create an image.
- Export the image.
Procedure
-
Create an Image.
Run the following commands as root to clear template identity and shut down. Remove temporary credentials and retain a login account for new VM Instances. Do not restart the template VM Instance after cleanup.
Note: Without cloud-init, these commands retain SSH host keys to avoid preventing SSH from starting without a key-generation mechanism. Arrange host-key regeneration for each VM Instance created from such an image; cloud-init initialization is unavailable.If cloud-init is installed, confirm that initialization succeeds and the ssh module generates SSH host keys on first boot before cleanup.
sh -eu <<'CLEANUP' test "$(id -u)" -eq 0 dbus_id=/var/lib/dbus/machine-id if [ -L "$dbus_id" ]; then test "$(readlink -f "$dbus_id")" = /etc/machine-id elif [ -e "$dbus_id" ]; then test -f "$dbus_id" fi if command -v cloud-init >/dev/null 2>&1; then cloud-init clean --logs --machine-id rm -f /etc/ssh/ssh_host_* else printf 'uninitialized\n' > /etc/machine-id fi if [ -d /var/lib/dbus ] && [ ! -L "$dbus_id" ]; then rm -f "$dbus_id" ln -s /etc/machine-id "$dbus_id" fi sync systemctl poweroff CLEANUPOn the details page of the VM instance created, choose . Then, the Create Image page is displayed.
On the displayed 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 here.
- Image Storage: Select an image storage created before.
Figure 10. Create an Image 
-
Export the image.
You can use the image exported to create VM instances on other cloud platforms directly. The method to export images varies according to image storage types.
- ImageStore image storage.
On the Image page, choose . This button helps export the image.
After generating the image, you can copy the URL of the image exported on the Overview page to download the image. Or, you can copy the URL of the exported image on the Exported page. You can also click Download on the page to download the image directly.
- Ceph image storage. If you use a Ceph image storage, you can export
the image on the UI or from the image storage.
- Export on the UI:
On the Image page, choose . This button helps export the image.
After generating the image, you can copy the URL of the image exported on the Overview page to download the image. Or, you can copy the URL of the exported image on the Exported page. You can also click Download on the page to download the image directly.
- Export from the image storage:
- On the Overview page of the created image, copy Installation Path.
- Login to the terminal of the Ceph image storage, run
rbd export to export the image.
For example: If you obtain the installation path ceph://bak-t-cac5eee23a204c1a914d1743f1584644/7232237c0059409babcd1c7a69452b98, you can run the following commands to export the image:
[root@ceph-node1 ~]# rbd export bak-t-cac5eee23a204c1a914d1743f1584644/7232237c0059409babcd1c7a69452b98 /root/export-test.qcow2 [root@ceph-node1 ~]# # bak-t indicates the installation path of the image [root@ceph-node1 ~]# # /root/export-test.qcow2 indicates the target path and the file name of the exported image
Note: The
command rbd export does not
include such a prefix as ceph://.
- Export on the UI:
- ImageStore image storage.







