Skip to content

Instantly share code, notes, and snippets.

@moddingg33k
Created September 20, 2020 20:46
Show Gist options
  • Save moddingg33k/7e576e0faa05a8e495f07b6506fb3016 to your computer and use it in GitHub Desktop.
Save moddingg33k/7e576e0faa05a8e495f07b6506fb3016 to your computer and use it in GitHub Desktop.

Fill the free space of the disk with zeros

cat /dev/zero > zero.fill; sync; sleep 1; sync; rm -f zero.fill

Get a list of HDDs and the UUID of the virtual disk

VBoxManage.exe list hdds
VBoxManage.exe showhdinfo <disk>.vmdk

Convert to .VDI

VBoxManage.exe clonehd <disk>.vmdk <disk>.vdi --format vdi

Compact

VBoxManage.exe modifyhd <disk>.vdi --compact

Convert back to .VMDK

VBoxManage.exe clonehd <disk>.vmdk <disk>.vdi --format vmdk

Restore UUID (see step #2)

VBoxManage.exe internalcommands sethduuid <disk>.vmdk <original_UUID>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment