#安装依赖

sudo apt install -y qemu qemu-kvm libvirt-daemon libvirt-clients bridge-utils virt-manager

#创建qcow2镜像

qemu-img create -f qcow2 hkcos.qcow2 10G

#将ISO镜像文件加载到虚拟机中

virt-install --name hkcossp4 --ram 2048 --cdrom=/opt/iso/CentOS-7.6-hik-r5-patch3.iso --disk path=/opt/iso/hkcos.qcow2,format=qcow2 --graphics vnc,listen=0.0.0.0 --noautoconsole --os-type=linux --os-variant=rhel7 --check all=off

#查看虚拟机

virsh list


#查看虚拟仓VNC端口

virsh vncdisplay hkcossp4

#通过VNC远程连接

vncviewer 127.0.0.1:0

#qcow2  转 raw 

qemu-img convert -f qcow2  hkcos.qcow2 -O  raw hkcos.raw

#raw 转 qcow2  

qemu-img convert -f qcow2  hkcos.raw  -O  raw  hkcos.qcow2

 


古之善为士者,微妙玄通,深不可识