GalaxyData Community

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

dd if=/dev/vmlv/vm4992 of=/dev/vmlv/vm4992-new

 

qemu-img convert /dev/vmlv/vm4992 -O raw /dev/vmlv/vm4992

 

 
 
#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>

 

Exit mobile version