Re: Why does creating a fixed size VDI take so long?
Posted: 17. Jun 2012, 15:42
Ok, well, is there a way of not getting it to zero all the clusters, or maybe one of the other HD formats for preallocation?
End user forums for VirtualBox
https://forums.virtualbox.org/
I'm not talking about how the image file is internally organized, I'm talking about how it's stored on disk. A file that grows over time is far more likely to be fragmented on the host filesystem. I'm also not sure how many users are able and/or willing to run CloneVDI or something similar regularly.mpack wrote:The marginal difference caused by internal block order fragmentation can be eliminated at any time by cloning the drive, especially convenient if done using CloneVDI with the "keep UUID" option set.
A humongous file created as a unit is far less likely to be fragmented, unless the host filesystem sucks. I agree that letting an image grow and defragmenting it later is a better use of resources, but I disagree that it's something users are likely to do. Just saying.Of course a humungous fixed size drive image is more likely to be fragmented as a file on the host drive, so IMHO most users will see no difference in net effect. In fact it would pay to defragment the VDI, then defragment the host using a different tool - after the file size has stablilized of course. That should achieve the perfect ideal of compactness and performance
So I'm guessing I'm going to have to roll my own?adrianh wrote:Ok, well, is there a way of not getting it to zero all the clusters, or maybe one of the other HD formats for preallocation?
Well, due to the lack of response, I'm rolling my own. This message is quite useful up to a point. Looks like nobody checked the math or confirmed the results:adrianh wrote:So I'm guessing I'm going to have to roll my own?adrianh wrote:Ok, well, is there a way of not getting it to zero all the clusters, or maybe one of the other HD formats for preallocation?
Creating a 10M file I get this:TerryE wrote: In the case of a dynamic VDI (Type 1) as “new” 1Mbyte blocks in the virtual HDD are written to, these are mapped to new 1Mbyte blocks which are allocated at the end of the VDI file; that is a dynamic VDI is initially ordered in chronological not physical order. The initial size of an N Mbyte dynamic VDI is 512+4N+F bytes with all N image map entries set to -1. F = (508+4N) mod 512, that is the packing necessary to round up to a sector boundary.
In the case of a static (Type 2) VDI all blocks are pre-allocated so no dynamic allocation is necessary. The create utility also writes zeros to the entire file because many file systems themselves adopt a just-in-time allocation policy. The initial size of an N Mbyte static VDI is 512+4N+F+1048576N bytes, where F is as in the dynamic case.
Code: Select all
$ vboxmanage createhd --filename c.vdi --size 10 --format VDI --variant Standard
$ ls -l c.vdi
-rwxr-xr-x 1 Adrian None 8192 Jun 19 11:49 c.vdi
Code: Select all
(int(4(N-1)/4096)+1)*4096Yes, I could go through the code to track it down. But I'm new to the project and there is little documentation there too and no overview document requiring a lot of guessing where things are and why they are named the way they are. And I also hate it when people say, "but its common sense!" because it is common only to those on the project after a good long time studying and delving into the code.mpack wrote:There's no need to experiment. The structure of a VDI is given in the source code.
Well Perryg, where did you see an insult? I merely stated my feelings about this and many other projects. Did I hurt your feelings by stating that it's documentation is poor? It is most likely not your fault, it is just a fact, mostly due to no leadership, time and/or drive. I've been in this game for a while and this is not the first and will not be the last time when I see a poorly documented system.Perryg wrote:Well now. That should get you somewhere. Smack down the people that know and insult them. I for one am outa here.