標籤:virtio kvm windows
KVM安裝Windows預設使用的是qemu虛擬化IDE硬碟模式,在這種情況下,IO效能比較低,如果使用virtio的方式可以提高虛擬機器IO效能。而virtio所驅動的網卡,也將原來的百兆擴充到千兆。這裡就簡單介紹下如何使用virtio驅動安裝window server 2008. 其它windows版本操作相同,只需選擇對應的驅動即可。
使用virtio安裝window虛擬機器
KVM安裝Windows需要使用virtio的驅動:
https://fedoraproject.org/wiki/Windows_Virtio_Drivers#Direct_download
安裝虛擬機器步驟:
1、安裝virtio驅動:
wget https://fedorapeople.org/groups/virt/virtio-win/virtio-win.repo -O /etc/yum.repos.d/virtio-win.repo
yum install virtio-win -y
2、查看virtio-win提供的驅動:
rpm -ql virtio-win | grep iso/usr/share/virtio-win/virtio-win-0.1.126.iso/usr/share/virtio-win/virtio-win.iso
3、安裝windows:
建立一個虛擬機器磁碟:
qemu-img create -f qcow2 win-2c8g150g.img 150G
使用virtio驅動安裝虛擬機器:
virt-install -n win-2c8g150g --vcpus=2 --ram=8192 --os-type=windows --os-variant=win2k8 -c /vm/iso/cn_windows_server_2008_r2_sp1_x64.iso --disk path=/usr/share/virtio-win/virtio-win-0.1.126_amd64.vfd,device=floppy --disk path=/vm/win-2c8g150g.img,format=qcow2,bus=virtio --graphics vnc,listen=0.0.0.0 --noautoconsole
提示: 這裡是使用的是磁碟片方式載入,如果鏡像和驅動都使用cdrom的方式載入,在有些情況系統會找不到啟動鏡像,導致無法啟動. 載入的驅動有x86和amd64兩種類型,64位系統選擇amd64. 32為系統選擇x86.
4、 安裝過程中,在選擇磁碟介面會找不到磁碟,選擇“載入驅動”,“瀏覽”,找到“軟碟機”,點開後選擇 “server 2008”確定,驅動載入完成後,磁碟就出現了,繼續安裝即可。
5、安裝完成後,在裝置管理員中可以看到使用的是virtio:
650) this.width=650;" src="https://s5.51cto.com/wyfs02/M01/9D/F3/wKiom1mJM9vToPJuAAF7LT_WF-M343.jpg" title="1111.jpg" alt="wKiom1mJM9vToPJuAAF7LT_WF-M343.jpg" />
在已安裝的kvm虛擬機器上添加virtio驅動
如果以傳統的IDE硬碟模式安裝可以使用如下命令:
virt-install --virt-type kvm --name win-2c8g100g --ram 8192 -vcpus=2 -s 100 -c /vm/iso/cn_windows_server_2008_r2_sp1_x64.iso --os-type=windows -f /vm/win-2c8g100g.img --graphics vnc,listen=0.0.0.0 --noautoconsole
安裝之後要使用virtio驅動,可以選擇載入virtio驅動的iso檔案到虛擬機器光碟機:
virsh attach-disk win-2c8g100g /usr/share/virtio-win/virtio-win.iso hdb --type cdrom
或者使用如下命令:
virsh change-media win-2c8g100g hdb /usr/share/virtio-win/virtio-win.iso
參考連結:https://superuser.com/questions/239870/change-cd-rom-via-virsh
修改虛擬機器的xml檔案,使其能發現virtio類型的裝置,否則驅動無法安裝:
增加一塊virtio驅動的硬碟:
qemu-img create -f qcow2 test.img 1G
修改虛擬機器的xml檔案,在原有的"disk type"地區增加一個test磁碟的配置:
<disk type=‘file‘ device=‘disk‘> <driver name=‘qemu‘ type=‘qcow2‘/> <source file=‘/vm/test.img‘/> <target dev=‘vdb‘ bus=‘virtio‘/> </disk>
修改網卡類型為 virtio, 在 interface type 地區,修改model type=‘virtio‘ :
<interface type=‘bridge‘> <mac address=‘52:54:00:39:f9:60‘/> <source bridge=‘br0‘/> <model type=‘virtio‘/>
提示:如果不是使用vnc遠端連線,需要新增一個網卡配置,在沒有安裝驅動前,使用上面的配置,虛擬機器是斷網狀態。
修改完成之後,重啟虛擬機器:
virsh shutdown win-2c8g100gvirsh start win-2c8g100g
進入虛擬機器,成功添加iso驅動程式後,進入虛擬機器的裝置管理員介面,在“系統裝置”裡面對相應的驅動進行更新:
更新驅動需要找到掛載的CD中 virtio-win.iso中的對應檔案。驅動鏡像中分別有四種驅動,他們對應關係為:
Balloon
, the balloon driver, affects the PCI standard RAM Controller in the System devicesgroup.
vioserial
, the serial driver, affects the PCI Simple Communication Controller in the System devices group.
NetKVM
, the network driver, affects the Network adapters group. This driver is only available if a virtio NIC is configured. Configurable parameters for this driver are documented in Appendix A, NetKVM Driver Parameters.
viostor
, the block driver, affects the Disk drives group. This driver is only available if a virtio disk is configured.
參考連結:
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Virtualization_Host_Configuration_and_Guest_Installation_Guide/form-Virtualization_Host_Configuration_and_Guest_Installation_Guide-Para_virtualized_drivers-Mounting_the_image_with_virt_manager.html
如果找不到英文說明中對應的裝置,使用如下方式:
對未知裝置添加virtio驅動即可,650) this.width=650;" src="https://s4.51cto.com/wyfs02/M00/9D/F9/wKiom1mJcb7QkcQhAAGRHg_CpEE735.jpg" title="333.jpg" alt="wKiom1mJcb7QkcQhAAGRHg_CpEE735.jpg" />
安裝驅動之後:
650) this.width=650;" src="https://s4.51cto.com/wyfs02/M00/9D/F8/wKioL1mJcg7Sjv5TAAGNZdlc8LI143.jpg" title="444.jpg" alt="wKioL1mJcg7Sjv5TAAGNZdlc8LI143.jpg" />
對應的磁碟驅動成功安裝:
650) this.width=650;" src="https://s2.51cto.com/wyfs02/M02/9D/F9/wKiom1mJcnTDxwC4AAHyf7OtQOM892.jpg" title="222.jpg" alt="wKiom1mJcnTDxwC4AAHyf7OtQOM892.jpg" />
此時virtio驅動添加完成,修改虛擬機器的xml檔案,刪除test.img的虛擬磁碟配置,修改啟動磁碟驅動類型:
<disk type=‘file‘ device=‘disk‘> <driver name=‘qemu‘ type=‘qcow2‘/> <source file=‘/vm/win-2c8g100g.img‘/> <target dev=‘vda‘ bus=‘virtio‘/> <address type=‘pci‘ domain=‘0x0000‘ bus=‘0x00‘ slot=‘0x07‘ function=‘0x0‘/> </disk>
重啟虛擬機器即可。
參考連結:
https://access.redhat.com/solutions/17463
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Virtualization_Host_Configuration_and_Guest_Installation_Guide/form-Virtualization_Host_Configuration_and_Guest_Installation_Guide-Para_virtualized_drivers-Installing_with_a_virtualized_floppy_disk.html
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Virtualization_Host_Configuration_and_Guest_Installation_Guide/form-Virtualization_Host_Configuration_and_Guest_Installation_Guide-Para_virtualized_drivers-Mounting_the_image_with_virt_manager.html
http://blog.csdn.net/ks_is_fighting/article/details/38358793
本文出自 “Trying” 部落格,請務必保留此出處http://tryingstuff.blog.51cto.com/4603492/1954531
KVM 使用virtio驅動Windows server 虛擬機器