Mac OS displays incorrect guest size

Discussions related to using VirtualBox on Mac OS X hosts.
Post Reply
james.wilde
Posts: 11
Joined: 18. Nov 2008, 16:52

Mac OS displays incorrect guest size

Post by james.wilde »

I have a Windows 7 guest on Mac OSX. I made the disk to be dynamic, max 25 GB. I have installed Windows, and a few programs. Mac OSX tells me that my W7 guest occupies 26.75 GB on disk, nearly all of which is the disk. When I am in the guest I have checked the size of the different directories, and I get 8 GB for the Windows directory, and less than 0.5 GB each for three other directories, Users, Programs x86 and Programs. So where do the other 17 GB go?

Since I have chosen a dynamic disk size, I would expect that OSX would be showing something less than 9.5 GB.
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: Mac OS displays incorrect guest size

Post by mpack »

Did you read the user manual section on virtual storage? The size of a dynamic VDI is dictated by how many sectors have been written to. The contents of the guest filesystem are not important - that's a software matter, wherease VirtualBox is working at a (simulated) sector level. Deleting a file does not unwrite the data from the sector.

Also, I suspect you may not have recognized the distinction between binary and decimal GB. VirtualBox uses consistent units throughout its dialogs, hence 1GB in the RAM section means the same as 1GB in the storage section. Those are binary GBs (1GB == 2^30 bytes = 2097152 sectors). However hard disk manufacturers - and some operating systems - typically use decimal GBs (1GB = 10^9 bytes = 1953125 sectors) since it allows them to appear (to the unwary) to have larger disk capacities than they actually have. Programmers and other knowledgable computer users often prefer the binary notation because it's guaranteed to give you a round number of sectors, which the decimal notation doesn't. Plus it's useful to be consistent if you might expect 1GB RAM to be storable in 1GB of disk space.
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: Mac OS displays incorrect guest size

Post by socratis »

I was about to post what mpack said. Just to add some details, OSX measures them as is the SI system; 1 GB = 1000^3 B. Windows as 1 GB = 1024^3 B. There is a "movement" to move to Gibibytes and other binary units. See Wikipedia and NIST.
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
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: Mac OS displays incorrect guest size

Post by mpack »

socratis wrote:There is a "movement" to move to Gibibytes and other binary units. See Wikipedia and NIST.
Would those be the same guys who've been trying for 30 years to get us to say "octet" instead of "byte"? Not gonna happen... :-)
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: Mac OS displays incorrect guest size

Post by socratis »

Actually, if you're running a Linux-based OS with Nemo as the FileManager (I run Mint 15, Nemo 1.8.3), under Preferences -> Display, you'll see that it allows you to list the FileSize as "Binary".

Viva muchachos! La revolución ha comenzado! :D
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
james.wilde
Posts: 11
Joined: 18. Nov 2008, 16:52

Re: Mac OS displays incorrect guest size

Post by james.wilde »

Actually I'm not bothered by the fact that I set my disk to be 25 GB and it's showing as 26.5 GB. The difference between different types of GB are well known.

What baffles me is that a new instance, on which I have loaded the 8 GB of operating system and about ten files, is showing 26.5 GB of Mac disk in use when the total space taken up is about 9.5 GB. A dynamic disk in my understanding means that, if I have used 5 GB, it takes 5 GB, and when I add 2 GB more, it takes 7 GB and this will go on until I have reached the 25/26.5 GB limit I set when the disk was created. As far as I can see, what has happened is that my disk is not dynamic at all, but the whole enchilada is taken at once.
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: Mac OS displays incorrect guest size

Post by socratis »

james.wilde wrote:A dynamic disk in my understanding means that, if I have used 5 GB, it takes 5 GB
No, it doesn't. Read mpack's initial response.

- First of all, if you can't "afford" 25 GB, you should not have allocated 25 GB.
- Second, If you want to "shrink" your guest to its actual used size, try the following; run the "sdelete" tool (in your Win7 VM) from Microsoft's SysInternals. Then shut down your VM. Then run "VBoxManage modifyhd --compact <YourVM>.vdi".
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
james.wilde
Posts: 11
Joined: 18. Nov 2008, 16:52

Re: Mac OS displays incorrect guest size

Post by james.wilde »

socratis wrote:
james.wilde wrote:A dynamic disk in my understanding means that, if I have used 5 GB, it takes 5 GB
No, it doesn't. Read mpack's initial response.
This is what mpack said:

Code: Select all

The size of a dynamic VDI is dictated by how many sectors have been written to. The contents of the guest filesystem are not important - that's a software matter, wherease VirtualBox is working at a (simulated) sector level. Deleting a file does not unwrite the data from the sector.
This is my understanding of the term 'dynamic', too. If I write, say, 20000 sectors of half a MB each I have written 10 GB to my virtual disk, and I expect those 10 GB to be on consecutive sectors and take up 10 GB plus administrative space on my host hard disk. It's not as if I have written 25 GB to my guest and erased 15 GB and expect the whole to have returned to 10 GB. I do expect the host to write sectors sequentially, and that means I expect the host to show 10 GB of used space (note, not the VB control panel, but the host file system).
socratis wrote:- First of all, if you can't "afford" 25 GB, you should not have allocated 25 GB.
- Second, If you want to "shrink" your guest to its actual used size, try the following; run the "sdelete" tool (in your Win7 VM) from Microsoft's SysInternals. Then shut down your VM. Then run "VBoxManage modifyhd --compact <YourVM>.vdi".
It's not that I can't afford 25 GB. It's just that I don't want to be adding virtual disks every time I run out of space, so I set the max size to what seems like a reasonable level with reference to the planned use of the guest, and rely on VB not to take that max until I have used that amount.

Here's another interesting fact. The comments above refer to a Windows 7 guest on a Mac. I'm now writing from one of my linux boxes where I have six guests, two solaris, one ubuntu and three Windows 7. Here are the figures for these guests:

Code: Select all

               Max size               Size on disk  Size in guest

Solaris 10        16 GB                 4.8 GB
Solaris 11        16 GB                 2.7 GB
Ubuntu            20 GB                 6.1 GB
Windows 7           25 GB                13.6 GB         13.6 GB (Template for the other two W7 guests)
Windows 7           25 GB                20.8 GB         20.8 GB
Windows 7           25 GB                15.0 GB         15.0 GB
(The alignment in the above table is not perfect, but I think it is nonetheless readable)

It is apparent here that the virtual disks are, in fact, dynamic, including the Windows 7 disks. Why the template instance of Windows 7 should have a Windows directory 4 GB larger than the 8 GB one on my Mac is a bit of a mystery, but that being the case, the other two, which are clones, also have a 12 GB Windows directory, plus an insignificant extra in Users and Program Files for the one, and about 5 GB extra for the other. The size on disk is the size reported by the host file manager.

So it seems that VB on a Mac does not produce a dynamic disk at all, or else the Mac file manager reports incorrectly the amount of disk used by guests.

I assume, socratis, that the commands you gave me would reduce the size of the disk to the actual used size taken up by the guest, so that any extra programs or data would require a new virtual disk to be created. I think I'll try and go another way. I'll create a new guest with a smaller sized dynamic disk, and transfer all I have on the current one as best I can to the new, then destroy the current one.

I have just remembered that the Mac has a second guest running ubuntu. On checking this, I find that the VB directory for the ubuntu instance is 4.3 GB although the maximum size is 20 GB so I think it is clear that there is something wrong with the Windows 7 guest. Whether it is a VB problem or a Mac file manager problem, I cannot at the moment say, but creating a new instance should clear up the matter.
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: Mac OS displays incorrect guest size

Post by mpack »

I think the mistake you're making is to assume that current used space includes all the sectors that have ever been written to. On a modern OS that is usually not the case. And you may be assuming that dynamic disks shrink when files are deleted inside the guest, that's also not the case.

Incidentally, we have this discussion with someone every few weeks. We know there's no bug.
Post Reply