This is the intended purpose of VirtualBox’s dynamic allocation feature, but it doesn’t work withLinux guests.
This is due to how Linux manages its filesystems and how it interacts with its VirtualBox host.
Here’s how it’s done.
Corbin Davenport / How-To Geek
If it is not, you will need toconvert your disk to a dynamically allocated disk.
Next,back up your virtual disk.
Be careful using the dd command as it will overwrite data without warning!
Check your commands and paths carefully before running them.
The final step is to use the vboxmanage command to compact the virtual disk image.
What Did the dd Linux Command Do?
Thedd(data duplicator) command converts and copies files, and can also be used to write data.
This will continue until the disk is full as /dev/zero never stops providing null data.
Using VboxManage.exe in Windows
By default, VBoxManage.exe isn’t available on the Windows command line.
This lets you use spaces in path to the executable.