KVM 一条命令创建VM虚拟机

virt-install  --name 主机名称  --ram 内存大小(Kb)  --disk path=img路径(需要kvm有权限操作目录,自动创建),size=vm磁盘大小(Gb)  --vcpus 内核个数  --os-type linux  --os-variant rhel7  --network bridge=br0(网卡名称)  --graphics none  --console pty,target_type=serial  --location=/home/kvm/CentOS-7.7-x86_64-Minimal-1908.iso(镜像路径)  --extra-args 'console=ttyS0,115200n8 serial'(console配置)

举例:

virt-install  --name VM-name  --ram 16384  --disk path=/kvm/images/VM-name.img,size=500  --vcpus 8  --os-type linux  --os-variant rhel7  --network bridge=br0  --graphics none  --console pty,target_type=serial  --location=/home/kvm/CentOS-7.9-xxxxxx.iso  --extra-args 'console=ttyS0,115200n8 serial'