I have KVM running and need to convert some qcow2 disk images from running guests into vmdk format. Is it safe to take an LVM snapshot of the logical volume that the qcow2 file resides on, mount it, and then run qemu-img convert on the mounted snapshot volume? The destination for the converted file will either be an attached USB drive or an NFS mount. I want to be sure there is no risk to the original qcow2 file doing it this way. The alternative would be to make a copy to the destination first, and then convert that, which takes a lot longer. EXT4 filesystem, libvirt 0.10

  • Why would you need to mount the filesystem? Can you point the conversion tool directly at the snapshot device? If you are going to mount it, it seems like you would want to mount RO.
    – Zoredache
    Sep 11 '13 at 19:59
  • I always see these types of backups done from mounted snapshot lvs, can you perform operations directly on unmounted snapshot devices? I never tried that.
    – user160910
    Sep 11 '13 at 20:10
  • Sure, if you have a snapshot you can use DD to pull the contents off that snapshot. You don't need to mount it. I don't know how qemu-img works though, I imagine, it isn't very different from what you would get with a simple DD. Does qemu-img do some magic at the filesystem level to compress space/de-fragement files or anything?
    – Zoredache
    Sep 11 '13 at 20:26
  • Yes, it deduplicates zeroes when the target is qcow2, and it also copies the metadata offsets correctly, which dd sometimes misses
    – dyasny
    Sep 11 '13 at 21:26

Sounds like a good plan - take an LVM snapshot, use qemu-img convert to pull the data out of the snapshot into another LV or file, and discard the snapshot.

It won't be crash consistent, but it will work

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy