Pegasi Wiki

This wiki acts as a memo for our own work so why not share them? Feel free to browse and use out notes and leave a note while at it.

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

kvm_performance_tuning [2012/04/13 17:36]
Pekka Kuronen
kvm_performance_tuning [2017/11/06 10:11]
Line 1: Line 1:
-==== KVM performance tuning ==== 
  
----- 
- 
-I used to have XEN (para)virtualization and compared to that I notice KVM to be a lot more resource hungry and not easily optimized. I am using CentOS 6.2 which should be the best with KVM but at least for now Windows 7 64bit seems to be run slower than Windows 2000 VMWare guest with 25% of the resources. 
- 
-BUT.. I made some modifications and it started to fly. Here is my receipe for good life with KVM Windows. 
- 
-**Increase memory** 
- 
-I upped the guest memory to 12G so the disk operations got minimized 
- 
-**Use Virtio block and network drivers from Fedora** 
- 
-Very well functioning especially with block devices 
- 
-**Use cache=none OR cache=writeback** 
- 
-Preferably the first since it is safer in user 
- 
-**Use io=native** 
- 
-This should give some extra boost 
- 
-**Ditch the file image based storage** 
- 
-Raw image will not work stable with good cache settings and Windows guest. Best if you transfer the image to a block device with following procedure. Lets assume we have a raw image file and a nice SSD disk in /dev/sdd that is free to use for our guest. 
- 
-<​code>​ 
-fdisk /dev/sdd 
-</​code>​ 
- 
-Create HPFS/NTFS primary partition, bigger than the image file 
- 
-<​code>​ 
-dd if=yourkvmimagefile.img of=/​dev/​sdd1 bs=1024k 
-</​code>​ 
- 
-The device is now boot ready but if you want to increase the size of your partition continue to following 
- 
-<​code>​ 
-fdisk /dev/sdd 
-</​code>​ 
- 
-Delete and create again to your wanted size, if needed. 
- 
-<​code>​ 
-kpartx -a /dev/sdd1 
-ntfsresize --info /​dev/​mapper/​sdd1XXX 
-</​code>​ 
- 
-Look at current volume and device sizes and if needed resize with command 
- 
-<​code>​ 
-ntfsresize -s <​newsize>​ /​dev/​mapped/​sdd1XXX 
-</​code>​ 
- 
-Now change the virtual machine definition with 
- 
-<​code>​virsh edir yourvirtualmachine</​code>​ 
- 
-And edit the element 
- 
-<​code>​ 
-    <disk type='​file'​ device='​disk'>​ 
-      <driver name='​qemu'​ type='​raw'​ cache='​writethrough'/>​ 
-      <source file='/​var/​lib/​libvirt/​images/​myserver.img'/>​ 
-      <target dev='​hda'​ bus='​virtio'/>​ 
-      <address type='​pci'​ domain='​0x0000'​ bus='​0x00'​ slot='​0x03'​ function='​0x0'/>​ 
-    </​disk>​ 
-</​code>​ 
- 
-To look like 
- 
-<​code>​ 
-    <disk type='​block'​ device='​disk'>​ 
-      <driver name='​qemu'​ type='​raw'​ cache='​none'​ io='​native'/>​ 
-      <source dev='/​dev/​sdd1'/>​ 
-      <target dev='​vda'​ bus='​virtio'/>​ 
-      <address type='​pci'​ domain='​0x0000'​ bus='​0x00'​ slot='​0x04'​ function='​0x0'/>​ 
-    </​disk>​ 
-</​code>​ 
- 
-This made my KVM guest fly and host can barely see the load. I can truly say it is like a different piece of hardware compared to image based system. 

  //check if we are running within the DokuWiki environment if (!defined("DOKU_INC")){ die(); } //place the needed HTML source codes BELOW this line