Rate This Document
Findability
Accuracy
Completeness
Readability

Creating a VM Using an Existing QCOW2 Image

If there is an existing QCOW2 image, you can use it to create a VM. For example, you can use the QCOW2 image from the openEuler repository. If another image is used, change the image names as required in the following steps.

  1. Upload the image to the /home/kvm/images directory and decompress it.
    cd /home/kvm/images/
    xz -d openEuler-22.03-LTS-SP3-aarch64.qcow2.xz
  2. Create a VM named as vm2 and allocate four vCPUs, 8 GB memory, and 40 GB drive space to it. Run the following command to create a VM:
    1
    virt-install --name=vm2 --vcpus=4 --ram=8192  --disk path=/home/kvm/images/openEuler-22.03-LTS-SP3-aarch64.qcow2,format=qcow2,size=40,bus=virtio --boot hd --network network=default --force --autostart
    
    • The drive space allocated to the VM cannot be less than the virtual drive size of the QCOW2 image. Otherwise, the VM fails to be created. Run the following command to query the virtual drive size of the image. In the command, openEuler-22.03-LTS-SP3-aarch64.qcow2 indicates the image file name. In the command output, virtual size indicates the virtual drive size of the image.
      qemu-img info openEuler-22.03-LTS-SP3-aarch64.qcow2

    • The partition of the QCOW2 image is fixed. If the drive space allocated to the VM is greater than the virtual drive size of the QCOW2 image, you need to perform manual partitioning or expand the capacity of the existing partitions before using the extra space.