Created page with "{{PDF}} == Introduction == Normally I used to run virtual servers on raw devices, installing directly to LVM volumes. <br>The volumes were created on top of either a RAID ar..."
New page
{{PDF}}
== Introduction ==
Normally I used to run virtual servers on raw devices, installing directly to LVM volumes.
<br>The volumes were created on top of either a RAID array or a LUN exported from an expensive storage device - a SAN.
<br>This approach may add some speed but it also takes away flexibility and adds complexity to the setup.
<br>Recently I started testing a clustered file-system called GlusterFS and I decided to give it a shot.
<br>For that I wanted to convert some of my KVM guest VMs to disk containers. Here is how it's done.
== Execurion ==
* Use qemu-img to convert from an lvm to qcow2 format:
# qemu-img convert -O qcow2 /dev/vg_name/lv_name/ /var/lib/libvirt/images/image_name.qcow2
If you want the image compressed add '-c' right after the word convert.
* Edit the xml for the image.
# virsh edit image_name
*Modify the disk stanza, adding a type to the driver line; on the source line change 'dev' to 'file' and modify the path:
driver name='qemu' type='qcow2'
source file='/var/lib/libvirt/images/image_name.qcow2'
Creating images from with a base image allows quick rollouts of many boxes based on an single install - for example I have a 'golden image' of Centos, I can stop that VM and create 2 servers using the original VM disk as a base file and writing changes to different files.
# qemu-img create -b original_image.qcow2 -f qcow2 clone_image01.qcow2
# qemu-img create -b original_image.qcow2 -f qcow2 clone_image02.qcow2
Taking this further I can then snapshot both images so once I start making changes, rolling back to a point in time prior to the changes is very easy:
# qemu-img snapshot -c snapshot_name vm_image_name.qcow2
That's all folks!<br>
[[User:YazzY|Marcin]]
[[Category: Alphabetized|RPM]]
<br>
<comments /><br>{{:{{TALKSPACE}}:{{PAGENAME}}}}