创建虚拟机

image.pngimage.png
image.pngimage.pngimage.pngimage.pngimage.pngimage.pngimage.pngimage.pngimage.png

问题1:提示无法连接服务器

双击创建好的虚拟机,启动报错
image.png
查看日志
image.pngimage.png

解决方法

执行下面的命令:

  1. modprobe -r kvm_intel
  2. modprobe kvm_intel nested=1
  3. cat /sys/module/kvm_intel/parameters/nested

其中如果执行到第二个命令失败
modprobe: ERROR: could not insert’kvm_intel’: Operation not supported

需要将vmware 开启VM的硬件cpu虚拟化功能
image.png
开启后再次执行

  1. modprobe -r kvm_intel
  2. modprobe kvm_intel nested=1
  3. cat /sys/module/kvm_intel/parameters/nested

image.png
编辑配置文件:

  1. echo "options kvm_intel nested=1" >> /etc/modprobe.d/modprobe.conf

查看虚拟机启动命令行,下面以我的环境中vmid为100的虚拟机为列:

  1. # qm showcmd 100

image.png找到-cpu ‘kvm64,enforce,hv_ipi,hv_relaxed,hv_reset,hv_runtime,hv_spinlocks=0x1fff,hv_stimer,hv_synic,hv_time,hv_vapic,hv_vpindex,+kvm_pv_eoi,+kvm_pv_unhalt,+lahf_lm,+sep’在enforce前面加上+vmx,表示开启vmx

修改后为

  1. /usr/bin/kvm -id 100 -name win8 -chardev 'socket,id=qmp,path=/var/run/qemu-server/100.qmp,server,nowait' -mon 'chardev=qmp,mode=control' -chardev 'socket,id=qmp-event,path=/var/run/qmeventd.sock,reconnect=5' -mon 'chardev=qmp-event,mode=control' -pidfile /var/run/qemu-server/100.pid -daemonize -smbios 'type=1,uuid=17d48c81-1b0f-42db-b7e6-f17d1f799740' -smp '4,sockets=1,cores=4,maxcpus=4' -nodefaults -boot 'menu=on,strict=on,reboot-timeout=1000,splash=/usr/share/qemu-server/bootsplash.jpg' -vnc unix:/var/run/qemu-server/100.vnc,password -no-hpet -cpu 'kvm64,+vmx,enforce,hv_ipi,hv_relaxed,hv_reset,hv_runtime,hv_spinlocks=0x1fff,hv_stimer,hv_synic,hv_time,hv_vapic,hv_vpindex,+kvm_pv_eoi,+kvm_pv_unhalt,+lahf_lm,+sep' -m 4096 -device 'pci-bridge,id=pci.1,chassis_nr=1,bus=pci.0,addr=0x1e' -device 'pci-bridge,id=pci.2,chassis_nr=2,bus=pci.0,addr=0x1f' -device 'vmgenid,guid=a483e042-8384-4e78-9f20-fcd274e32ac5' -device 'piix3-usb-uhci,id=uhci,bus=pci.0,addr=0x1.0x2' -device 'usb-tablet,id=tablet,bus=uhci.0,port=1' -device 'VGA,id=vga,bus=pci.0,addr=0x2' -device 'virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3' -iscsi 'initiator-name=iqn.1993-08.org.debian:01:eb1bebfd7aff' -drive 'file=/var/lib/vz/template/iso/Windows_8_Enterprise_64_.iso,if=none,id=drive-ide2,media=cdrom,aio=threads' -device 'ide-cd,bus=ide.1,unit=0,drive=drive-ide2,id=ide2,bootindex=200' -device 'virtio-scsi-pci,id=scsihw0,bus=pci.0,addr=0x5' -drive 'file=/dev/pve/vm-100-disk-0,if=none,id=drive-scsi0,format=raw,cache=none,aio=native,detect-zeroes=on' -device 'scsi-hd,bus=scsihw0.0,channel=0,scsi-id=0,lun=0,drive=drive-scsi0,id=scsi0,bootindex=100' -netdev 'type=tap,id=net0,ifname=tap100i0,script=/var/lib/qemu-server/pve-bridge,downscript=/var/lib/qemu-server/pve-bridgedown,vhost=on' -device 'virtio-net-pci,mac=C2:23:C2:35:AD:0A,netdev=net0,bus=pci.0,addr=0x12,id=net0,bootindex=300' -rtc 'driftfix=slew,base=localtime' -machine 'type=pc+pve0' -global 'kvm-pit.lost_tick_policy=discard'

关闭虚拟机:

  1. qm stop 100

输入以下代码:

  1. /usr/bin/kvm -id 100 -name win8 -chardev 'socket,id=qmp,path=/var/run/qemu-server/100.qmp,server,nowait' -mon 'chardev=qmp,mode=control' -chardev 'socket,id=qmp-event,path=/var/run/qmeventd.sock,reconnect=5' -mon 'chardev=qmp-event,mode=control' -pidfile /var/run/qemu-server/100.pid -daemonize -smbios 'type=1,uuid=17d48c81-1b0f-42db-b7e6-f17d1f799740' -smp '4,sockets=1,cores=4,maxcpus=4' -nodefaults -boot 'menu=on,strict=on,reboot-timeout=1000,splash=/usr/share/qemu-server/bootsplash.jpg' -vnc unix:/var/run/qemu-server/100.vnc,password -no-hpet -cpu 'kvm64,+vmx,enforce,hv_ipi,hv_relaxed,hv_reset,hv_runtime,hv_spinlocks=0x1fff,hv_stimer,hv_synic,hv_time,hv_vapic,hv_vpindex,+kvm_pv_eoi,+kvm_pv_unhalt,+lahf_lm,+sep' -m 4096 -device 'pci-bridge,id=pci.1,chassis_nr=1,bus=pci.0,addr=0x1e' -device 'pci-bridge,id=pci.2,chassis_nr=2,bus=pci.0,addr=0x1f' -device 'vmgenid,guid=a483e042-8384-4e78-9f20-fcd274e32ac5' -device 'piix3-usb-uhci,id=uhci,bus=pci.0,addr=0x1.0x2' -device 'usb-tablet,id=tablet,bus=uhci.0,port=1' -device 'VGA,id=vga,bus=pci.0,addr=0x2' -device 'virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3' -iscsi 'initiator-name=iqn.1993-08.org.debian:01:eb1bebfd7aff' -drive 'file=/var/lib/vz/template/iso/Windows_8_Enterprise_64_.iso,if=none,id=drive-ide2,media=cdrom,aio=threads' -device 'ide-cd,bus=ide.1,unit=0,drive=drive-ide2,id=ide2,bootindex=200' -device 'virtio-scsi-pci,id=scsihw0,bus=pci.0,addr=0x5' -drive 'file=/dev/pve/vm-100-disk-0,if=none,id=drive-scsi0,format=raw,cache=none,aio=native,detect-zeroes=on' -device 'scsi-hd,bus=scsihw0.0,channel=0,scsi-id=0,lun=0,drive=drive-scsi0,id=scsi0,bootindex=100' -netdev 'type=tap,id=net0,ifname=tap100i0,script=/var/lib/qemu-server/pve-bridge,downscript=/var/lib/qemu-server/pve-bridgedown,vhost=on' -device 'virtio-net-pci,mac=C2:23:C2:35:AD:0A,netdev=net0,bus=pci.0,addr=0x12,id=net0,bootindex=300' -rtc 'driftfix=slew,base=localtime' -machine 'type=pc+pve0' -global 'kvm-pit.lost_tick_policy=discard'

image.png列出虚拟机:

  1. qm list

发现vmid为100的虚拟机状态已变更为running
image.png
进入该虚拟机,使用命令验证是否已开启vmx:

  1. #egrep "vmx|svm" /proc/cpuinfo

image.png至此,成功在PVE中开启了嵌套虚拟化

开启虚拟机

接着双击创建的虚拟机来进行系统安装
image.png

问题2:安装系统没有磁盘

解决方法

挂载磁盘驱动
image.png
安装系统时安装位置选择磁盘驱动,image.pngimage.pngimage.png