Change a VirtualBox dynamic disk size on MacOS

When creating a dynamic disk VirtualBox asks you to specify the maximum size. If the max dynamic disk size needs changing after its initial creation we cannot use the VirtualBox interface, instead we need the VBoxManage command line tool.

1. Shutdown the VM and quit VirtualBox
2. Open the Terminal app and use the following command to navigate to the VirtualBox app directory
cd /Applications/VirtualBox.app/Contents/Resources/VirtualBoxVM.app/Contents/MacOS/
3. Now in the proper directory, you’re ready to run the resize command with the following syntax:
VBoxManage modifyhd –resize [new size in MB] [/path/to/vdi]
Example:
VBoxManage modifyhd –resize 30000 ~/Documents/VM/Windows10.vdi
4. If desired, verify the change has taken place with the showhdinfo command:
5. Launch VirtualBox and boot renewly resized VM

Reclaiming space from VirtualBox on MacOS

Dynamic disks tend to be the preferred choice for virtual disk images as they only use the physic disk space they need. However while VirtualBox is a very good free virtual machine application, the dynamic disks are much better expanding than shrinking. While commercial tools such as VMWare and Parallels have a one click/automatic way to reclaim physical disk space, VirtualBox needs a little manual intervention.

The following steps will give you some physical disk space back, its a good idea to run these after a major service pack install or after removing a large application from your virtual machine. Steps 1-5 is recommend regardless of which VM application you are running as this frees space on the virtual machine.

1. Delete unwanted files
2. Run Windows Clean Up, use the advanced option to remove windows update files.
3. Empty Recycle Bin
4. Defrag
5. Clean garbage bits and bytes using SDelete by Windows Sysinternals, after installation open cmd and type

sdelete.exe C: -z

6. Shutdown Windows VM and close VirtualBox
7. Open Terminal app and enter

cd /Applications/VirtualBox.app/Contents/Resources/VirtualBoxVM.app/Contents/MacOS/

8. Then enter

VBoxManage modifyhd –compact “[/path/to/vdi]”