[Solved] Confusing .vdi size host vs guest.

Discussions about using Windows guests in VirtualBox.
Post Reply
loukingjr
Volunteer
Posts: 8851
Joined: 30. Apr 2009, 09:45
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: just about all that run

[Solved] Confusing .vdi size host vs guest.

Post by loukingjr »

I have a Windows 8.1 guest which is working fine but, it has a 40GB dynamic .vdi of which 21.3GBs is being used. However, the host reports the .vdi file as 42.59GBs(?). The guest was cloned from a Windows 7 guest using the VirtualBox Manager then upgraded to Windows 8.1. The Windows 7 .vdi (34.89GBs) file is smaller than the Windows 8.1 .vdi even though it is using 28.5GBs.

It doesn't matter I suppose since the guests work fine but I'm curious how this happened.
Last edited by loukingjr on 25. Feb 2015, 13:19, edited 1 time in total.
OSX, Linux and Windows Hosts & Guests
There are three groups of people. Those that can count and those that can't.
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: Confusing .vdi size host vs guest.

Post by mpack »

You say "the host reports". Where does it do that? Can you provide a screenshot?

At the moment this is sounding like a standard confusion of binary vs decimal GB. I.e. 40GB = 40*(1024^3) = 42.95e10^9 bytes.

AFAIK VirtualBox always uses binary derived units, and does so consistently for all quantites. So AFAIK it would never report the 42.95gB figure.
loukingjr
Volunteer
Posts: 8851
Joined: 30. Apr 2009, 09:45
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: just about all that run

Re: Confusing .vdi size host vs guest.

Post by loukingjr »

Don, if you really want a screenshot I can provide one of course. But every guest I have reports the file size of a .vdi as the approx amount used since I don't use fixed disks. So if I have 10 guests that have a 40gb .vdi and say half is filled, the host reports the file size as 20GB give or take except for the one Windows 8.1 guest. Which reports 42,586,865,664 bytes or 42.59 GB even though only 21.3 GBs are being used.

The question is for me, why one particular guest is reporting 40 GB give or take rather than the amount used which is 21.3 GBs.

FWIW, I have 25 guests currently and they all are the size I expect except for the Windows 8.1 guest.
OSX, Linux and Windows Hosts & Guests
There are three groups of people. Those that can count and those that can't.
loukingjr
Volunteer
Posts: 8851
Joined: 30. Apr 2009, 09:45
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: just about all that run

Re: Confusing .vdi size host vs guest.

Post by loukingjr »

I had an idea so I decided to test it. Here's the steps…
1. Started the Windows 8.1 guest.
2. Took a Snapshot.
3. Copied a 4GB .iso to the guest (W10 TP, not that it matters :) )
4. Shutdown the guest.
5. Deleted the Snaphot.

The .vdi file grew to 42,694,868,992 bytes (42.69 GB) from it's previous size on the host disk. So it looks like despite the guest having an assigned 40GB dynamic drive, the space it takes up on the host can exceed 40GB. As matter of fact, if I kept repeating the test, I could have a 40GB guest that takes up 60GBs or more on the host.

I don't know why it does that but it's interesting.

I suspect the reason it takes up more than 40GBs on the host in the first place is because I created it by cloning a Windows 7 guest, took a snapshot, ran the 8.1 upgrade, then deleted the snaphot.
OSX, Linux and Windows Hosts & Guests
There are three groups of people. Those that can count and those that can't.
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: Confusing .vdi size host vs guest.

Post by mpack »

I still don't know what you're telling me. A VDI can't grow to more than the capacity+[fixed header overhead]. Snapshots are independant VDIs each with their own independant storage requirements... I'm not sure why you mentioned them.

And we need to agree on units if this discussion is going to be fruitful: 42,694,868,992 bytes is a tad less than 40GB, it is not 42GB. I don't do powers of 10, neither does VirtualBox.

As to the disparity between guest reported size and host reported size, they usually won't be the same unless you compact the drive. The best you can say is that the former usually can't exceed the latter (unless there's been a lot of zeros written).
loukingjr
Volunteer
Posts: 8851
Joined: 30. Apr 2009, 09:45
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: just about all that run

Re: Confusing .vdi size host vs guest.

Post by loukingjr »

Don, my point isn't about whether the host says a .vdi is 40GBs or 42GBs. The Windows 8.1 guest as I have mentioned is only using approx. 21.4 GB with 18.4GBs of Free space. My understanding was, a .vdi file will only take up as much HD space on the host as the .vdi contains. That seems to be the case with all my other guests. So I would expect the Windows 8.1 .vdi to be taking only 21.4GBs on the host, not 40ish. For example, I have a Windows 10 guest with an 32GB drive assigned. The .vdi file size on the host is just over 10GBs which is also the used space on the guest. Which is how 24 out of 25 guests seem to behave.

Maybe screenshots will help…
The first one is what my Mac host reports.
The second, from inside the Windows 8.1. guest.
Attachments
Screen Shot 2015-02-25 at 6.00.37 AM.png
Screen Shot 2015-02-25 at 6.00.37 AM.png (24.52 KiB) Viewed 1678 times
Screen Shot 2015-02-25 at 5.59.18 AM.png
Screen Shot 2015-02-25 at 5.59.18 AM.png (26.63 KiB) Viewed 1678 times
OSX, Linux and Windows Hosts & Guests
There are three groups of people. Those that can count and those that can't.
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: Confusing .vdi size host vs guest.

Post by mpack »

loukingjr wrote:My understanding was, a .vdi file will only take up as much HD space on the host as the .vdi contains.
As the disk contains, yes. Which is quite different from "what the filesystem contains" (used space inside the guest).

When the guest writes to a previously unwritten disk sector, VirtualBox allocates host space. There is no opposite process short of manual compaction.

So, all that guest OS image is telling you is that it's currently using less than its peak amount. Windows guests are not special in this regard, though perhaps their usage patterns may be different.
loukingjr
Volunteer
Posts: 8851
Joined: 30. Apr 2009, 09:45
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: just about all that run

Re: Confusing .vdi size host vs guest.

Post by loukingjr »

So, I take it the reason why the file grew so large was because I updated a cloned W7 guest to a W8.1 guest which nearly maxed out the .vdi size in the process.

edit: I'm usually not this slow. :D
OSX, Linux and Windows Hosts & Guests
There are three groups of people. Those that can count and those that can't.
Post Reply