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.
- Create a storage pool.
- 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
- 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
- Query the storage pool information.
1 2
virsh pool-info StoragePool virsh pool-list

- Create a storage pool directory and configure operation permissions for the directory.
- Create the drive space for the VM.
- Create a volume.
Create a volume named 1.img in the storage pool named StoragePool.
The drive file format must be qcow2.
1virsh 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.
- Check volume information.
1virsh vol-info /home/kvm/images/1.img

- Create a volume.
- Create a VM.
- 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:
1virt-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.
- During the OS installation on the VM:
- 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.

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

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

- 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.
- After the OS installation is complete, press Enter to restart the server. Log in to the system after the restart.

- 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:
Parent topic: Running and Verification