Virtual host QCow convert to LVM


Sometimes its better to have your virtual images running directly of LVM instead of using raw or QCow formatted files. So how do we convert? Basically you have to make sure that you have a volume group, of the right size or bigger and then dd the file into a LV on that volume group:

This should in the directory where you have the image:

[cc lang=“bash”]

# Get the filesize of the raw image in Kilobytes.

ls -lk

#Create lv on vdisk05 (the VG)

lvcreate -L 5242880K -n vm-102-disk-1 vdisk05

#Convert from QCow to Raw

qemu-img convert bld-ubuntu-1004-2.qcow2 -O raw bld-ubuntu-1004-2.raw

#Copy the image into the lv:

dd if=bld-ubuntu-1004-2.raw of=/dev/vdisk05/vm-102-disk-1


Then change the configuration of your QEMU or whatever you are using on your virtualisation platform.

Sorry for the briefness of the instructions, its mainly for my own benefit and if you are doing this you should really know about LVM, dd and ls.

comments powered by Disqus