Guest Disk Space to Host File Space Mismatch

This is for discussing general topics about how to use VirtualBox.
Post Reply
MattC13
Posts: 33
Joined: 7. Feb 2020, 22:53

Guest Disk Space to Host File Space Mismatch

Post by MattC13 »

Hi, I'm finding this difficult to understand. The disk space in the VM (Win10) is showing around 20GB used. The vdi file in the host is showing 14GB. I could understand it if it was the other way round as the vdi does not contract, even if the guest disk usage is reduced. But I don't understand the vdi being smaller than the guest's. Does Vb use compression with its vdi? If not, can anyone explain this?

Matt
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Guest Disk Space to Host File Space Mismatch

Post by scottgus1 »

I don't think Virtualbox uses compression in VDI, but Windows compresses some things in its installation.

Please use Upload Attachment to show a screenshot inside the VM of the disk's Properties tab. Also, please run these commands in the host's Command Prompt or Terminal Window:

(this one if it's a Windows host:)
CD C:\Program Files\Oracle\Virtualbox

vboxmanage showmediuminfo "path\to\\drive\file.vdi"
fth0
Volunteer
Posts: 5668
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: Guest Disk Space to Host File Space Mismatch

Post by fth0 »

MattC13 wrote:If not, can anyone explain this?
Windows cannot count! ;)

Seriously, Windows 10 uses hardlinks for many of its own installed files (e.g. *.exe, *.dll). Open a command prompt and enter the following command:

Code: Select all

fsutil hardlink list c:\windows\notepad.exe
The output will probably look like:

Code: Select all

\Windows\System32\notepad.exe
\Windows\notepad.exe
\Windows\WinSxS\amd64_microsoft-windows-notepad_31bf3856ad364e35_10.0.19041.1081_none_e3f87355251e8c43\notepad.exe
If you use the Properties dialog of Explorer on any of those files, it will tell you that their size on disk is approximately 200 kB. If you use the Properties dialog of Explorer on the c:\windows folder, all three of them account for approximately 600 kB. But this simply isn't true. ;)

In addition to that, Windows 10 uses file compression (e.g. in C:\Program Files\WindowsApps) and sparse files, and VirtualBox will not allocate VDI blocks for 1 MB blocks containing only zeroed bytes.
Post Reply