Virtual Box

Increase/Expand the Size of Windows 7 vdi File on VirtualBox Mac

In Mac OS X, Tips & Tricks by tigerNT17 Comments

Host OS: Mac OS X: Version:10.6.4
Guest OS: Windows 7 X64
Mac app: Virtualbox Mac


6 months ago, I Installed Windows 7 on my Mac using VirtualBox. I made a bad decision when creating the Windows virtual machine (VM). I chose to create VirtualBox VDI file of fixed-size storage of 20GB. It didn't take long before Windows started alerting me there is not enough space for update and paging.  This afternoon, When there was only 20MB space left in Windows system, I finally decided to try to expand the disk size of Windows volume. Here is how I changed the Fixed-sized Windows 7 Virtualbox VDI from 20GB to a dynamically expanding VDI file. It it actually much easier than I thought.

Create a new dynamically expending Virtual Disk Image (VDI) using virtualBox Mac

  1. Open VirtualBox (VB), choose menu File–>Virtual Media Manager virtual media manager
  2. In "Create New Virtual Disk Wizard" choose "Dynamically expanding storage"
  3. Choose VDI file location and specify the maximum size for this VDI, If you specify 60GB as the maximum size, then maximum windows disk space will be 60GB. Here, I choose 60GB for the maximum storage size and 'Win7X64.vdi' as the file name.

Use clonehd to 'copy' old VDI to the new VDI file (in my case:Win7X64.vdi) you just created

We need to transfer the Windows system installed on the old VDI file to the new virtual disk image We just created. In  order to do this, We need to use the VBoxManage clonehd command. Here is the usage of clonehd. Open Terminal,  go the directory where your virtual machine files(old vid files and the new vdi file just created) are and type: VBoxManage clonehd OldVidFile.vdi newDynamicallyExpandingVidFile.vdi --existing The clone process should begin and you should see output similar to  this:

Attach the new dynamically expending VDI and extend the Windows volume

In VB–>Settings–>Storage, attach the new VDI and de-attach the old VDI. You may need to open the Virtual Media Manager. Boot into Windows 7 on the newly attached VDI. Go to Start–>Control Panel–>Administrative Tools–>Computer Management In Computer Management–>Disk Management, choose your system drive(Boot), right click on it and choose "Extend Volume" That's it, Now you should have your Windows virtual machine expanded.

Image Credit: Emmanuel Alanis

Comments

  1. This was a tremendous help for me. It worked for me on my Ubuntu Linux laptop. I had to use a slightly different method of adding and releasing drives, but all the command line stuff worked the same. Thank you so much for this great tutorial!

  2. Pingback: Increase size of VirtualBox image (current state) | pssst …

  3. Many thanks that was very helpful – some settings were in different places as I guess I had a different version of VB but all went to plan!

  4. Great tip!
    Only thing I stumbled on was “de-attach the old VDI”.
    Why is it so hard to read and follow instructions carefully?

    Thanks!

  5. What an excellent tip. It does what it says and took me about ten minutes to add 40GB to the boot drive of my Windows 7 VM.

    Thank you.

  6. same situation here (I need a bigger virtual HD) but my guest system is WinXP, do you know the Windows XP equivalents to the “Disk Management” function? Is this even possible with WinXP or is this a function of Win7 only?

    1. For Win XP, download this “EaseUS Partition Master” software, and merge the unused disk space. The software is free and #1 rated, so no need to worry much. I just had to do this myself, and it worked successfully. Took forever researching, thought I share. FYI, i also tried DiskPart windows utility (another proposed solution) and it failed.

  7. It looks that my previous comment was filtered. I add only that my tool, vidma – Virtual Disks Manipulator, since version 0.0.3 supports resizing dynamic VDI files (fixed ones were supported from the beginning).

  8. Eamon, did you succeed?
    You may be having the same problem I had. It was resolved by removing (but keeping!) both harddisks from VirtualBox while doing the actual cloning. I.e:
    1. Remove the old/small harddisk from virtual box.
    2. Creat the new/large harddisk in virtual box.
    3. Remove but keep the new harddisk.
    4. Perform the VBoxManage clonehd command.
    5. Attach the new/large harddisk.
    6. Start the virtual machine and exted the volume in windows.

    I have performed the above steps on 3 harddisks succesfully.
    All 3 times on OSX 10.6, 2 different iMacs and one MacBook. All 3 virtual machines win7.

    Thanks a million, TIgernt :o)

  9. ~Solved (re previous comment). I used the UUID of the xp.vdi instead of the vdi filename and it worked fine

    1. Eamon,
      can explain me the difference between UUID and a vdi filename please? I have got the same error message after restoring everything from yesterdays backup.
      I have issued a similar command (modifyhd) today and it worked. At least I saw the increased HD-size in the VB Manger. But then things get mixed up and I have to restore the whole thing from my TimeMachine.

      Also I wonder how to create a new virtual disk from just the Menu (VB) File -> Virtual Media Manger. In the window that opens on my computer there is no command to create a new virtual disk.

  10. I get to step 2. But this fails. I tried copying the original xp.vdi to OLDxp.vdi but the UUID is registered somewhere.

    ERROR: Cannot register the hard disk ‘/Users/eamon/Desktop/Eamon/virtual box/OLDxp.vdi’ with UUID {447a6705-e94f-44da-8acb-2ab56e3096a9} because a hard disk ‘/Users/eamon/Desktop/Eamon/virtual box/xp.vdi’ with UUID {447a6705-e94f-44da-8acb-2ab56e3096a9} already exists in the media registry (‘/Users/eamon/Library/VirtualBox/VirtualBox.xml’)
    Details: code NS_ERROR_INVALID_ARG (0x80070057), component VirtualBox, interface IVirtualBox, callee nsISupports
    Context: “OpenHardDisk(Bstr(szFilenameAbs), AccessMode_ReadWrite, false, Bstr(“”), false, Bstr(“”), srcDisk.asOutParam())” at line 633 of file VBoxManageDisk.cpp

Leave a Comment