How to Resize a VirtualBox VM

So, I recently found out what happens when a virtual machine
runs out of space. Just resize the hard drive, right? Intuitively, one might
think there’d be a button for that… There isn’t.

A little background: I’m on OS X 10.7.5 and VirtualBox 4.2.12

** Disclaimer: ** This could potentially destroy all data on your virtual
machine. Back up all your data, and proceed at your own risk.

Here’s how to do it:

Shut down the virtual machine you’re trying to resize.

Open an OS X terminal window and navigate to the directory where your virtual
machine is. Mine is in “VirtualBox VMs/Ubuntu”.

Clone the virtual hard drive, so you’ll have a backup:VBoxManage clonehd Your_virtual_machine.vdi clone.vdiIf your vm is in .vmdk format, you need to convert to .vdi:VBoxManage clonehd Your_virtual_machine.vmdk clone.vdi -format VDIYou should see a progress bar. This will take at least a few minutes.

Resize the hard drive:VBoxManage modifyhd clone.vdi --resize 20000
(Where the number is the new size in mb.)

Create a new virtual machine:

Go back to VirtualBox and click ‘New’. Choose a new name and select the same OS and memory settings as the original.

At the ‘Hard drive’ screen, select ‘use an existing virtual hard drive file’
and choose the file you created in step 4. Click ‘Create’.
The new machine will have all the installed programs and data as the original.