Unable to shrink .vdi file

Discussions related to using VirtualBox on Windows hosts.
Post Reply
pclin
Posts: 2
Joined: 21. Sep 2012, 15:13

Unable to shrink .vdi file

Post by pclin »

I allocated (dynamically) 40GB for a Windows XP (32 bits) guest. The size of the .vdi file was originally about 26GB.
After deleting many large files on the guest (only about 9GB remained), the file size remained the same.
Hence I followed the common steps found on the websites to shrink the .vdi file.
That is, defrag --> sdelete -c --> VBoxManage modifyhd --compact.

Unfortunately, the .vdi size became nearly 40GB. I tried to use "VBoxManage modifyhd --compact" to
shrink the .vdi file again, but the file size was still the same. I checked the hdinfo with the command

C:\Program Files\Oracle\VirtualBox>VBoxManage.exe showhdinfo vdi_file

Accessible: yes
Logical size: 40960 MBytes
Current size on disk: 39508 MBytes
Type: normal (base)

It seems that Virtualbox thinks the disk is nearly full, but on the Windows XP guest, the available
disk space is about 31GB. Both values differ significantly.

How can I make Virtualbox believe there is still much disk space available on the guest, and shrink the
vdi file accordingly? The Virtualbox version is 4.2.0, and the host is Windows 7 64 bits. Many thanks.
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: Unable to shrink .vdi file

Post by mpack »

See the CloneVDI sticky at the top of this forum. Read the release notes you find inside the zip. Check out the "Compact" option. Send someone to slap whoever advised you to go that crappy old sdelete + VBoxManage route.
Post Reply