Here are a couple of tips and tricks for Oracle VirtualBox. At the time of writing this blog the latest version of VirtualBox is 4.1. The VirtualBox commands that follow is run in Windows but is more or less the same in Linux environments.

Tip 1 – Clone existing Virtual disk

In command line go to the path of where VirtualBox is installed because you are going to need access to the program VBoxManage. Windows command to change path: cd "C:\Program Files\Oracle\VirtualBox"

Command to clone an existing vdi file:

VBoxManage clonehd "path_to_source_image.vdi" "path_to_destination_image.vdi"

From version 4.1 there is an menu option to clone existing images in the VirtualBox Manager GUI.

Tip 2 – Clone existing Virtual disk to raw format

Cloning an existing image file to raw makes an copy of the image without any compression to the vdi format.

Command to clone to raw file:

VBoxManage clonehd --format RAW “path_to_source_image.vdi” “path_to_destination_image.raw”

Tip 3 – Convert raw image to vdi format

If you have an raw image you can convert it to the compressed vdi file format.

Command to convert from raw to vdi:

VBoxManage convertfromraw --format VDI “path_to_source_image.vdi” “path_to_destination_image.raw”

Tip 4 – Recompress an vdi file

After using an image file for an while it will keep allocating disk space if dynamic allocation is used, but you can reclaim some of that used disk space.

Inside the image you need to remove unused data and use an tool like CCleaner in Windows images to clear temp files.

Then you need to defrag the hard drive inside the image. Do defrag the hard drive twice. I use the tool Defraggler which is much better that the default defrag tool of Windows.

After that you can use the CCleaner drive wipe tool to clear free space only or use an similar tool. This will replace all clear space with 0 bits.

After that shutdown the image file and run the following command to recompress the vdi file: VboxManage modifyhd “path_to_target_image.vdi” compact

This command will remove all those 0 bits from the image file. After running the above command you will see that your vdi disk allocation has reduced. I have successfully shrink an vdi file from 70GB to 41GB.

Tip 5 – Host VMWare images

Firstly on you host you need to uninstall all VMWare tools.

Inside VirtualBox mount the VMWare image (.vmdk file) as an IDE, not SATA (the default when using the VirtualBox wizard).

Make sure the .vmdk filename does not contain '.' suffices.

After that you should be able to run the virtual disk.


Hope all these tips help you to run VirtualBox more efficiently and make you life easier. If you use any other VirtualBox command regularly let me know!