Document navigation

Environment Preparation

Prerequisites

To encapsulate an openEuler 24.03 LTS SP4 template, obtain an ISO image in advance and add it to ZStack Cloud. Notice the following points when you perform this operation:
  • 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

  1. Add an installation image.

    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 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

To install an operating system, follow these steps:
  1. Create a VM instance.
  2. Install openEuler 24.03 LTS SP4.

Procedure

  1. 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.

  2. Install openEuler 24.03 LTS SP4.
    1. Select the Installation Language.

      Boot the installer from the ISO and configure installation on the following pages.

      Select English and English (United States), then click Continue. Configure the time zone and keyboard.

      See Figure 2.

      Figure 2. Select the Installation Language

      Select the Installation Language
    2. Installation Summary.

      In Software Selection, select Minimal Install and click Done.

      See Figure 3.

      Figure 3. Select Minimal Install

      Select Minimal Install

      In Network & Host Name, select the actual NIC and turn it on. Confirm its state changes to Connected. The NIC name in the figure is an example; use the name on your system.

      See Figure 4.

      Figure 4. Enable the Installation NIC

      Enable the Installation NIC

      Click Configure and verify that Method on IPv4 Settings is Automatic (DHCP). Save the configuration and check the assigned address, gateway, and DNS. Configure a dedicated administrator account before starting installation.

      See Figure 5.

      Figure 5. Check IPv4 DHCP Settings

      Check IPv4 DHCP Settings

      This example uses the following installation settings. Start installation after configuring disk partitioning.

      See Figure 6.

      Figure 6. Review the Summary Before Installation

      openEuler installation summary and Begin Installation button
    3. (Optional) Partition the Disk.

      In Installation Destination, select the new root volume and verify its capacity and device name. The example uses a 40 GiB vda disk. Select Automatic partitioning, review the partition summary, and click Done.

      See Figure 7.

      Figure 7. Select the Installation Disk and Automatic Partitioning

      Select the Installation Disk and Automatic Partitioning
    4. Install the System.

      After completing the settings, return to Installation Summary and click Begin Installation.

      Wait until the installer displays Complete! and confirms successful installation before restarting and checking boot from the root volume.

      See Figure 8.

      Figure 8. openEuler Installation Complete

      Installer showing Complete! and the Reboot System button

      Detach the installation ISO and set HardDisk first in the boot order. Sign in to the installed system through the console, then configure the template.

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:
  1. Set the Hostname.
  2. (Optional) Install cloud-init.
  3. Configure networking.
  4. (Optional) Install GuestTools.

Procedure

  1. Set the Hostname.
    Run the following command to set the template hostname:
    hostnamectl set-hostname localhost.localdomain
  2. (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.
  3. 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 status

    Set 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.

  4. (Optional) Install GuestTools.

    Before installing GuestTools, install the following dependencies:

    dnf install -y tar

    Attach 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.sh

    If the installer asks whether to link python3 to python, enter y. After installation, leave the directory and unmount the media.

    cd ~
    umount /mnt/cdrom
    Figure 9. GuestTools Installation Result and Compatibility Notice

    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

To create a system template, follow these steps:
  1. Create an image.
  2. Export the image.

Procedure

  1. 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
    CLEANUP

    On the details page of the VM instance created, choose Actions > Image and ISO > Create Image. 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


  2. 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 Actions > Export Image. 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 Actions > Export Image. 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:
        1. On the Overview page of the created image, copy Installation Path.
        2. 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://.

What to do next

Now, you have completed the encapsulation of a openEuler 24.03 LTS SP4 system template. You can use this image to create VM instances in bulk.
openEuler 24 System Template Tutorial | 5.5.38 | ZStack Cloud · ZCF | ZStack Resource Center