Rate This Document
Findability
Accuracy
Completeness
Readability

Creating a VM

Create a storage pool and use an ISO image to create a VM. This section uses the openEuler 22.03 SP3 image as an example to create a VM. If another image is used, change the image names as required in the following steps.

  1. Create a storage pool.
    1. Create a storage pool directory and configure operation permissions for the directory.
      1
      2
      3
      mkdir -p /home/kvm/images
      chown root:root /home/kvm/images
      chmod 755 /home/kvm/images
      
    2. Define a storage pool and bind it to the storage pool directory. Create a folder-based storage pool, activate it, and set it to start upon system startup.
      1
      2
      3
      4
      virsh pool-define-as StoragePool --type dir --target /home/kvm/images
      virsh pool-build StoragePool
      virsh pool-start StoragePool
      virsh pool-autostart StoragePool
      
    3. Query the storage pool information.
      1
      2
      virsh pool-info StoragePool
      virsh pool-list
      

  2. Create the drive space for the VM.
    1. Create a volume.
      Create a volume named 1.img in the storage pool named StoragePool.

      The drive file format must be qcow2.

      1
      virsh vol-create-as --pool StoragePool --name 1.img --capacity 50G --allocation 1G --format qcow2
      

      In the preceding command, the capacity of the created volume is 50 GB, the initially allocated capacity is 1 GB, and the file format is qcow2. You can change the volume size and configurations as required.

    2. Check volume information.
      1
      virsh vol-info /home/kvm/images/1.img
      

  3. Create a VM.
    1. Create a VM named vm1. Copy the openEuler-22.03-LTS-SP3-aarch64-dvd.iso file to the /home directory (not the /root directory) and run the following command to create a VM:
      1
      virt-install --name=vm1 --vcpus=4 --ram=8192 --disk path=/home/kvm/images/1.img,format=qcow2,size=50,bus=virtio --location /home/openEuler-22.03-LTS-SP3-aarch64-dvd.iso --network network=default --nographics
      
      • In the preceding command, four vCPUs and 8 GB memory are allocated to the VM, and 1.img is used as the system volume. You can modify the VM specifications and configurations as required.
      • After running the command, wait for a while, and install the OS on the VM.
    2. During the OS installation on the VM:
      1. If the status of a configuration item is Processing..., the configuration item is being automatically configured. Enter r and press Enter to refresh the status.

      2. After the automatic configuration is complete, enter the sequence number of an option marked with !, press Enter, and manually configure the option as prompted.

      3. After all configurations are complete, enter b and press Enter to start the installation.

    3. After the OS installation is complete, press Enter to restart the server. Log in to the system after the restart.