Alibaba Cloud Linux 3 images are available in various formats and have cloud-init built in. This topic describes how to use Alibaba Cloud Linux 3 images in an on-premises environment.
Background information
Alibaba Cloud Linux 3 images can run only on kernel-based virtual machines (KVMs). Alibaba Cloud Linux 3 images cannot directly start KVMs. You must configure a boot image.
In this topic, the on-premises operating system is Anolis OS. Alibaba Cloud Linux 3 is used to create a KVM, and cloud-init is used to initialize the system settings of the KVM. The NoCloud data source is used to create on-premises configuration files. After the configuration files are attached to the KVM as virtual disks, the KVM can be started. To download Anolis OS, go to the Anolis OS download page. For more information about cloud-init, see Cloud-init documentation on the official cloud-init website.
Step 1: Download an Alibaba Cloud Linux 3 image to your computer
You can download an Alibaba Cloud Linux 3 image to your computer from the Alibaba Cloud Linux 3 On-premise Image page. Alibaba Cloud Linux 3 images are available in the VHD or QCOW2 format.
Step 2: Obtain the seed.img boot image from your computer
You can use one of the following methods to obtain the seed.img image:
- Go to the Alibaba Cloud Linux 3 On-premise Image page and click seed.img to download the seed.img image.
The configurations in this image cannot be modified, which makes it less ideal for some scenarios. Make sure that you are familiar with the image before you use it.
- Perform the following operations to manually generate the seed.img image based on the NoCloud data source.
- In an on-premises directory, create two configuration files named
meta-data
anduser-data
. - Install the
cloud-utils
software package on your computer.yum install -y cloud-utils
- In the
seed
directory, run the following command to generate theseed.img
image:cloud-localds seed.img user-data meta-data
Step 3: Start the KVM
user-data
configuration file to log on to the KVM. - Use libvirt to start the KVM.
- Create a configuration file in the XML format on your computer. In this example, the file is named
alinux3.xml
and contains the following content. You can modify this file based on your requirements.<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, you must disable dataplane. --> <source file='path'/> <!-- Enter the absolute path of the Alibaba Cloud Linux 3 image. --> <target dev='vda' bus='virtio'/> </disk> <!-- Add the information of the seed.img 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 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>
- Run the
virsh
command to start the KVM. The following code shows sample commands.Note By default, libvirt is started by a common user. Make sure that common users have the permissions to manage image files and their paths.virsh define alinux3.xml virsh start KVMName # Enter the name of the KVM.
- Create a configuration file in the XML format on your computer. In this example, the file is named
- Run the
qemu-kvm
command to start the KVM. You must append the following parameter information to the command. Set thefile
parameter to the actual absolute path of the seed.img image.
For more information about how to configure and manage virtualization, see Configuring and managing virtualization.-drive file=/path/to/your/seed.img,if=virtio,format=raw
- Use the graphical interface (virt-manager) to start the KVM. Before you start the KVM, find the configuration file of the KVM on your computer and add the absolute path of the seed.img image to the configuration file.