Linux – What KVM disk type to use

kvm-virtualizationlinuxlvmperformancevirtualization

I'm setting up a few KVM virtual guests and I'm debating which disk type to use. I haven't been able to find a good resource online that runs down the pros and cons of each.

Can you help me create a list of the different disk type and the advantages and disadvantages of each? Here are the disk types I know about:

  • Raw image
  • qcow2
  • Dedicated partition (eg, in LVM)

I'm curious about these criteria:

  • Ease of setup (how easy is it to create each type)
  • Performance
  • Ease of cloning
  • Ease of expanding (to make bigger, so the virtual guest has more disk space)
  • Features specific to that disk type
  • Ease of backup
  • Migration to other hosts

Can you help me evaluate my choices?

Best Answer

I would concentrate on raw image and LVM.

Raw image its easier to backup and copy, since it's just a file and you can do with it whatever you can do to a simple file. Also, avoiding specific formats you can easily use it, like mount it on a loop device to access the files in case of a crash or problem (or even on a backup server without virtualization). On the other hand, raw image files are affected by the kernel file cache, so you must be very careful when dealing with crashes and shutdowns, because the VM sync() doesn't really means that the host server sync()ed the file to a disk. I had many problems with that.

LVM bypass the cache problem, has better performance than files (AFAIK, it may have changed on the last months) and has the advantages of snapshots for backup. Changing the size of disks is also not complicated, but it's a little less trivial than raw files. Also with LVM you can setup DRBD for live migrations/failover.

In my opinion, go with LVM unless you have very specific needs for files.