Categories
Linux Virtualization

KVM image on LVM

Convert qcow2/raw images to LVM logical volume to use with KVM:

– Convert the qcow2 image to raw format (if it is in qcow2)
$ qemu-img convert image.qcow2 -O raw image.raw

– Create the physical volume for LVM
# pvcreate /dev/sdb
(replace the device with correspond to the system)

– Create the volume group
# vgcreate pool1 /dev/sdb
(replace pool1 with the name as required)

– Create Logical volume with same size as the image
# lvcreate -n justaname --size 50G pool1
(replace justaname and size as per the requirements)
Use lvresize incase you required the change the volume size

– dd the raw image to lvm logical volume
# dd if=image.raw of=/dev/pool1/justaname bs=8M
(Change the block size according to the requirements.

Edit the kvm xml configuration for the corresponding virutal machine to use the logical volume

< disk type='block' device='disk' >
< source dev='/dev/pool1/justaname'/ >
< /code >

./arun

Leave a Reply

Your email address will not be published.

*