How do convert dynamic to static vdi?

This is for discussing general topics about how to use VirtualBox.
skoehler
Posts: 117
Joined: 1. Dec 2008, 12:12

How do convert dynamic to static vdi?

Post 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?
TerryE
Volunteer
Posts: 3572
Joined: 28. May 2008, 08:40
Primary OS: Ubuntu other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Ubuntu 10.04 & 11.10, both Svr&Wstn, Debian, CentOS
Contact:

Post 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?
Read the Forum Posting Guide
Google your Q site:VirtualBox.org or search for the answer before posting.
skoehler
Posts: 117
Joined: 1. Dec 2008, 12:12

Post 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.
TerryE
Volunteer
Posts: 3572
Joined: 28. May 2008, 08:40
Primary OS: Ubuntu other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Ubuntu 10.04 & 11.10, both Svr&Wstn, Debian, CentOS
Contact:

Post 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.
Read the Forum Posting Guide
Google your Q site:VirtualBox.org or search for the answer before posting.
ctryon
Posts: 1
Joined: 5. Aug 2009, 22:58
Primary OS: Fedora other
VBox Version: OSE Fedora
Guest OSses: Windows, Linux

Re: How do convert dynamic to static vdi?

Post 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
vbox4me2
Volunteer
Posts: 5218
Joined: 21. Nov 2008, 20:27
Location: Rotterdam
Contact:

Re: How do convert dynamic to static vdi?

Post 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.
TerryE
Volunteer
Posts: 3572
Joined: 28. May 2008, 08:40
Primary OS: Ubuntu other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Ubuntu 10.04 & 11.10, both Svr&Wstn, Debian, CentOS
Contact:

Re: How do convert dynamic to static vdi?

Post 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.
Read the Forum Posting Guide
Google your Q site:VirtualBox.org or search for the answer before posting.
rsaavedra
Posts: 7
Joined: 18. May 2010, 15:47
Primary OS: MS Windows XP
VBox Version: OSE other
Guest OSses: Ubuntu, Debian, Puppy Linux

Re: How do convert dynamic to static vdi?

Post 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.
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Mostly XP

Re: How do convert dynamic to static vdi?

Post 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.
Sasquatch
Volunteer
Posts: 17798
Joined: 17. Mar 2008, 13:41
Primary OS: Debian other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows XP, Windows 7, Linux
Location: /dev/random

Re: How do convert dynamic to static vdi?

Post 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.
Read the Forum Posting Guide before opening a topic.
VirtualBox FAQ: Check this before asking questions.
Online User Manual: A must read if you want to know what we're talking about.
Howto: Install Linux Guest Additions
Howto: Use Shared Folders on Linux Guest
See the Tutorials and FAQ section at the top of the Forum for more guides.
Try searching the forums first with Google and add the site filter for this forum.
E.g. install guest additions site:forums.virtualbox.org

Retired from this Forum since OSSO introduction.
TedWalther
Posts: 1
Joined: 29. May 2010, 23:30
Primary OS: Ubuntu other
VBox Version: OSE other
Guest OSses: Debian, Ubuntu

Re: How do convert dynamic to static vdi?

Post 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?
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Mostly XP

Re: How do convert dynamic to static vdi?

Post 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.
rsaavedra
Posts: 7
Joined: 18. May 2010, 15:47
Primary OS: MS Windows XP
VBox Version: OSE other
Guest OSses: Ubuntu, Debian, Puppy Linux

Re: How do convert dynamic to static vdi?

Post 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?)
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Mostly XP

Re: How do convert dynamic to static vdi?

Post 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.
rsaavedra
Posts: 7
Joined: 18. May 2010, 15:47
Primary OS: MS Windows XP
VBox Version: OSE other
Guest OSses: Ubuntu, Debian, Puppy Linux

Re: How do convert dynamic to static vdi?

Post 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.
Post Reply