[Solved] unable to shrink dynamic vdi file virtual size

Discussions related to using VirtualBox on Windows hosts.
Post Reply
Jobe76
Posts: 10
Joined: 6. Dec 2020, 19:23

[Solved] unable to shrink dynamic vdi file virtual size

Post by Jobe76 »

I just tried to shrink a dynamic vdi's virtual size file from 98gb to 50, but got a strange error;

Code: Select all

T:\Torris>VBoxManage modifyhd Torris.vdi --resize 50000
0%...
Progress state: VBOX_E_NOT_SUPPORTED
VBoxManage.exe: error: Failed to resize medium
VBoxManage.exe: error: Shrinking is not yet supported for medium 'T:\Torris\Torris.vdi'
VBoxManage.exe: error: Details: code VBOX_E_NOT_SUPPORTED (0x80bb0009), component MediumWrap, interface IMedium
VBoxManage.exe: error: Context: "enum RTEXITCODE __cdecl handleModifyMedium(struct HandlerArg *)" at line 816 of file VBoxManageDisk.cpp
This is the information about the vdi;

Code: Select all

UUID:           b0646904-5d7d-48f6-99b2-3ab1f7ac05b5
Parent UUID:    base
State:          created
Type:           normal (base)
Location:       T:\Torris\Torris.vdi
Storage format: VDI
Format variant: dynamic default
Capacity:       100352 MBytes
Size on disk:   22838 MBytes
Encryption:     disabled
Property:       AllocationBlockSize=1048576
isn't it possible to change the "max" size if the real size is smaller than the new size, or am I just having a meltdown?
Last edited by Jobe76 on 6. Dec 2020, 22:13, edited 2 times in total.
multiOS
Volunteer
Posts: 1227
Joined: 14. Sep 2019, 16:51
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows, Linux, BSD
Location: United Kingdom

Re: unable to shrink dynamic vdi file

Post by multiOS »

See the VirtualBox Manual entry "8.22 VBoxManage modify medium" - Pages 177-178 in the Version 6.1.16 Manual.

Third bullet item "The --compact option can be used to compact disk images. Compacting removes blocks that only contains zeroes. Using this option will shrink a dynamically allocated image......."
Jobe76
Posts: 10
Joined: 6. Dec 2020, 19:23

Re: unable to shrink dynamic vdi file

Post by Jobe76 »

multiOS wrote: "The --compact option can be used to compact disk images. ..."
Yes, but I'm trying to shrink the virtual space from 98 to 50, not have actual space (which now is 21gb)
multiOS
Volunteer
Posts: 1227
Joined: 14. Sep 2019, 16:51
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows, Linux, BSD
Location: United Kingdom

Re: unable to shrink dynamic vdi file

Post by multiOS »

O.K. if you read on the only options currently available are to expand and not shrink VDIs. The workaround having compacted the VDI is to use a partitioning tool to reduce the size of the allocated partition(s) in the Virtual Machine to the size you want and leave the rest of the space as unallocated, then the true physical size cannot 'expand' beyond the boundary of the allocated partition(s), although the size of the VDI will still show the size originally allocated.
Jobe76
Posts: 10
Joined: 6. Dec 2020, 19:23

Re: unable to shrink dynamic vdi file virtual size

Post by Jobe76 »

Ah, great suggestion, that should work as a workaround...
Post Reply