does KVM raw images support preallocation?

raw images do not support preallocation, qcow2 and qed-images do:

preallocation=full instead of preallocation=metadata does not only allocate metadata for the raw image, but also writes zeros to it, thus creating a non-sparse image file.

If your filesystems supports sparse-files (e.g. ext, xfs, btrfs), blocks filled only with zeros are not stored physically, that saves space at the beginning of using this image.

If you would like to allocate all space on the raw image, you can use the dd command: dd if=/dev/zero of=file.img bs=1M count=204800

If you are working towards speed, also use cache=writethrough with e.g. libvirt, this enhanced speed without loss of data if your physical machine crashes.


According to this manual, I don't see any preallocation options for raw images.

And also it might be good to take a look at these benchmarks, It seems that any kind of raw images have better performance than qcow2.

and also I've seen many suggestions to avoid write-through caching because of performance issues but I didn't test it myself.