Growing a VirtualBox VDI is easy…

I use VirtualBox for lots of things, not the least to be able to use Microsoft Office for Windows on my work laptop, which is a Mac. Bless Office for the Mac but it sucks and I really need Excel to work with VB and the Data Analysis add-on…

However, I digress. As I installed more and more apps into my Win7 Virtual Machine I started running out of disk space so here follows a brief explanation of what I did (and do) when I need it (the VDI…) to grow. (Note that I didn’t originally create it using the  “dynamically expanding storage” option in VBox and if I had I might not be in this predicament but there you go.)

So;

  1. Create a new harddrive using the Virtual Media Manager in VBox and make sure it’s the size you want
    1. NOTE: Again I didn’t create the new disk as dynamic, but rather as static…I don’t know if the following steps would work if it was dynamic (somehow I doubt it but if you try then please let me know how it went…)
  2. Release and Remove your old harddrive from VBox’ grasp using the Virtual Media Manager;
    1. You have to do this otherwise the next step will fail. All you need to do is to release it, then remove it and REMEMBER to “Keep” the hard disk image when you do that!
  3. Clone your old (and smaller) VDI into the new (and larger) one like so using the VBox command line tool:
VBoxManage clonehd --existing OLD.vdi NEW.vdi
  1. Now go back into Virtual Media Manager and add the NEW.vdi drive
  2. In the settings for your virtual machine (the one that previously used the OLD.vdi) you change it to use NEW.vdi
  3. Downloadsystemrescuecd.iso (or any LiveCD with a Linux Distro and GParted on it. The remaining steps assume you can run GParted)
  4. Attach the LiveCD to your virtual machine so that it will be booted when it starts
  5. Boot your virtual machine…
  6. Run GParted;
    1. The virtual machine’s hard disk will be allocated into the “old” partition (which is the smaller size) and an extra, unallocated, partition which is whatever extra space you now have in your new and (larger) hard disk
  7. Resize the smaller partition (old) to take up all of the (new) disk
    1. NOTE: this assumes your guest OS uses a file system that GParted understands. In my case this was NTFS (Windows) but if you are attempting this to grow something else, and utterly esoteric, I can’t guarantee it will work. However, it would have to be very esoteric…
  8. Shut down the virtual machine
  9. Release the ISO (sysrescd.iso in my example)
  10. Reboot….
  11. Presto, you’re done! The machine should boot up happily and Windows will tell you that the C: drive is whatever size NEW.VDI was created as

Certainly beats using CloneZilla to try and save off the old image and restore it. I tried that too and it didn’t work but even if it did this method seems simpler.

8 thoughts on “Growing a VirtualBox VDI is easy…

  1. “2.Release and Remove your old harddrive from VBox’ grasp using the Virtual Media Manager;
    1.You have to do this otherwise the next step will fail. All you need to do is to release it, then remove it and REMEMBER to “Keep” the hard disk image when you do that!”

    This is not clear to me. What do you mean by release and remove? I upgraded to VBox 4.0; then, I created another vid, but have not installed anything in it yet. I added the new vdi to the same controller where the old one that isn’t working is on. I can see where I can attach or remove vids from the controller, but I don’t see anything that says ‘release’ or ‘remove.’ In either case, I don’t see anything that says I can ‘keep’ the hard disk image. This all seems crucial from your instructions, but the statement is vague enough to make me very unsure about exactly what you are saying to do.

    1. Hi Ray,

      Releasing the image means opening up the Virtual Media Manager from within VBox, finding the current VDI that you are going to change, and selecting “Release” first, this disconnects it from any Virtual Machines using it. Then you can choose to “remove” it to remove it from the Virtual Media Manager’s database. When you select remove VBox will ask you if you want to delete or keep the original VDI. You
      want to keep it so that the file is left on disk.

      You shouldn’t keep the VDI attached to the Virtual Machine, which is what I believe you have done.

      Does that help?

  2. Thank you, you saved me a lot of time! I work a lot with virtual machines to develop and test software and websites, and before reading your post I wasted a lot of time enlarging my virtual disks…

    I can confirm that your mathod works with ”dynamically expanding storage” virtual disks, at least when cloning a dynamic disk on another, new dynamic disk (but I don’t see why this shouldn’t work even with different combinations).

    One more hint: instead of using SystemRescueD (that is cool, but could be overkill for this case), one can use also GParted Live CD (http://gparted.sourceforge.net/livecd.php), that is smaller, so faster to download, and boots faster than SystemRescueCD.

  3. I created a dynamic disk and it worked. Also, I didn’t have to release the disk to clone it, just the VM had to be turned off. This is with VirtualBox 4.2.

    Thanks for the pointers!

  4. Thanks for this, saved me from the predicament. I couldn’t create a new harddrive using the Virtual Media Manager in VBox, don’t have the option, not sure why. Using VBox 4.2.6, host is linux, guest running out of space was winXP. I didn’t have to release the disk either.
    I had to resize the vdi from console with: “VBoxManage modifyhd –resize [size in MB] ” . Find the uuiid with “VBoxManage list hdds”.
    Then, do the resizing bit with GParted Live CD like suggested.

  5. Thank you for this! I searched for too-long, encountering too-many answer-clones all telling me to use modifyhd, etc., etc., which all returned errors about “not supported on this version”. Your method is the same or similar to what I must have done a few years ago, and I didn’t recall the steps, but yours worked fine!

Leave a reply to Ray Cancel reply