Win10系统通过VMware安装Centos7,部署KVM安装WIN7虚拟机

Win10系统通过VMware安装Centos7,部署KVM安装WIN7虚拟机

一、环境准备
  • 本机Win10系统

  • 下载Centos7镜像,Win7镜像,VMWare软件,XShell软件,VNCViewer

二、安装Centos7系统
  • Win10安装VMWare

  • VMWare安装Centos7镜像

  • XShell登录Centos7

  • xftp将Win7镜像传入Centos7中

三、Centos7里部署KVM
1、验证是否支持虚拟化
[root@yzl ~]# egrep '(vmx|svm)' --color=always /proc/cpuinfo 
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc eagerfpu pni pclmulqdq vmx ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm ssbd ibrs ibpb stibp tpr_shadow vnmi ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid xsaveopt arat spec_ctrl intel_stibp flush_l1d arch_capabilities
。。。
# 可以看见带有vmx,说明支持vmx虚拟化
  • 可以看见带有vmx,说明支持vmx虚拟化。如果没有这个输出,说明你没有开启vmx虚拟化支持,所以,你需要在VMware虚拟机设置里,找到虚拟化引擎,勾选虚拟化Intel,就可以了。
2、装包
[root@yzl ~]# yum -y install kvm python-virtinst libvirt tunctl bridge-utils virt-manager qemu-kvm-tools virt-viewer virt-v2v libguestfs-tools
# 安装VNC,后面连接安装用
[root@yzl ~]# yum -y install vnc-server     
[root@yzl ~]# yum -y install tigervnc-server
3、启动libvirtd服务
[root@yzl ~]# /sbin/service libvirtd restart
[root@yzl ~]# ln -s /usr/libexec/qemu-kvm /usr/bin/qemu-kvm
四、KVM安装WIN7虚拟机
1、安装virtio驱动
[root@yzl ~]# wget https://fedorapeople.org/groups/virt/virtio-win/virtio-win.repo -O /etc/yum.repos.d/virtio-win.repo
[root@yzl ~]# yum install virtio-win -y	# 网络yum源安装,时间较慢
2、搭建虚拟机
  • 创建一个虚拟机磁盘
[root@yzl ~]# qemu-img create -f qcow2 win7.img 20G	
Formatting 'win7.img', fmt=qcow2 size=21474836480 encryption=off cluster_size=65536 lazy_refcounts=off 
[root@yzl ~]# echo $?
0

  • 创建虚拟机
[root@yzl ~]# virt-install -n win7 --vcpus=2 --ram=1024 --os-type=windows --os-variant=win2k12 -c /root/GHOST_WIN7_X64_2006C.iso --disk path=/usr/share/virtio-win/virtio-win-0.1.171_amd64.vfd,device=floppy --disk path=/root/win7.img,format=qcow2,bus=virtio --graphics vnc,listen=0.0.0.0 --noautoconsole
# 命令解释
# virt-install	# 安装命令
# -n win7	 	# 虚拟机命名
# --vcpus=2 	# 分配两个CPU给这台机器
# --ram=1024 	# 分配1024内存
# --os-type=windows   # 类型是windows
# --os-variant=win2k12 -c /root/GHOST_WIN7_X64_2006C.iso  #指向win7镜绝对路径
# --disk path=/usr/share/virtio-win/virtio-win-0.1.171_amd64.vfd,device=floppy   #指向驱动virtio-win-0.1.126_amd64
# --disk path=/root/win7.img,format=qcow2,bus=virtio --graphics vnc,listen=0.0.0.0  #指向虚拟磁盘win7.img,默认端口5900
# --noautoconsole

  • 第一次安装,可能会有报错
[root@yzl ~]# virt-install -n win7 --vcpus=2 --ram=1024 --os-type=windows --os-variant=win2k12 -c /root/GHOST_WIN7_X64_2006C.iso --disk path=/usr/share/virtio-win/virtio-win-0.1.171_amd64.vfd,device=floppy --disk path=/root/win7.img,format=qcow2,bus=virtio --graphics vnc,listen=0.0.0.0 --noautoconsole
WARNING  /root/win7.img may not be accessible by the hypervisor. You will need to grant the 'qemu' user search permissions for the following directories: ['/root']

Starting install...
ERROR    Cannot access storage file '/root/win7.img' (as uid:107, gid:107): Permission denied
Domain installation does not appear to have been successful.
If it was, you can restart your domain by running:
  virsh --connect qemu:///system start win7
otherwise, please restart your installation.
  • 提示无法访问,权限被拒绝。解决办法:更改/etc/libvirt/qemu.conf可以解决问题。取消注释用户/组以root用户身份运行。
[root@yzl ~]# vim /etc/libvirt/qemu.conf	# 注释掉用户/组以root用户身份运行 两行
# 修改完后,配置文件内容如下:
[root@yzl ~]# grep -v "^#" /etc/libvirt/qemu.conf | grep -v "^$"
user = "root"
group = "root"
[root@yzl ~]# systemctl restart libvirtd	# 修改后重启虚拟化服务
  • 再次执行,安装成功后,会有如下提示
[root@yzl ~]# virt-install -n win7 --vcpus=2 --ram=1024 --os-type=windows --os-variant=win2k12 -c /root/GHOST_WIN7_X64_2006C.iso --disk path=/usr/share/virtio-win/virtio-win-0.1.171_amd64.vfd,device=floppy --disk path=/root/win7.img,format=qcow2,bus=virtio --graphics vnc,listen=0.0.0.0 --noautoconsole

Starting install...
Domain installation still in progress. You can reconnect to 
the console to complete the installation process.
[root@yzl ~]# echo $?
0
[root@yzl ~]# virsh list --all
 Id    Name                           State
----------------------------------------------------
 -     win7                           shut off

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值