Skip to content

Instantly share code, notes, and snippets.

@tovbinm
Created March 21, 2012 20:18
Show Gist options
  • Save tovbinm/2152446 to your computer and use it in GitHub Desktop.
Save tovbinm/2152446 to your computer and use it in GitHub Desktop.
vbox tricks
1. Open terminal inside your virtual machine and run:
sudo dd if=/dev/zero of=EMPTY bs=1M
sudo rm ./EMPTY
This will zeroify all the empty blocks on your disk.
2. Shutdown you virtual box.
3. Check what type of virtual drive do you have: VMDK or VDI. VirtualBox shrinking works only with VDI files.
If you have a VDI file, proceed to the last step, otherwise you'll need to perform an additional step of converting your VMDK file
to VDI format, using qemu as follows.
Install qemu by typing in mac terminal: sudo port install qemu
Convert your disk file to raw format: /opt/local/bin/qemu-img convert <path-to-your-virtual-disk-file.vmdk> <path-to-output.raw>
Convert your disk from raw to vdi: /Applications/VirtualBox.app/Contents/MacOS/VBoxManage convertfromraw <path-to-output.raw> <path-to-your-new-virtual-disk-file.vdi>
3. Open your mac terminal and type:
/Applications/VirtualBox.app/Contents/MacOS/VBoxManage modifyhd <path-to-your-virtual-disk-file.vdi> --compact
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment