https://www.cnblogs.com/songfucai/p/6710150.html

一、环境准备:
1、虚拟机磁盘镜像
2、系统安装盘(或 ISO镜像)
3、virtio-win-0.1.96_x86.vfd 软盘驱动

二、kvm中安装windows xp 系统的两种方式

1、在创建虚拟机的时候软盘加载virtio驱动

virt-install --name=windows-xp --ram 2048 --vcpus=2 \
--disk path=/home/KVM-template/windows-xp/windows.qcow2,bus=virtio,size=30,format=qcow2 \
--accelerate --cdrom /home/ISO/windows-xp-sp3.iso \
--vnc --vncport=6000 --vnclisten=0.0.0.0 --network bridge=br0 --force --autostart \
--disk path=/home/ISO/virtio-win-0.1.96_x86.vfd,device=floppy

或者

virt-install --virt-type kvm --name winxp3 --ram 1024 --os-type=windows --os-variant=winxp --disk path=/home/ISO/windowxp3.qcow2,format=qcow2,bus=virtio,cache=none --disk path=/home/ISO/virtio-win-0.1.96_x86.vfd,device=floppy --network bridge=br0,model=virtio --cdrom /home/ISO/windows-xp-sp3.iso --graphics vnc,listen=0.0.0.0 --noautoconsole

以上两个命令均可成功安装xp系统。

2、RAW格式的镜像磁盘安装xp
qcow2格式的磁盘安装windows xp的时候无法识别硬盘,但是raw格式的磁盘安装windows xp系统是可以正常识别硬盘的。如果不顾及磁盘性能的前提下,可以尝试用raw格式的磁盘进行windows系统安装。

qemu-img create -f raw xpde1.img 10G

总结:
1、XP的安装程序只支持从软盘加载驱动程序,因此需要一个软盘的镜像文件,在KVM启动的时候进行加载。
3、windows7在安装过程中,可以从光盘读取磁盘的驱动程序,因此只要挂载二个iso,模拟二个光驱即可,安装的iso指定序号为0、驱动的ISO指定序号为1。安装过程中,选择加载第二个光盘里的磁盘virtio驱动就可以了,这个ISO中也包含了网卡的virtio驱动。
4、如遇到某些设备的驱动安装不正常,可右击设备,选择属性,重新通过驱动盘安装驱动即可。


鹏鹏实际使用命令

virt-install --virt-type kvm --name pek101-33xp --ram 512 --os-type=windows --os-variant=winxp --disk path=/awdisk10111/vmdir/pek101-33xp.img,format=qcow2,bus=virtio,cache=none --disk path=/awdisk10111/nas/iso/virtio-win-0.1.160_x86.vfd,device=floppy --network bridge=br0,model=virtio --cdrom /awdisk10111/nas/iso/TinyXP.iso --graphics vnc,listen=0.0.0.0 --noautoconsole


virt-install --virt-type kvm --name pek101-33work --ram 512 --os-type=windows --os-variant=winxp --disk path=/awdisk10111/vmdir/pek101-33work.img,format=qcow2,bus=virtio,cache=none --disk path=/awdisk10111/nas/iso/virtio-win-0.1.160_x86.vfd,device=floppy --network bridge=br0,model=virtio --cdrom  /awdisk10111/nas/iso/cn_win_srv_2003_r2_enterprise_with_sp2_vl_cd1.iso --graphics vnc,listen=0.0.0.0 --noautoconsole

kvm配置实例

<domain type='kvm'>
  <name>pek101-33work</name>
  <uuid>09eb8c0d-7b64-4b1e-b871-e7d9028d5066</uuid>
  <memory unit='KiB'>524288</memory>
  <currentMemory unit='KiB'>524288</currentMemory>
  <vcpu placement='static'>1</vcpu>
  <os>
    <type arch='x86_64' machine='pc-i440fx-rhel7.0.0'>hvm</type>
    <boot dev='hd'/>
  </os>
  <features>
    <acpi/>
    <apic/>
    <hyperv>
      <relaxed state='on'/>
      <vapic state='on'/>
      <spinlocks state='on' retries='8191'/>
    </hyperv>
  </features>
  <cpu mode='custom' match='exact' check='partial'>
    <model fallback='allow'>Nehalem</model>
  </cpu>
  <clock offset='localtime'>
    <timer name='rtc' tickpolicy='catchup'/>
    <timer name='pit' tickpolicy='delay'/>
    <timer name='hpet' present='no'/>
    <timer name='hypervclock' present='yes'/>
  </clock>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>
  <pm>
    <suspend-to-mem enabled='no'/>
    <suspend-to-disk enabled='no'/>
  </pm>
  <devices>
    <emulator>/usr/libexec/qemu-kvm</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw' cache='none'/>
      <source file='/awdisk10111/vmdir/pek101-33work.img'/>
      <target dev='vda' bus='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
    </disk>
    <disk type='file' device='floppy'>
      <driver name='qemu' type='raw'/>
      <source file='/awdisk10111/nas/iso/virtio-win-0.1.160_x86.vfd'/>
      <target dev='fda' bus='fdc'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/awdisk10111/nas/iso/cn_win_srv_2003_r2_enterprise_with_sp2_vl_cd1.iso'/>
      <target dev='hda' bus='ide'/>
      <readonly/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>
    <controller type='usb' index='0' model='ich9-ehci1'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x7'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci1'>
      <master startport='0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0' multifunction='on'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci2'>
      <master startport='2'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x1'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci3'>
      <master startport='4'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x2'/>
    </controller>
    <controller type='pci' index='0' model='pci-root'/>
    <controller type='fdc' index='0'/>
    <controller type='ide' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
    </controller>
    <interface type='bridge'>
      <mac address='52:54:00:37:ee:2b'/>
      <source bridge='br0'/>
      <model type='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
    <serial type='pty'>
      <target type='isa-serial' port='0'>
        <model name='isa-serial'/>
      </target>
    </serial>
    <console type='pty'>
      <target type='serial' port='0'/>
    </console>
    <input type='tablet' bus='usb'>
      <address type='usb' bus='0' port='1'/>
    </input>
    <input type='mouse' bus='ps2'/>
    <input type='keyboard' bus='ps2'/>
    <graphics type='vnc' port='-1' autoport='yes' listen='0.0.0.0'>
      <listen type='address' address='0.0.0.0'/>
    </graphics>
    <video>
      <model type='vga' vram='16384' heads='1' primary='yes'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </video>
    <memballoon model='virtio'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    </memballoon>
  </devices>
</domain>
文档更新时间: 2020-02-23 05:42   作者:月影鹏鹏