Page 1 of 2

How do convert dynamic to static vdi?

Posted: 1. Dec 2008, 17:58
by skoehler
Hi,

i have found out, that i can convert a static vdi into a dynamically growing vdi by executing

Code: Select all

VBoxManage modifyvdi myfile.vdi compact
Now is there a way to convert that file back back to static vdi again?

Posted: 1. Dec 2008, 20:43
by TerryE
The only way is disk-to-disk copy as discussed in my tutorial All about VDIs.

Dynamic VDIs have a lot of benefits. Static VDIs have some as well. However, I am at a loss as to why you would want to go static->dynamic->static again. Why, what is your thinking here?

Posted: 1. Dec 2008, 20:51
by skoehler
TerryE wrote:The only way is disk-to-disk copy as discussed in my tutorial All about VDIs.

Dynamic VDIs have a lot of benefits. Static VDIs have some as well. However, I am at a loss as to why you would want to go static->dynamic->static again. Why, what is your thinking here?
What do you mean by "disk-to-disk copy" ?
To be more precise: is there a way to convert a dynmic to a static vdi using VBoxManage only?

Actually, i created a 32GB static vdi (that took ages!) and installed Windows XP. Then i compacted it. Now it's a dynamic vdi.

So now i'm not quite sure, if compacting was the right kind of thing for me. Maybe i'm better off using a static vdi. So i'm looking for a ways back, just in case that one day i regret the switch to a dynamic vdi.


Actually, what i'd really be looking for is a way to use a physical partition like /dev/sda2 in VirtualBox.

Posted: 1. Dec 2008, 21:44
by TerryE
skoehler, when I write a tutorial which answers most of you Qs and a lot more, then perhaps you can do me the courtesy of at least looking at it before asking me the Qs again :)

No there isn't a VBoxManage command to convert from dynamic to static VDIs, you have to use the guest-based approach that I describe.

One of the nice features of VDIs is the ability to use snapshots. If you use snapshots then there is little point in using static VDIs.

If you want to install to a physical partition research createrawvmdk in the User Guide and forum topics.

Re: How do convert dynamic to static vdi?

Posted: 6. Aug 2009, 03:14
by ctryon
Hummm... I looked through the tutorial, but I didn't see anything about changing from dynamic to static VDI files. (Lots of other useful information, but not that...)

It would be interesting to see some comparisons between the two. I know I've done some testing with other products like VMware, and there is a noticeable improvement in performance with statically defined virtual disks. Not always enough to offset the advantage of dynamic disks, but enough to think about....
--
Chuck

Re: How do convert dynamic to static vdi?

Posted: 6. Aug 2009, 08:53
by vbox4me2
ctryon wrote:Hummm... I looked through the tutorial, but I didn't see anything about changing from dynamic to static VDI files. (Lots of other useful information, but not that...)
Its the same procedure as resizing a VDI, see also the FAQ.

Re: How do convert dynamic to static vdi?

Posted: 6. Aug 2009, 11:38
by TerryE
ctryon wrote:I know I've done some testing with other products like VMware, and there is a noticeable improvement in performance with statically defined virtual disks.
Nope, sorry but there's no material difference. I've done benchmarking posts previously.

Re: How do convert dynamic to static vdi?

Posted: 18. May 2010, 18:01
by rsaavedra
TerryE wrote:
ctryon wrote:I know I've done some testing with other products like VMware, and there is a noticeable improvement in performance with statically defined virtual disks.
Nope, sorry but there's no material difference. I've done benchmarking posts previously.
The tutorial itself indicates that when the host OS drive is fragmented there can be a penalty performance though.

I installed VirtualBox in a WinXP NTFS drive that (according to WinXP) did not require defragmentation. Created a VM and Installed Ubuntu in it using a dynamic vdi. Used this Ubuntu for a couple of days, and then realized the VDI had grown, and when I checked the fragmentation in WinXP, it suggested that the drive should be defragmented. Because of this I'm thinking about converting the vdi to static.

Re: How do convert dynamic to static vdi?

Posted: 19. May 2010, 06:42
by mpack
rsaavedra wrote:Because of this I'm thinking about converting the vdi to static.
That would be a crazy decision. Ok, so you think you've detected that dynamic VDIs cause host fragmentation (not true, but let that pass). So where is your experiment to prove that fixed VDIs don't do the same?

Fixed vs Dynamic is a mere detail about the internal structure of the VDI file. As far as the host OS is concerned the only visible difference is that one of these files tends to be larger - i.e. the fixed one. Fragmentation of the host is much more likely with the larger (fixed) VDI, because the host is much less likely to have (say) 60GB contiguous free than it is to have 3GB contiguous free. Note that I'm discussing this because you raised it as a concern: in fact there is little basis for any concern since one quick defrag session will fix any problems in either case (in the dynamic VDI case it's best to leave host defrag until after you've installed your guest apps).

A fixed VDI is a humungous disk space hog, and there is really no convincing benefit IMHO.

Re: How do convert dynamic to static vdi?

Posted: 19. May 2010, 22:41
by Sasquatch
Mpack, you seem to forget the way files are written to the hard drive. As you stated, with static VDIs it's more likely to be fragmented due to the lack of contiguous space, but a dynamic VDI has the same limitation. Say it gets created in a spot with 2 GB of space, then grows to 4 GB. It will then be in at least two parts: one to fill the 2 GB gap and the rest at whatever spot the system likes it to be.
Also, one defrag pass might not be enough to make it one contiguous file.

Having one big file is a downside for the Host itself, because if you create a 50 GB VDI, it will occupy 50 GB, but you might be using just 10% of that (5 GB) or even decide to partition it just like that so you have some spare space in case your initial allocation is too small.
Other than that, dynamic have a bigger advantage due to the file size it has. I has a smaller chance to get fragmented and if it does, a defrag is a lot faster for smaller files than one huge one.

Re: How do convert dynamic to static vdi?

Posted: 29. May 2010, 23:41
by TedWalther
The reason to convert dynamic to static vdi is so that you can mount the vdi filesystems. I use VirtualBox to compile Debian and Ubuntu packages for various releases and architectures. If I could mount the vdi directly, it would make it much easier to keep the sources consistent. I could upload my source, then only need to boot up the vdi and run dpkg-buildpackage; it would be easier to keep all the build trees consistent on each different vdi.

So, for my purposes, converting dynamic to static is important; the space savings aren't worth the extra time it takes to boot up all the boxes every time there is a new upstream release.

Also, it seems that each virtualbox is grabbing the same MAC address, and so I can only run one at a time because there are stray interrupts that crash things. (I'm running VirtualBox under Ubuntu Lucid) Anyone know anything about this?

Re: How do convert dynamic to static vdi?

Posted: 30. May 2010, 09:17
by mpack
TedWalther wrote:The reason to convert dynamic to static vdi is so that you can mount the vdi filesystems.
I guess that's a practical reason, though not one that appeals to me.
TedWalther wrote:Also, it seems that each virtualbox is grabbing the same MAC address ... Anyone know anything about this?
That is off-topic. You should start your own thread if you wish to discuss something other than the OPs question.

Re: How do convert dynamic to static vdi?

Posted: 17. Aug 2010, 20:07
by rsaavedra
mpack wrote:
rsaavedra wrote:Because of this I'm thinking about converting the vdi to static.
That would be a crazy decision.
Don't see why you think so.

First of all, my virtual disks are not 50 gb but 8 gb each. (but even if, please read further.) Second, when creating the 8 gb fixed, the file may end up fragmented, true. But then I can defragment the host's drive just once (and for the record, I defrag not with the Windows tool but with Defraggler, which can ensure 100% defragmentation.) After that, the vdi file ends up contiguous on the host drive, and whatever happens after that inside that file won't ever affect the fragmentation of the host's drive (or will it?) That's the big difference.

When the vdi is dynamic, you have to keep defragmenting the host every so often with each subsequent growth of that vdi file, because said growth contributes to the fragmentation of your host's drive. When the vdi is fixed, you just defragment once, right after that vdi gets created, and the fragmentation of your host will thenceforth never be aggravated by that guest's disk. (Or will it?)

Re: How do convert dynamic to static vdi?

Posted: 17. Aug 2010, 21:03
by mpack
rsaavedra wrote:
mpack wrote:
rsaavedra wrote:Because of this I'm thinking about converting the vdi to static.
That would be a crazy decision.
Don't see why you think so.
I gave the reason in my original message: i.e. that the person I responded to had given insufficient evidence to justify his conclusion, because he had benchmarked one side of the equation and only made assumptions about the other side. I did not say that his conclusion was wrong.

On your general proposition, I don't really care to get into a fixed vs dynamic debate because that's a matter of personal taste. My own personal taste is that I don't want a virtual drive permanently hogging 32GB of host disk space unless there is an astonishingly big advantage for doing so. I'm not aware of such an advantage, certainly not a big performance advantage for either host or guest.

I also suggest both that 32GB is a reasonable size for a Windows system drive and that 8GB is way too small: a drive that small will quickly become congested and performance will drop off. I assume you chose such a small size because you were trying to avoid hogging the host drive with a fixed size image: i.e. you have concerns about using fixed images too.

Re: How do convert dynamic to static vdi?

Posted: 18. Aug 2010, 18:01
by rsaavedra
mpack wrote:I also suggest both that 32GB is a reasonable size for a Windows system drive and that 8GB is way too small: a drive that small will quickly become congested and performance will drop off. I assume you chose such a small size because you were trying to avoid hogging the host drive with a fixed size image: i.e. you have concerns about using fixed images too.
My 8GB disks were not intended for Windows, but for Debian and Ubuntu server plain installations + updates. The 8 GB disks are being used as sort of master images for testing servers. Just avoiding going through the actual os installation and then getting the updates all over again with every new testing server needed.