The premise condition

  • Complete KVM environment
  • Centos image


  • Step 1: Create a disk
qemu-img create -f qcow2 centos_kvm1.qcow2 16G
Copy the code
  • Step 2: Install the VM
virt-install \
--virt-type=kvm \
--name=centos-kvm \
--hvm \
--vcpus=1 \
--memory=1024 \
--cdrom=/srv/kvm/CentOS-7-x86_64-Minimal-1810.iso \
--disk path=/srv/kvm/centos_kvm1.qcow2,size=16,format=qcow2 \
--graphics vnc,password=kvm,listen=::,port=5911 \
--network bridge=virbr0 \
--autostart \
Copy the code

After the installation is successful, use VNC Viewer on any desktop device that can access the KVM host to enter YourIp:5911. Enter the password to enter the KVM to enter the VM and continue the installation.

  • The third step, basic operation
virsh list --all           # View all running and not running VMS
virsh list                 # View the running VIRTUAL machine
virsh dumpxml vm-name      # View the KVM VM configuration file
virsh start vm-name        # Start the KVM VM
virsh shutdown vm-name     # Normal shutdown

virsh destroy vm-name      Forcibly shut down virtual machine (equivalent to unplugging physical machine directly)
virsh undefine vm-name     Delete the vm configuration file

virsh define file-name.xml Define a VM based on the configuration file
virsh suspend vm-name      # suspend, terminate
virsh resumed vm-name      # Restore suspended VIRTUAL machines
virsh autostart vm-name    # Start vm after startupVirsh console < Vm name ># Connect to the VM
Copy the code

Install Expand the directory

- Name Specifies the VM name. - Memory Specifies the memory size. - vcpus Specifies the number of CPU cores allocated, which is the same as the maximum number of physical CPUS. - Disk specifies the VM image, and size specifies the size allocated, in G. - Network Indicates the network type. The default value is bridge. - Accelerate - Cdrom Specifies the installation image ISO. - VNC Enable VNC remote management. This function is required in most installation systems. - vncport Specifies the VNC monitoring port. The default port number is 5900. The port number must be unique. - Vnclisten specifies the VNC binding IP address. The default binding IP address is - OS-type = Linux, Windows - OS-variant =rhel6 --name Specifies the VM name. -- RAM Specifies the VM memory size, in MB. --vcpus Specifies the number of CPU cores allocated to the VM. The maximum number of CPU cores is the same as that of a physical machine. - N/A VNC Enable VNC remote management. - -vncport Specifies the VNC monitoring port. The default port number is 5900. The port number must be unique. - -vnclisten Specifies the VNC binding IP address. The default binding IP address is Bridge =br0 specifies the name of the bridge nic. - OS-type = Linux, Windows - OS-variant = rHEL7.2 -- Disk Specifies the disk storage location of the VM. The initial disk size is in GB. --location Specifies the installation path, such as the path of the CD-ROM image file. There may be a lot of interaction during the new virtual machine installation, such as setting the language, initializing the root password, and so on. The # graphics option is used to configure graphical interaction, which can be linked using VNC (a remote desktop software). # Our column uses the command line installation, so set it to None, but specify terminal information with the --extra-args option, # so that interactive information from the installation is printed to the current console. Extra-args sets different extra options depending on the installation modeCopy the code


  • Kvm-virsh Learning (VM Disk Management)
  • Install the Ubuntu 18.04 Server on KVM VMS