配置 vnc
vim /etc/libvirt/qemu.conf
去掉下面的注释
vnc_listen = "0.0.0.0"
创建虚拟机
virt-install --name=vm1 --ram=1024 --vcpus=2 --disk path=/home/kvm/images/vm1.img,size=10 --cdrom /dev/cdrom --graphics vnc,password=123456,port=5910, --network bridge=br0,model=virtio --force --autostart
表示创建一个名称为vm1的虚拟机,其内存为1024M,分配2核CPU,磁盘位置在/home/kvm/images/vm1.img,size=10是磁盘大小,然后指定cdrom位置,配置图形安装,使用vnc,vnc连接密码是123456 ,端口是5910 网络使用桥接方式,创建完立即启动。
[root@kvm ~]# virt-install --name=vm1 --ram=1024 --vcpus=2 --disk path=/home/kvm/images/vm1.img,size=10 --cdrom /dev/cdrom --graphics vnc,password=123456,port=5910, --network bridge=br0,model=virtio --force --autostart
WARNING The requested volume capacity will exceed the available pool space when the volume is fully allocated. (10240 M requested capacity > 5270 M available)
WARNING The requested volume capacity will exceed the available pool space when the volume is fully allocated. (10240 M requested capacity > 5270 M available)
WARNING The requested volume capacity will exceed the available pool space when the volume is fully allocated. (10240 M requested capacity > 5270 M available)
WARNING The requested volume capacity will exceed the available pool space when the volume is fully allocated. (10240 M requested capacity > 5270 M available)
WARNING The requested volume capacity will exceed the available pool space when the volume is fully allocated. (10240 M requested capacity > 5270 M available)
WARNING The requested volume capacity will exceed the available pool space when the volume is fully allocated. (10240 M requested capacity > 5270 M available)
WARNING The requested volume capacity will exceed the available pool space when the volume is fully allocated. (10240 M requested capacity > 5270 M available)
WARNING The requested volume capacity will exceed the available pool space when the volume is fully allocated. (10240 M requested capacity > 5270 M available)
WARNING The requested volume capacity will exceed the available pool space when the volume is fully allocated. (10240 M requested capacity > 5270 M available)
Starting install...
WARNING The requested volume capacity will exceed the available pool space when the volume is fully allocated. (10240 M requested capacity > 5270 M available)
Allocating 'vm1.img' | 10 GB 00:00
Creating domain... | 0 B 00:00
Cannot open display:
Run 'virt-viewer --help' to see a full list of available command line options
Domain installation still in progress. You can reconnect to
the console to complete the installation process.
通过vnc连接
我们可以在Chrome商店,安装vnc扩展程序,然后连接
安装的话正常安装就可以
附,创建一个 kvm 格式的虚拟机
virt-install \
--hvm \
--name=centos7 \
--ram=1024 \
--vcpus=1 \
--cdrom=/opt/ios/CentOS-7-x86_64-Minimal-1611.iso \
--virt-type=kvm \
--disk path=/home/kvm/images/vm-centos-7.img,size=20 \
--network network=default \
--network bridge=br0,model=virtio \
--accelerate \
--graphics vnc,port=5950,password=123456 \
--force \
--autostart