Convert physical disk to kvm/qemu raw sparse img

I’ve had a hard time finding any guides on this. Always they suggest using dd to copy disk to virtual image file.  Which works fine I’m sure, but I wondered why not just use qemu-img convert command directly. Why the two step conversion?  So I did run into a post where someone asked the same thing, and sure enough, you can do this!

Here’s what I did, as an example.  In my case I’m converting a ZFS zvol to a raw img file. But I don’t see why you couldn’t use /dev/sdc directly, rather than the zvol device.  (obviously you either need to be in the directory you want the img file or use the full path!)


qemu-img convert -p -S 512 /dev/zvol/vpoolg1/VM/vm-1/sys/disk/tleweb/linvol -O raw tlweb-osvol.img

So in my example, I have:
-p to show progress
-S 512 for consecutive bytes to count for sparse
-O raw imgfile.img – the output file

Easy! And very fast for me!