Virtual Size and Effective Size after shrink

Discussions related to using VirtualBox on Linux hosts.
Post Reply
PaoloHolzl
Posts: 3
Joined: 13. Jan 2023, 13:03

Virtual Size and Effective Size after shrink

Post by PaoloHolzl »

If I create a disk in Media Manager Virtual Size and Actual Size are similar.
I have reduced size of a vdi disk (Win10) from 300 to 65 Gb.
Is working without problem and the fisical file is shrinked, now in Media Virtual Manager Actual Size is 65Gb but Virtual Size remain 300.
So I have try to convert vdi Standard disk to fixed size disk, the new disk is 300Gb, I have compacted it, after compact same situazion Actual Size is 65 but Virtual Size remain 300.
Howto reduce Virtual Size?
What effect does it have to have a much larger virtualsize than the physical file?
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Virtual Size and Effective Size after shrink

Post by mpack »

PaoloHolzl wrote:If I create a disk in Media Manager Virtual Size and Actual Size are similar.
No they aren't, unless you create a fixed size disk. A dynamic disk is 2MB when first created.
PaoloHolzl wrote: I have reduced size of a vdi disk (Win10) from 300 to 65 Gb.
How did you do that? VirtualBox does not provide a disk shrinkage feature.
PaoloHolzl wrote: So I have try to convert vdi Standard disk to fixed size disk, the new disk is 300Gb
Why on earth would you do that? Also you can't compact a fixed size disk. Fixed size disks have... fixed size.
PaoloHolzl wrote: What effect does it have to have a much larger virtualsize than the physical file?
Why do you expect an effect? This is like having a shopping bag which you normally keep folded. When you fill it with stuff the volume will grow. There is no disadvantage attached to keep it folded when not full. And it's usually more convenient (for the host) if it doesn't fill space unnecessarily.
PaoloHolzl
Posts: 3
Joined: 13. Jan 2023, 13:03

Re: Virtual Size and Effective Size after shrink

Post by PaoloHolzl »

mpack wrote:
PaoloHolzl wrote:If I create a disk in Media Manager Virtual Size and Actual Size are similar.
No they aren't, unless you create a fixed size disk. A dynamic disk is 2MB when first created.

Ok but after shrink virtual size is 300Gb real 10Gb (file size).
PaoloHolzl wrote: I have reduced size of a vdi disk (Win10) from 300 to 65 Gb.
How did you do that? VirtualBox does not provide a disk shrinkage feature.

It is not simple but the system exists.
For a guest system Win you need resize partitions, use program sdelete (download from Microsoft),
Use VBoxManage modifymedium disk diskname.vdi --compact.
You can simply find detail on Internet.
PaoloHolzl wrote: So I have try to convert vdi Standard disk to fixed size disk, the new disk is 300Gb
Why on earth would you do that? Also you can't compact a fixed size disk. Fixed size disks have... fixed size.

Ok but if you have a vdi created of 100 Gb and you need only 20 Gb is better reduce IT for disk space, backup ...
PaoloHolzl wrote: What effect does it have to have a much larger virtualsize than the physical file?
Why do you expect an effect? This is like having a shopping bag which you normally keep folded. When you fill it with stuff the volume will grow. There is no disadvantage attached to keep it folded when not full. And it's usually more convenient (for the host) if it doesn't fill space unnecessarily.
Ok but if I know that at most I will put 10 kg of stuff into the bag each time, I don't want a one meter bag * one meter.
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Virtual Size and Effective Size after shrink

Post by scottgus1 »

PaoloHolzl wrote:in Media Virtual Manager Actual Size is 65Gb but Virtual Size remain 300.
The Virtual Size is the upper limit that the disk file will grow to.

So the Actual size of the disk file is 65GB today. It can grow to 300GB in the future if the host OS decides to write to the whole disk for whatever reason.

If you no longer want the disk file to grow to 300GB on the host, then after you have the disk file compacted, go into the VM OS's partition manager and shrink the main data partition until all partitions total the final smaller size you want the disk to limit out at. Then the OS will only write to that new smaller partition size and the disk file won't get used the rest of the way on the host.

All of the above applies only to dynamic disk files, not fixed-size disk files.
Post Reply