temporarily speeding up IO performance for KVM VM

i have few VMs running on top of spinning rust. recently i’ve upgraded one of them to not-yet-stable debian bookworm. upgrade would be pretty slow but.. i’ve edited the VM definition and asked KVM to allow host server to cache any IO operations. speedup was great, bullseye->bookworm upgrade finished in less than 5 minutes.

# stop the VM
# on the KVM host
virsh edit nameOfVM
# search for virtual disk definition and add
# cache='unsafe' as below:
<disk type='file' device='disk'>
  <driver name='qemu' type='qcow2'         cache='unsafe'        />
  <source file='/mnt/vms/nameOfVM/vda.qcow2'/>
  <target dev='vda' bus='virtio'/>
  <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
virsh define /etc/libvirt/qemu/nameOfVM.xml
virsh start nameOfVM

# after the upgrade repeat above and remove cache='unsafe'

for more details – see Red Hat’s documentation.

Leave a Reply

Your email address will not be published. Required fields are marked *

(Spamcheck Enabled)