VDI blocksize

Discussions related to using VirtualBox on Linux hosts.
Post Reply
j77h
Posts: 6
Joined: 23. Dec 2022, 04:42

VDI blocksize

Post by j77h »

After half an hour googling I've found nothing useful
about VDI blocksize or "block size" or "block-size".

'VBoxManage createmedium' has no such option.
It has a '--property' option, but does not say what properties can be used.
(Where can one find a list of such properties?)

Does a VDI have a blocksize?

Perhaps it is set dynamically by the filesystem created within it?

If not:
- what is the default value of blocksize?
- can we set blocksize when creating a VDI?

Use case: when the host fs is ZFS, apparently it's best for performance
to set the vdev's recordsize equal to the virtual disk's blocksize, or a small multiple thereof.

EDIT: In this post viewtopic.php?f=6&t=99852&sid=bcf170106 ... ce29158b99
I saw "VDI has a 1MiB block size", but can't use it because I found no evidence to support it.
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: VDI blocksize

Post by mpack »

VDI blocksize is 1MB as you can see from the source code. It is theoretically variable via a value in the header, but don't try changing it. I suspect that lots of things will break. As you have seen, no such feature is claimed in the formal docs.

And since you don't seem to have believed the previous comment of mine that you found, I am the author of the CloneVDI tool, so I do know whereof I speak...

Regarding ZFS, I doubt very much it will care about the VDI block size. 1MB is going to be a multiple of whatever minimum size it would prefer, and on modern SSDs nobody much cares anyway - it isn't as if seek latency is much of a thing any more.
j77h
Posts: 6
Joined: 23. Dec 2022, 04:42

Re: VDI blocksize

Post by j77h »

Thank you.
mpack wrote: 14. Sep 2023, 11:19 since you don't seem to have believed the previous comment of mine
The comment I saw is under a name that I don't know.
If it had been under your name I would have believed it.

My VMs are on a ZFS mirror of Seagate Ironwolf spinning disks.
For all other purposes it's surprisingly fast and responsive,
but my Win11 VM takes 3 minutes from switch-on to be ready to use.
Naturally a spinning disk is slower than SSD,
but I don't think it should be this slow.

Once I'm in there, it works fine, but I don't push hard on the disk in/out.
I use it about once a week for half an hour, so it's not a big deal.
fth0
Volunteer
Posts: 5678
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: VDI blocksize

Post by fth0 »

j77h wrote: 14. Sep 2023, 14:31 a name that I don't know
You can believe aeichner, too, since it's one of the VirtualBox core developers.

Regarding the vdev's recordsize, you could try 1 MiB indeed, which is also recommended for general-purpose file storage by some people giving solid explanations regarding ZFS details. I'm not sure how much it will really help, though:

On one hand, VirtualBox writes new 1 MiB VDI blocks at a time, when enlarging the current state VDI file. On the other hand, I could imagine that VirtualBox only writes the actual smaller amounts of data, when the current state VDI file already contains the respective VDI block. In any case, it shouldn't hurt, because the recordsize is only a maximum block size and shouldn't negatively impact small files being written to the same vdev.

PS: I won't tell you if you can believe me. SCNR ;)
Post Reply