How to setup VM in KVM? Qcow or LVM etc

kvm-virtualization

Finally, after quite a bit of this vs that, I have chosen to virtualize a couple of my servers with KVM. I did do a test setup as well, but I have a few questions about setting VM's in KVM. Would appreciate pointers.

  1. What is the best storage to use – Qcow2 or LVM? I like the fact that I can copy the VM file easily with a Qcow2 but what about LVM, how do I take a backup or make copy on a development server to play with? I know I can clone a LVM, but how do I bring to my development server?

  2. How do I setup the guest partitioning? For example, when setting up Ubuntu inside Ubuntu, do I choose LVM for that VM or regular fdisk partitioning? Can I increase the partition size then later, if I need a bigger disk?

Best Answer

The answer to your first question depends on your requirements and priorities. Using an LVM volume for a guest disk will definitely perform a little better, especially under high disk usage, but qcow2 virtual disks are -- as you point out -- more flexible and easily portable. We use qcow images for just about everything for this reason, and pass through entire hard disks as block devices where performance is more important. Of course, where performance is absolutely critical it may be best to forgo virtualization altogether.

In regard to your second question, to use your example of an Ubuntu host/guest combination with a qc2 image, we would select the install option to create and install to a single LVM volume using the entire (virtual qcow2) disk. This is relatively quick and painless and should work for most scenarios, but be advised that if you've selected an encrypted LVM volume for the host, do NOT choose encryption for the guest's volume, as this generally isn't necessary and has caused problems for us in the past. In fact, even encrypting the home directories on the guest has caused freeze-ups for us when the guest VM image files were run from on an encrypted LVM host volume.