Convert a KVM Virtual Machine from RAW to QCOW2 Format

Convert a KVM Virtual Machine from RAW to QCOW2 Format

The KVM image format RAW (the default) is very basic. One feature that might be missed is the ability to Snapshot the entire virtual machine. The Qcow2 format supports snapshots. The following command will convert a KVM image from RAW to Qcow2.

qemu-img convert -f raw -O qcow2 /home/libvirt/images/vmguest1.img /home/libvirt/images/vmguest1.qcow2

In the above command, the path to the RAW format is “/home/libvirt/images/”. However, the default location on a CentOS system is “/var/lib/libvirt/images/”.

Now ensure the correct permissions on the new image file. Just copy the ownership and permissions of the other images (such as the original RAW image):

ls -l /home/libvirt/iamges
-rw-------. 1 qemu qemu 53687091200 Jan 14 01:16 vmguest1.img
-rw-r--r--. 1 root root   743374848 Jan 14 01:24 vmguest1.qcow2

Now make the corrections:

chmod 600 /home/libvirt/images/vmguest1.qcow2
chown qemu.qemu /home/libvirt/images/vmguest1.qcow2

Finally you can create a new virtual machine based on the new image using whatever means you prefer. I prefer to use a graphical tool such as “virt-manager” which does away with having to deal with XML files. Redhat and CentOS come with virt-manager. It’s part of the “KVM” package group. EG: “yum groupinfo KVM”.

— See more at:

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *


Этот сайт использует Akismet для борьбы со спамом. Узнайте, как обрабатываются ваши данные комментариев.