Centos7下通过virt-p2v虚拟化windows Server 2008R2

本文介绍如何将Windows Server 2008 R2通过P2V方式迁移到虚拟环境中,并详细讲解了如何手动添加virtio驱动以提高性能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

环境说明

virt-p2v:Centos7.2

virt-p2v client:Windows Server 2008 R2

virt-p2v version:1.28.1

virt-v2v version:1.28.1

配置说明

         在windows server 2008r2下的虚拟化转换工作与 Centos7下通过virt-p2v虚拟化Centos7服务器步骤相同,只是windows server 2008 R2不支持virtio,在windows下需要

另行添加virtio驱动,在windows下virtio驱动主要是网卡以及硬盘的驱动,这里我们需要virtio-win.iso文件,这个可以在百度里面去找到。下面我们来看看如何进行修改。


       我们首先看看在进行p2v完成后,同样会形成一个xml文件,如下

<!--
WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE
OVERWRITTEN AND LOST. Changes to this xml configuration should be made using:
  virsh edit windows2008-vmware
or other application using the libvirt API.
-->

<domain type='kvm'>
  <name>windows2008-vmware</name>
  <uuid>2977ef26-f7e7-4cbc-a264-0f4bad58d980</uuid>
  <memory unit='KiB'>4194304</memory>
  <currentMemory unit='KiB'>4194304</currentMemory>
  <vcpu placement='static'>1</vcpu>
  <os>
    <type arch='x86_64' machine='pc-i440fx-rhel7.2.0'>hvm</type>
    <boot dev='hd'/>
  </os>
  <features>
    <acpi/>
    <apic/>
  </features>
  <clock offset='utc'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>restart</on_crash>
  <devices>
    <emulator>/usr/libexec/qemu-kvm</emulator>
    <disk type='volume' device='disk'>
      <driver name='qemu' type='raw' cache='none'/>
      <source pool='pool-1' volume='windows2008-vmware-sda'/>
      <target dev='hda' bus='ide'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/root/virtio-win-1.7.2.iso'/>
      <target dev='hdb' bus='ide'/>
      <readonly/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    </disk>
    <controller type='usb' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
    </controller>
    <controller type='pci' index='0' model='pci-root'/>
    <controller type='ide' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
    </controller>
    <interface type='network'>
      <mac address='00:0c:29:42:28:bd'/>
      <source network='vdsm-ovirtmgmt'/>
      <model type='rtl8139'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
    <serial type='pty'>
      <target port='0'/>
    </serial>
    <console type='pty'>
      <target type='serial' port='0'/>
    </console>
    <input type='tablet' bus='usb'/>
    <input type='mouse' bus='ps2'/>
    <input type='keyboard' bus='ps2'/>
    <graphics type='vnc' port='-1' autoport='yes'/>
    <video>
      <model type='cirrus' vram='16384' heads='1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </video>
    <memballoon model='virtio'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </memballoon>
  </devices>
</domain>

我们可以看见其中硬盘以及网卡的总线都是IDE总线,硬盘hda是系统盘,如果这里修改为virtio总线的话,那么系统就无法找到启动盘,无法进行启动,所以我们只能在新添加

的硬盘里面使用virtio,以及修改网卡的总线为virtio总线。

首先我们进入虚拟化完成的windows server 2008 r2中看看设备管理器中网卡及硬盘:




因为系统盘我们无法修改驱动,所以我们先修改网卡的总线为virtio,编辑xml内容如下

 <interface type='network'>
      <mac address='00:0c:29:42:28:bd'/>
      <source network='vdsm-ovirtmgmt'/>
      <model type='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>

重启vm后,我们可以查看到需要新添加网卡驱动。

我们将下载好的virtio-win.iso文件添加至vm中

#virsh attach-disk windows2008-vmware /root/virtio-win-1.7.2.iso hdb --sourcetype block --driver qemu --subdriver raw --type cdrom

更新驱动在/NetKVM/2k8R2/amd64目录下可以找到该驱动,安装完成驱动后,我们可以看见网卡驱动已经变为virtio的驱动了



下面我们来添加新硬盘为virtio总线的

首先创建img文件

#qemu-img create disk2.img -f qcow2 -s 20G

添加以下内容至xml文件中:

<disk type='file' device='disk'>
      <driver name='qemu' type='raw' cache='none'/>
      <source file='/home/disk2.img'/>
      <target dev='vda' bus='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </disk>

或者执行

#virsh attach-disk windows2008 /home/disk2.img vda

这时候我们重启vm,会提示新添加scsi驱动,我们选择virstor/2k8R2/amd64内的驱动进行安装后,如下图所示,就出现了virtio的scsi控制器以及硬盘








评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值