Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm having some serious disk performance problems while setting up a KVM guest. Using a simple dd test, the partition on the host that the qcow2 images reside on (a mirrored RAID array) writes at over 120MB/s, while my guest gets writes ranging from 0.5 to 3MB/s.

  • The guest is configured with a couple of CPUs and 4G of RAM and isn't currently running anything else; it's a completely minimal install at the moment.
  • Performance is tested using time dd if=/dev/zero of=/tmp/test oflag=direct bs=64k count=16000.
  • The guest is configured to use virtio, but this doesn't appear to make a difference to the performance.
  • The host partitions are 4kb aligned (and performance is fine on the host, anyway).
  • Using writeback caching on the disks increases the reported performance massively, but I'd prefer not to use it; even without it performance should be far better than this.
  • Host and guest are both running Ubuntu 12.04 LTS, which comes with qemu-kvm 1.0+noroms-0ubuntu13 and libvirt 0.9.8-2ubuntu17.1.
  • Host has the deadline IO scheduler enabled and the guest has noop.

There seem to be plenty of guides out there tweaking kvm performance, and I'll get there eventually, but it seems like I should be getting vastly better performance than this at this point in time so it seems like something is already very wrong.

Update 1

And suddenly when I go back and test now, it's 26.6 MB/s; this is more like what I expected w/qcrow2. I'll leave the question up in case anyone has any ideas as to what might have been the problem (and in case it mysteriously returns again).

Update 2

I stopped worrying about qcow2 performance and just cut over to LVM on top of RAID1 with raw images, still using virtio but setting cache='none' and io='native' on the disk drive. Write performance is now appx. 135MB/s using the same basic test as above, so there doesn't seem to be much point in figuring out what the problem was when it can be so easily worked around entirely.

share|improve this question
You didn't mention the distribution and software versions in use. – dyasny Jul 15 '12 at 7:42
Added some info on versions. – El Yobo Jul 15 '12 at 7:55
ah, as expected, ubuntu... any chance you can reproduce this on fedora? – dyasny Jul 15 '12 at 8:13
The server is in Germany and I'm currently in Mexico, so that could be a little tricky. And if it did suddenly work... I still wouldn't want to have to deal with a Fedora server ;) I have seen a few comments suggesting that Debian/Ubuntu systems did have more issues than Fedora/CentOS for KVM as much of the development work was done there. – El Yobo Jul 15 '12 at 8:18
my point exactly. and in any case, if you are after a server grade OS you need RHEL, not Ubuntu – dyasny Jul 15 '12 at 8:51
up vote 10 down vote accepted

Well, yeah, qcow2 files aren't designed for blazingly fast performance. You'll get much better luck out of raw partitions (or, preferably, LVs).

share|improve this answer
Obviously, but they're also not meant to be quite as crap as the numbers I'm getting either. – El Yobo Jul 15 '12 at 7:52
[citation needed], as the wikipedians say. Who says they're not meant to be that crap? – womble Jul 15 '12 at 7:55
Most examples out there show similar performance with qcow2, which seems to be a significant improvement over the older version. The KVM site itself has come numbers up at which show comparable times for a range of cases. – El Yobo Jul 15 '12 at 8:15
18:35 (qcow2) vs 8:48 (raw) is "comparable times"? – womble Jul 15 '12 at 8:19
That is not quite true - latest patches in qemu speeds qcow2 a lot! We are almost on par. – lzap Nov 25 '13 at 20:43

How to achieve top performance with QCOW2:

qemu-img create -f qcow2 -o preallocation=metadata,compat=1.1,lazy_refcounts=on imageXYZ

The most important one is preallocation which gives nice boost, according to qcow2 developers. It is almost on par with LVM now! Also you can provide unsafe cache if this is not production instance (good for testing):

<driver name='qemu' cache='unsafe' />

Some users reports that this configuration beats LVM/unsafe configuration in some tests.

For all these parameters latest QEMU 1.5+ is required!

share|improve this answer
It is not a good idea to use cache=unsafe: an unexpected host shutdown can wreak havoc on the entire guest filesystem. It is much better to use cache=writeback: similar performance, but much better reliability. – shodanshok Apr 2 '15 at 17:18
As I've said: if this is not production instance (good for testing) – lzap Apr 3 '15 at 13:11
Fair enough. I missed it ;) – shodanshok Apr 3 '15 at 15:34
Thanks for the recommendation Shodanshok – SprintCycle Oct 15 '15 at 23:14

I achieved great results for qcow2 image with this setting:

<driver name='qemu' type='raw' cache='none' io='native'/>

which disables guest caches and enables AIO (Asynchronous IO). Running your dd command gave me 177MB/s on host and 155MB/s on guest. The image is placed on same LVM volume where host's test was done.

My qemu-kvm version is 1.0+noroms-0ubuntu14.8 and kernel 3.2.0-41-generic from stock Ubuntu 12.04.2 LTS.

share|improve this answer
You set a qcow2 image type to "raw"? – Alex Aug 18 '13 at 11:02
I guess I have copied older entry, I suppose speed benefits should be same for type='qcow2', could you check that before I edit? I have no more access to such configuration - I migrated to LXC with mount bind directories to achieve real native speeds in guests. – gertas Aug 18 '13 at 11:15

If you're running your vms with a single command, for arguments you can use

kvm -drive file=/path_to.qcow2,if=virtio,cache=off <...>

It got me from 3MB/s to 70MB/s

share|improve this answer

On old Qemu/KVM versions, Qcow2 backend was very slow when not preallocated, more so if used without writeback cache enabled. See here for more information.

On more recent Qemu versions, Qcow2 files are much faster, even when using no preallocation (or metadata-only preallocation). Still, LVM volumes remain faster.

A note on the cache modes: writeback cache is the preferred mode, unless using a guest with no or disabled support for disk cache flush/barriers. In practice, Win2000+ guests and any Linux EXT4, XFS or EXT3+barrier mount options are fines. On the other hand, cache=unsafe should never be used of production machines, as cache flushes are not propagated to the host system. An unexpected host shutdown can literally destroy guest's filesystem.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.