BACKGROUND: Up to now, I have been provisioning VMs as follows:
Create template/gold VM:
- Create new CentOS 6.6 VM with raw 200GB disk (1 .xml file, 1 .img file)
- LVM partitioning with: /boot, swap, and / partitions (most space in /)
- Install desired packages
The above results in a VM such as:
200GB /var/lib/libvirt/images/mytemplate.img
To produce guest images from the above I do:
- dd if=mytemplate.img of=myguest.img iflag=direct oflag=direct (vs cp for better copying speed)
- use guestfish to modify the /etc/sysconfig/network, /etc/sysconfig/network-scripts/ifcfg-eth0
- uuidgen and a MAC address generator script generate these ids
- static ip addresses are pulled from an available pool
The above works just fine: we have one .xml file and one .img file that can easily be moved around our data farm.
PROBLEM: The problem is that the above is thick provisioning. The images are 200GB in size, even though the majority of the image may be unused disk space. I'd like to have these thinly provisioned with a maximum growth size to make moving the images across the network faster. We'd want commands such as df / inside the guest VM to show the maximum size of the guest filesystem if at all possible.
Also, we'd like to consider qcow2 instead of raw for the image file so as to make it possible to take snapshots.
QUESTION: How do I create thinly-provisioned KVM images that are LVM partitioned as described above? Can I virt-sparsify the existing mytemplate.img file and still allow the image to grow to the maximum size and have the / filesystem have the behavior I want? Please feel free to offer alternatives for consideration.