How to Resize a VirtualBox VM

**Last edited 03 Jul 13

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:

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

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

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

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

  5. 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. screenshot 1
    • At the ‘Hard drive’ screen, select ‘use an existing virtual hard drive file’ and choose the file you created in step 4. Click ‘Create’. screenshot 2
      The new machine will have all the installed programs and data as the original.
  6. Repartition the hard drive:

Virtualization is an amazing thing. The ability to create customized, clonable, disposable virtual computing environments is endlessly useful. If that interests you, stay tuned for my upcoming post about Vagrant.