All Products
Search
Document Center

Alibaba Cloud Linux:Use an Alibaba Cloud Linux image on an on-premises virtual machine

Last Updated:May 27, 2026

Alibaba Cloud Linux provides VHD and QCOW2 images with built-in cloud-init for on-premises kernel-based virtual machines (KVMs). This topic covers how to use Alibaba Cloud Linux 2 or 3 images on on-premises KVMs.

Background information

This topic uses Anolis OS as the host operating system and the NoCloud data source to generate cloud-init configuration files. These files are attached to the KVM as virtual disks to initialize system settings on boot. Download Anolis OS from the Anolis OS download page. Familiarity with KVM management is assumed.

Step 1: Download an Alibaba Cloud Linux image

Download a VHD or QCOW2 image from one of the following URLs:

Step 2: Obtain the seed.img boot image

Alibaba Cloud Linux images require a seed.img boot image that contains network, account, and YUM repository configurations for cloud-init.

Important
  • The boot image is typically named seed.img. You can rename it, but we recommend keeping the default name.

  • The seed.img boot image contains only cloud-init configuration files, not Alibaba Cloud Linux system files.

Use one of the following methods to obtain the seed.img boot image:

  • Method 1: Download the seed.img boot image

    Download the seed.img boot image from one of the following URLs:

    Note

    The pre-built image has fixed configurations that cannot be modified. Verify that its settings meet your requirements before use.

  • Method 2: Use the NoCloud data source to manually generate the seed.img boot image

    Note

    NoCloud is a cloud-init data source that provides configuration files in on-premises environments for virtual machines to read at boot.

    1. Create two configuration files named meta-data and user-data in a local directory.

      These files are part of the seed.img boot image. On startup, cloud-init reads these files and initializes the virtual machine accordingly.

      1. Create a directory named seed and go to the directory.

        sudo mkdir seed
        sudo cd seed/
      2. Create a configuration file named meta-data.

        Example content. The virtual machine name is alinux-host. Change it as needed.

        #cloud-config
        #vim:syntax=yaml
        
        local-hostname: alinux-host                 
      3. Create a configuration file named user-data.

        Example content. Modify as needed. If you use this example directly, ensure you understand the configuration.

        • Creates a user account alinux with password aliyun and sudo privileges.

        • Adds the Alibaba Cloud Linux YUM repository.

          Alibaba Cloud Linux 3

          #cloud-config
          #vim:syntax=yaml
          
          # Create an account named alinux and grant the account the permissions to run sudo commands. 
          users:
            - default
            - name: alinux
              sudo: ['ALL=(ALL)   ALL']
              plain_text_passwd: aliyun
              lock_passwd: false
          
          # Create a YUM repository for Alibaba Cloud Linux 3. 
          yum_repos:
              alinux3-module:
                  name: alinux3-module
                  baseurl: https://mirrors.aliyun.com/alinux/$releasever/module/$basearch/
                  enabled: 1
                  gpgcheck: 1
                  gpgkey: https://mirrors.aliyun.com/alinux/$releasever/RPM-GPG-KEY-ALINUX-3
              alinux3-updates:
                  name: alinux3-updates
                  baseurl: https://mirrors.aliyun.com/alinux/$releasever/updates/$basearch/
                  enabled: 1
                  gpgcheck: 1
                  gpgkey: https://mirrors.aliyun.com/alinux/$releasever/RPM-GPG-KEY-ALINUX-3
              alinux3-plus:
                  name: alinux3-plus
                  baseurl: https://mirrors.aliyun.com/alinux/$releasever/plus/$basearch/
                  enabled: 1
                  gpgcheck: 1
                  gpgkey: https://mirrors.aliyun.com/alinux/$releasever/RPM-GPG-KEY-ALINUX-3
              alinux3-powertools:
                  name: alinux3-powertools
                  baseurl: https://mirrors.aliyun.com/alinux/$releasever/powertools/$basearch/
                  gpgcheck: 1
                  enabled: 1
                  gpgkey: https://mirrors.aliyun.com/alinux/$releasever/RPM-GPG-KEY-ALINUX-3
              alinux3-os:
                  name: alinux3-os
                  baseurl: https://mirrors.aliyun.com/alinux/$releasever/os/$basearch/
                  gpgcheck: 1
                  enabled: 1
                  gpgkey: https://mirrors.aliyun.com/alinux/$releasever/RPM-GPG-KEY-ALINUX-3

          Alibaba Cloud Linux 2

          #cloud-config
          #vim:syntax=yaml
          
          # Create an account named alinux and grant the account the permissions to run sudo commands. 
          users:
            - default
            - name: alinux
              sudo: ['ALL=(ALL)   ALL']
              plain_text_passwd: aliyun
              lock_passwd: false
          
          # Create a YUM repository for Alibaba Cloud Linux 2. 
          yum_repos:
              base:
                  baseurl: https://mirrors.aliyun.com/alinux/$releasever/os/$basearch/
                  enabled: true
                  gpgcheck: true
                  gpgkey: https://mirrors.aliyun.com/alinux/RPM-GPG-KEY-ALIYUN
                  name: Aliyun Linux - $releasever - Base - mirrors.aliyun.com
              updates:
                  baseurl: https://mirrors.aliyun.com/alinux/$releasever/updates/$basearch/
                  enabled: true
                  gpgcheck: true
                  gpgkey: https://mirrors.aliyun.com/alinux/RPM-GPG-KEY-ALIYUN
                  name: Aliyun Linux - $releasever - Updates - mirrors.aliyun.com
              extras:
                  baseurl: https://mirrors.aliyun.com/alinux/$releasever/extras/$basearch/
                  enabled: true
                  gpgcheck: true
                  gpgkey: https://mirrors.aliyun.com/alinux/RPM-GPG-KEY-ALIYUN
                  name: Aliyun Linux - $releasever - Extras - mirrors.aliyun.com
              plus:
                  baseurl: https://mirrors.aliyun.com/alinux/$releasever/plus/$basearch/
                  enabled: true
                  gpgcheck: true
                  gpgkey: https://mirrors.aliyun.com/alinux/RPM-GPG-KEY-ALIYUN
                  name: Aliyun Linux - $releasever - Plus - mirrors.aliyun.com
    2. (Optional) If you use Alibaba Cloud Linux 3, enable the epel-testing repository.

      1. Open the epel-testing.repo file.

        sudo vim /etc/yum.repos.d/epel-testing.repo
      2. Press i to enter edit mode and replace enabled=0 with enabled=1.

        [epel-testing]
        name=Extra Packages for Enterprise Linux 8 - Testing - $basearch
        baseurl=http://mirrors.cloud.aliyuncs.com/epel/testing/8/Everything/$basearch
        enabled=0
        gpgcheck=1
        countme=1
        gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8
      3. Press Esc and enter :wq to save and exit.

    3. Install the cloud-utils package:

      sudo yum install -y cloud-utils
    4. Generate the seed.img boot image:

      sudo cloud-localds seed.img user-data meta-data

Step 3: Start your on-premises virtual machine

Start a KVM using one of the following methods:

Use libvirt to start the KVM

  1. Create an XML configuration file on your on-premises computer.

    Example file: alinux3.xml for Alibaba Cloud Linux 3 or alinux2.xml for Alibaba Cloud Linux 2. Modify as needed.

    Alibaba Cloud Linux 3

    <domain type='kvm'>
        <name>alinux3</name>
        <memory>1048576</memory><!-- Set the memory size to 1 GB.  -->
        <vcpu>1</vcpu>
        cpu mode='host-passthrough'><!-- Start the KVM on the server of the corresponding architecture.  -->
        </cpu>
        <os>
            <type arch='x86_64'>hvm</type><!-- If the architecture of the server is ARM 64-bit, set arch to aarch64.  -->
            <boot dev='hd'/>
        </os>
        <clock sync="localtime"/>
        <on_poweroff>destroy</on_poweroff>
        <on_reboot>restart</on_reboot>
        <on_crash>restart</on_crash>
        <devices>
            <emulator>/usr/bin/qemu-kvm</emulator><!-- Configure a KVM path based on the operating system. For example, the KVM path for Ubuntu is /usr/bin/kvm.  -->
            <disk type='file' device='disk'><!-- Specify the type parameter based on the image format. Set type to qcow2 if the image is in the QCOW2 format, and set type to vpc if the image is in the VHD format.  -->
                <driver name='qemu' type='qcow2' cache='none' dataplane='on' io='native'/> <!-- If you want to create a snapshot in the QCOW2 format, disable dataplane.  -->
                <source file='path'/> <!-- Enter the absolute path of the Alibaba Cloud Linux 3 image.  -->
                <target dev='vda' bus='virtio'/>
            </disk>
            <!-- Add information about the seed.img boot image.  -->
            <disk type='file' device='disk'>
                <driver name='qemu' type='raw'/>
                <source file='/path/to/your/seed.img'/> <!-- Enter the absolute path of the seed.img boot image.  -->
                <target dev='vdb' bus='virtio'/>
            </disk>
            <interface type='network'>
                <source network='default'/>
                <model type='virtio'/>
            </interface>
            <console type='pty'>
                <target type='virtio' port='0'/>
            </console>
            <video>
                <model type='cirrus' vram='9216' heads='1'/>
                <alias name='video0'/>
            </video>
            <input type='tablet' bus='usb'/>
            <input type='mouse' bus='ps2'/>
            <graphics type='vnc' port='-1' autoport='yes'/>
        </devices>
    </domain>

    Alibaba Cloud Linux 2

    <domain type='kvm'>
        <name>alinux2</name>
        <memory>1048576</memory> <!-- Set the memory size to 1 GB.  -->
        <vcpu>1</vcpu>
        <os>
            <type arch='x86_64'>hvm</type>
            <boot dev='hd'/>
        </os>
        <clock sync="localtime"/>
        <on_poweroff>destroy</on_poweroff>
        <on_reboot>restart</on_reboot>
        <on_crash>restart</on_crash>
        <devices>
            <emulator>/usr/bin/qemu-kvm</emulator><!-- Configure a KVM path based on the operating system. For example, the KVM path for Ubuntu is /usr/bin/kvm. -->
            <disk type='file' device='disk'><!-- Specify the type parameter based on the image format. Set type to qcow2 if the image is in the QCOW2 format, and set type to vpc if the image is in the VHD format.  -->
                <driver name='qemu' type='qcow2' cache='none' dataplane='on' io='native'/> <!-- If you want to create a snapshot in the QCOW2 format, disable dataplane.  -->
                <source file='path'/> <!-- Enter the absolute path of the Alibaba Cloud Linux 2 image.  -->
                <target dev='vda' bus='virtio'/>
            </disk>
            <!-- Add information about the seed.img boot image.  -->
            <disk type='file' device='disk'>
                <driver name='qemu' type='raw'/>
                <source file='/path/to/your/seed.img'/> <!-- Enter the absolute path of the seed.img boot image.  -->
                <target dev='vdb' bus='virtio'/>
            </disk>
            <interface type='network'>
                <source network='default'/>
                <model type='virtio'/>
            </interface>
            <console type='pty'>
                <target type='virtio' port='0'/>
            </console>
            <video>
                <model type='cirrus' vram='9216' heads='1'/>
                <alias name='video0'/>
            </video>
            <input type='tablet' bus='usb'/>
            <input type='mouse' bus='ps2'/>
            <graphics type='vnc' port='-1' autoport='yes'/>
        </devices>
    </domain>
  2. Run the virsh command to start the KVM.

    Note

    By default, libvirt runs as a non-root user. Ensure that this user has permissions to manage the image files and their parent directories.

    Alibaba Cloud Linux 3

    sudo virsh define alinux3.xml
    virsh start <KVMName>   # Enter the name of the KVM. You can run the sudo virsh list --name command to query the name of the KVM.

    Alibaba Cloud Linux 2

    sudo virsh define alinux2.xml
    sudo virsh start <KVMName>    # Enter the name of the KVM. You can run the sudo virsh list --name command to query the name of the KVM.

Run the qemu-kvm command to start the KVM

Append the following parameter to the qemu-kvm command:

-drive file=/path/to/your/seed.img,if=virtio,format=raw
  • /path/to/your/seed.img: Replace with the actual path of your seed.img file.

  • if=virtio: Uses the virtio interface for the virtual disk.

  • format=raw: Specifies the RAW disk image format.

Example:

sudo /usr/libexec/qemu-kvm -drive file=/home/ecs-user/seed/seed.img,if=virtio,format=raw

Use the virt-manager graphical interface to start the KVM

Add the absolute path of your seed.img boot image to the KVM configuration file before starting the KVM.

What to do next

After the KVM starts, log on with the username and password specified in the user-data configuration file.

Note

To log on with an SSH key pair, add the public key to the cloud-init configuration file.

References

  • cloud-init automatically initializes Linux virtual machines at boot — configuring the hostname, network, and software packages.

  • libvirt, qemu-kvm, and virt-manager are commonly used KVM management tools. Red Hat documentation.