2

When adding an HDD to a guest in QEMU/KVM in Virt-Manager, there are "qcow2" and "raw". "raw" seems to be storing the data in a file with the ".img" extension. It seems that I can pass the entire physical disk to the guest like this post says, but is using the whole physical disk like that any faster than using the raw ".img" file?

I am going to use a dedicated physical drive for a guest anyway, but I guess passing the whole raw disk to the guest may damage the file system metadata if I let the host access that disk at the same time by a mistake. If I use a raw ".img" file on that drive, than it will be safe from such accident. But if the former is significantly faster, then it may be worth the risk.

<disk> <disk type="block" device="disk"> <driver name="qemu" type="raw"/> <source dev="/dev/sdg"/> <======= whatever the device is on your system -- lsblk will show devices <target dev="vda" bus="virtio"/> (for 2nd virtio device then replace vda by vdb etc ) # <address type="pci" domain="0x0000" bus="0x06" slot="0x00" function="0x0"/> this line is generated when the VM is booted so you don't enter this one </disk> 
0

1 Answer 1

3

Raw disk would faster, although it would make it difficult to move the virtual machine to another computer (because requiring to clone the disk).

The reason Raw is faster is because for qcow2 (or any other virtual format) any disk request would be passed among two file systems:

  1. The request issued in the virtual machine will be handled by the driver in the VM, including all the administration involved with allocation of virtual sectors etc. which is actually only within the .img file, so within a fictional file-system.

  2. The virtual driver then issues the request to the real physical disk, to another file-system, which would then do the same work of the allocation of physical sectors etc.

For the Raw disk, there is only one file-system - the virtual and physical are then identical. However, in most cases the performance improvement is only marginal and does not justify the inconvenience,

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.