Page 1 of 2

Convert Dynamic to fixed-size virtualdisk

Posted: 6. Jun 2013, 17:28
by kiwi
Hi everyone,
I'm running VirtualBox 4.2.12 on Ubuntu 12.04.2. While creating VM I prefer to use fixed-size virtual disk as it is said to be faster than dynamic one.
I created a fixed-size disk of 80GB (format vmdk) and run Windows Server 2008 on it. I exported that VM using Export Appliance to a .ova file.
When i import that VM to a different host using Import Appliance it is imported Ok. However the disk is dynamic and only weigh 9GB.

How can I change that disk into fixed size disk? Is it possible to keep the disk in fixed-size mode during Import Appliance :?:

Re: Convert Dynamic to fixed-size virtualdisk

Posted: 6. Jun 2013, 17:31
by mpack
kiwi wrote:I prefer to use fixed-size virtual disk as it is said to be faster than dynamic one.
It's not said by anyone who knows what he's talking about.

If you insist on doing it anyway, then you can use "VBoxManage clonehd <src name> <dest name> --variant Fixed". See user manual for exact syntax.

No, it isn't possible to retain the fixed format when exporting/importing. However it also isn't necessary to use export/import to move a VM between VBox hosts. The Howto explains the proper way.

Re: Convert Dynamic to fixed-size virtualdisk

Posted: 18. Jun 2013, 12:34
by kiwi
thank mpack for ur beautiful command to convert dynamic disk to fixed one. I now realize that I love the exporting/importing function is very beneficial because it shrinks the fixed virtualdisk into very small dynamic one (my fixed virtual disk is 80GB large). With your command, i just move the exported .voa (less than 10GB) to a different host, import it, convert it to fixed disk, delete the dynamic one and let the VM mount the new disk.
It's not said by anyone who knows what he's talking about.
Can you clarify it more? I heard that if the VM does a lot of read/write to its disk, using fixed disk is a better choice. I am running MySQL on my VM

Re: Convert Dynamic to fixed-size virtualdisk

Posted: 18. Jun 2013, 13:30
by mpack
kiwi wrote:I heard that if the VM does a lot of read/write to its disk, using fixed disk is a better choice
I don't particularly care to have this discussion yet again against phantom assertions. If you believe that fixed is typically faster than dynamic then by all means lets see the statistics which persuaded you of that.

From the point of view of someone who understands the VDI format I will note that the fixed and dynamic VDI formats are actually identical, the only difference being when the blocks are allocated (either up front, or on demand). The cost of allocation is higher for fixed: all at once up front regardless of whether you need it all or not, vs a bit a time and only if needed. However, because people tend to make fixed sized disks too small, they tend to be more congested and hence have poorer performance. Seek performance is often brought up, however there is no evidence that having related guest blocks next to each other is a bad thing seek wise - intuitively the opposite would be true - and of course that discussion is irrelevant for SSDs. It would be true to say that fixed size disks are more robust, i.e. more easily repaired after certain kinds of error, on the other hand dynamic disks are usually smaller and easier to back up.

There being no clear winner in the performance or reliability stakes I would tend to go with convenience and choose dynamically allocated VDI.

Re: Convert Dynamic to fixed-size virtualdisk

Posted: 11. Dec 2014, 06:38
by Pseudo Lee
Is this feedback specific to Linux hosts?

I created several Windows 7 guests (on windows 8 host) over the last week. I found Fixed disks to be a LOT faster for installs.

Just tonight, I made my first one with a Dynamic size, and it took over 10 minutes *just* to personalize the desktop for first login. The visual response is also terribly sluggish. This is the 4th Windows 7 VM I have installed this week on this computer. I always allocate 2GB of memory, and allow 4 processors, with all acceleration options and 128MB video memory. The allocations are done before the VM boots for the first time. Nothing else was running (including no other VM's) while building this VM.

In my previous attempts using VirtualBox ~2 years ago, it was the same way.

Re: Convert Dynamic to fixed-size virtualdisk

Posted: 11. Dec 2014, 12:46
by mpack
Pseudo Lee wrote:I found Fixed disks to be a LOT faster for installs.
Well naturally. That means you were filling up the drive, probably having just done a fresh OS install? This is precisely when the "grow" overhead is incurred (*). In normal use there is no such overhead. I.e. when the VM is new the disk grows quickly, but the size is capped so it can't grow forever. Very quickly the drive should reach its stable size which depends on your usage pattern and there is no more overhead. That's assuming you don't then do something dumb like create a snapshot, which basically tells the drive to start growing again.

Really, I don't understand why I need to keep saying this: the fixed and virtual formats are identical, so there cannot possibly be a built in (systemic) advantage except in terms of typical long term usage patterns: which IMHO favour dynamic allocation.

Fixed disks have no performance advantage. I'll concede that they might have better robustness, i.e. if you corrupt the header of a fixed size drive, and assuming you're a VDI expert, then you should be able to recover the drive image. I can see that being important say in a critical email server. However for most people an even better solution is to make regular backups of your VMs. That way even the noobiest of noobs can recover the data perfectly, and not have to suffer the downsides of fixed size congestion.

(*) That said, most people don't find the allocation overhead very noticeable. If you saw a big difference then it could imply that your host was having trouble finding space to allocate, which may mean you had a congested host drive - possibly caused by using fixed size virtual disks!

Re: Convert Dynamic to fixed-size virtualdisk

Posted: 11. Dec 2014, 14:07
by loukingjr
I tried creating a fixed disk for a guest a few years ago. It took so long to allocate the space I decided I wasn't going to do that again. Plus as mpack has said, I don't see any reason to have 100GB .vdis with <12GBs inside them. Whatever performance difference there may be between fixed and dynamic drives, I suspect the only way to even notice is to measure the difference. In the real world, dynamic drives seems to make the most sense and are the most practical.

Re: Convert Dynamic to fixed-size virtualdisk

Posted: 26. Aug 2016, 02:25
by bulblight
Apart from the fact that both formats are identical, there was no other way I could update my Ubuntu virtual server OS without converting dynamic to fixed disk.
This is because the drive size is scanned to check for adequate free space before the upgrade could commence.
An unfortunate real-world issue - solved with a hammer :lol:

Re: Convert Dynamic to fixed-size virtualdisk

Posted: 26. Aug 2016, 08:19
by socratis
@bulblight
I'm sorry, but what you said does not make sense. The guest doesn't even know what a dynamic or fixed disk is. They both appear as fixed to the guest. Unless you changed the size during the conversion, there is no way on this side of the universe that changing from dynamic to fixed would matter.

Re: Convert Dynamic to fixed-size virtualdisk

Posted: 26. Aug 2016, 08:20
by loukingjr
+1

Re: Convert Dynamic to fixed-size virtualdisk

Posted: 26. Aug 2016, 10:19
by mpack
bulblight wrote: This is because the drive size is scanned to check for adequate free space before the upgrade could commence.
As Socratis has said, that makes zero sense. You are confusing current size with capacity, and I frankly don't understand why people confuse the two. If you see a folded up carrier bag, do you immediately think "ooh, that's too small to carry anything"?

The capacity of a drive, whether fixed or dynamic, is fixed at the moment of creation and that is all the guest OS ever sees. The size merely reflects how much of that capacity has been used. In the case of fixed disk, it's all filled to the brim up front. With dynamic we fill it as our usage requires. The pros and cons of the two strategies was already discussed above.

Re: Convert Dynamic to fixed-size virtualdisk

Posted: 26. Aug 2016, 14:38
by The Raven
Only reason I've found so far to define a VDI as fixed was
when I needed one to be SHARED between guests - then it has be
created as fixed.

The biggest benefit for me with dynamic VDI's is the saving in
backup time. I take a weekly backup of my entire VirtualBox
configuration and if all my VDI's were fixed that would entail
backing up (or at least reading and compressing) a lot of empty
space in each vdi.

Re: Convert Dynamic to fixed-size virtualdisk

Posted: 26. Aug 2016, 17:55
by mpack
The Raven wrote:Only reason I've found so far to define a VDI as fixed was
when I needed one to be SHARED between guests - then it has be
created as fixed.
Do you have a reference for that?

Re: Convert Dynamic to fixed-size virtualdisk

Posted: 27. Aug 2016, 10:03
by The Raven
Section 5.4 of the User Guide ...

"Shareable hard disks are a variant of write-through hard disks. In principle they behave exactly the same, i.e. their state is not saved when a snapshot is taken, and not restored when a snapshot is restored. The difference only shows if you attach such disks to several VMs. Shareable disks may be attached to several VMs which may run concurrently. This makes them suitable for use by cluster filesystems between VMs and similar applications which are explicitly prepared to access a disk concurrently. Only fixed size images can be used in this way, and dynamically allocated images are rejected."

Note : My emphasis.

Re: Convert Dynamic to fixed-size virtualdisk

Posted: 27. Aug 2016, 10:12
by mpack
Hmm, I wasn't aware of that, thanks. I wonder why that restriction? I assume they were worried about the VDI growing in >1 contexts, but I don't see how its different from >1 pending writes to an existing block - presumably only the last write wins.