So the installation instructions that involve VirtualBox include this highlighted note:
By default VirtualBox does not free up unused disk space. To automatically shrink the vdi disk image the discard option must be enabled:
VBoxManage storageattach <VM name> --storagectl "SATA" --port 0 --device 0 --nonrotational on --discard on
Where do I type this command?
And what if I don’t do it?
What happens eventually if VirtualBox does not free up unused disk space?
Everything else in my Home Assistant install is working just great,
but I am wondering how to do this last thing,
and worried about what will happen if I don’t do it.
Google has brought me here while I was searching for a solution to compact my vdi file. So I am going to provide some summary here even though it does not 100% aligned to the initial question. The answer to the initial question is just above my comment by miles.beattie.
I will start with the issue. Even though I have followed the instruction and confirmed that the virtual drive was mounted as SSD (nonrotational on) and supported trim (discard on) the size of the vdi file was not changing after removing some big files from the system.
I have confirmed the config with the virtualbox machine definition file. I have even logged in as root and run hdparm -I /dev/sda expecting to see Data Set Management TRIM supported (limit unknown). But I haven’t. Probably there is still something I have done wrong while following the instructions but… no clue how to continue.
The solution
For me the current solution is to use CloneVDI tool by mpack “site moderator for forums.virtualbox.org”. I have just executed that tool on my VDI and the result was this
So if you are like me looking for a working solution to trim or compact your home assistant VDI for VirtualBox - this is what has worked for me.