0

I am thinking about this for a while. That you shall have your partitions aligned especially when using SSD's to get full performance is a well known fact. I guess :))

So if I create a VM that uses a file as a virtual block device, the file resides on the hosts SSD and starts in some sector. Depending on the type for the virtual image, I guess the file itself starts with some kind of a header, which moves the beginning of the actual data area backwards.

When the installation process of the OS inside the VM gets to the partitioning, would it be able to detect that offset and align the partitions inside the image file with the physical layout of the host's SSD? Or do I have to take care of this and make sure that alignment will happen?

I converted the disk images for my important VM's from qcow2 to raw and my impression is that they all run with less impact on the hosts resources. But that may well just be a wish come true :)))

Any ideas anyone?

1 Answer 1

1

Of course there is some impact. Virtualisation companies like VMWare, NetApp etc. have lots of documents on that (see e.g. http://media.netapp.com/documents/tr-3747.pdf, https://blogs.vmware.com/vsphere/2011/08/guest-os-partition-alignment.html, https://kb.netapp.com/support/index?page=content&id=3011193). Sorry for the examples, but that's what I was working with; other companies may have similar ressources.

And there is an "impact on the host ressources" if you use qcow2 instead of raw format - "copy on write" creates some overhead; you cannot get the advances (like snapshots etc.) for nothing.

If the "installation process of the OS inside the VM" is able to detect the physical layout of the physical disk depends on the virtualisation systems (storage virtualisation as well as cpu virtualisation). The two systems mentioned above are in certain configurations able to do this (before installaton of OS, i.e. VMWare ESX with NetApp storage provides an aligned virtual disk to the OS).

I suppose your question is for Qemu/KVM or the like. As far as I know there is no way for the OS installation process to request the alignment; even if there were some, it would not help, as you may move the virtual disk to another place, and therefore the alignment would be destroyed.

Regarding qcow2 with sparse disk assignment this will be impossible, as disk space is allocated "somewhere" when needed, so there is no dedicated alignment of virtual partitions on any defined physical boundary.

5
  • Interesting links! You are right, I was looking into Qemu/KVM, actually with my notebook in mind :)) I did not know that it also handled by network storage systems.
    – FredFoo
    Sep 20, 2016 at 8:03
  • Could it actually be that if you have an "intelligent disk format" the i/o impact can be eliminated? If the local image file is created with a guest os in mind that will align partitions and growing the file assures allocations will be in full blocks, so that guest blocks are kept aligned - maybe my question is some kind of dumb one :) Maybe it is so common that it is not even documented for qcow2 and friends :))
    – FredFoo
    Sep 20, 2016 at 8:09
  • Assumed that your physical partition starts on a physical block, and that the block size of your filesystem (e.g. ext4) meets the block size of your disk (see man mkfs.ext4, option -b), you can create a virtual disk, even in qcow2 format, to be block aligned with `qemu-img create -f qcow2 -o cluster_size <n> <file-to-create> <size-to-create>. This does not depend on any guest OS. For performance considerations, see e.g. this blog. I never used this, though...
    – ridgy
    Sep 20, 2016 at 8:30
  • Sorry. The command to create the disk is qemu-img create -f qcow2 -o cluster_size=<n> <file-to-create> <size-to-create>. The important thing here is cluster_size=.
    – ridgy
    Sep 20, 2016 at 8:52
  • Now this blog is a really nice one! Thanks a lot!
    – FredFoo
    Sep 20, 2016 at 11:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .