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.

Advertisements