Friday, May 17, 2013

Convert KVM Qcow2 File to LVM Disk


Following steps involve moving some KVM VMs from file storage to block storage. 
This is basically converting the .qcow2 files to LVM LVs. It was surprisingly simple.







1. qemu-img convert disk0.qcow2 -O raw disk0.raw

2. ls -l


-rw-r--r-- 1 user user 44023414784 2011-03-27 09:09 disk.raw

3. lvcreate -L 44023414784b -n lv_disk vgroup

4. dd if=disk.raw of=/dev/vgroup/lv_disk





=============================================================



#Configuration Before:



<disk type='file' device='disk'>

  <driver name='qemu' type='qcow2' cache='none'/>

  <source file='/srv/virtual/vm_web/tmp5GWO4q.qcow2'/>

  <target dev='hda' bus='virtio'/>

</disk>





#Configuration After:



<disk type='block' device='disk'>

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

  <source dev='/dev/vgroup/lv_disk'/>

  <target dev='vda' bus='virtio'/>

</disk>

No comments:

Post a Comment