Resizing a VirtualBox VHD or VDI file on Mac OS XResizing a VirtualBox VHD or VDI file on Mac OS X

I recently created a Windows 8 VM using VirtualBox on my iMac and misjudged how much space I would need, however not being an experienced VirtualBox user I didn’t realise you wouldn’t be able to increase the VM size from within the GUI. After a quick google session I also found that the advice on resizing VirtualBox VMs was very Windows-centric, so I thought i’d post step-by-step instructions for all you Mac VirtualBox users our there in the same position.

Before we proceed, I must note that this process will _only_ work on VDI or VHD files, and only for those that are “Dynamically allocated storage”, as Fixed storage VMs aren’t able to use the resize option.

If you have a fixed storage VM I suggest you google how to resize VirtualBox VMs using cloning, there are hundreds of blog posts so I won’t re-invent the wheel! Same goes for Windows users, there are tonnes of existing solutions out there for you.

Requirements:

  1. Dynamically allocated storage (rather than fixed)
  2. VDI or VHD file
  3. Mac OS X (I’m using 10.8.3, although i’m assuming the working directory shouldn’t have changed in previous versions)
  4. Shut down the VM first.
  5. If you have any critical data in the VM I suggest you back it up.

The Solution:

  1. Open a terminal
  2. Navigate to /Applications/VirtualBox.app/Contents/Resources/VirtualBoxVM.app/Contents/MacOS
  3. Run the command VBoxManage modifyhd [myvm.vdi] –resize 50000

If you’re still struggling:

  1. Be sure to change [myvm.vdi] to the location of your VDI file, and change 50000 to the number of megabytes to resize the VM to. 50000 megabytes = 50GB
  2. If your VDI is buried deep in multiple directories, and/or if the directories contain spaces and odd characters that requiring escaping in the terminal, the easiest option is simply to find the VDI/VHD file in the Finder and drag it into the terminal – that will copy the full path of the file into the directory. If you want to do this, first type VBoxManage modifyhd into the terminal, then drag in the VDI/VHD file so that it copies the path, now add –resize 50000 to the end of it (changing the 50000 to the size you want).
  3. Here’s the full command I ran as an example: VBoxManage modifyhd /Volumes/1TB\ HDD/Virtual\ Machines/Windows\ 8/Windows\ 8.vdi --resize 60000

Now that you’ve resized the VDI/VHD file, don’t forget that you’ll now need to extend the partition within the guest OS itself to make use of the additional disk space, in Windows this is done via Disk  Management (Right click on “My Computer”, select “Manage”, select “Disk Management”)

Comment if you get stuck and i’ll try to help. Keep VM’ing people.