Rate This Document
Findability
Accuracy
Completeness
Readability

Creating a VM

  1. Start the libvirtd service and enable the libvertd service to automatically start upon system startup.
    1
    2
    systemctl start libvirtd
    systemctl enable libvirtd
    
  2. 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 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
      

    3. Query the storage pool information.
      1
      2
      virsh pool-info StoragePool
      virsh pool-list
      

  3. Create the drive space for the virtual machine (VM).
    1. 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.

      1
      virsh vol-create-as --pool StoragePool --name 1.img --capacity 50G --allocation 1G --format qcow2
      
    2. Check volume information.
      1
      virsh vol-info /home/kvm/images/1.img
      

  4. Create a VM.
    1. 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
      
    2. Installing the OS on the VM.

    3. 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.

    4. After the installation is complete, the login prompt is displayed.