Creating a VM
- Start the libvirtd service and enable the libvertd service to automatically start upon system startup.
1 2
systemctl start libvirtd systemctl enable libvirtd
- 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 directory created. Create a folder-based storage pool, activate it, and enable 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 virtual machine (VM).
- Create a volume.
For example, the volume named is 1.img, the storage pool is StoragePool, the volume capacity is 50 GB, the initially allocated capacity is 1 GB, the file format is qcow2, and the drive file format is qcow2.
1virsh vol-create-as --pool StoragePool --name 1.img --capacity 50G --allocation 1G --format qcow2
- Check volume information.
1virsh vol-info /home/kvm/images/1.img

- Create a volume.
- Create a VM.
- Create VM vm1, and allocate four CPUs, 8 GB memory, and 1.img drive space to it. Copy the .iso file to a non-root directory, and install CentOS 7.6.
1 2
brctl addbr br1 virt-install --name=vm1 --vcpus=4 --ram=8192 --disk path=/home/kvm/images/1.img,format=qcow2,size=50,bus=virtio --cdrom /xxx/CentOS-7-aarch64-Everything-1810.iso --network bridge=br1,model=virtio --force --autostart
- Installing the OS on the VM.
- Configure all items that contain !. Input the serial numbers corresponding to the items and configure them as prompted. Then, press b to start the installation.

- After the installation is complete, the login prompt is displayed.
- Create VM vm1, and allocate four CPUs, 8 GB memory, and 1.img drive space to it. Copy the .iso file to a non-root directory, and install CentOS 7.6.
Parent topic: Installing VMs

