Moving a Virtual Machine Image in VirtualBox 4.0.10

I have a testing environment for our deployable application MSI here.  It’s a licence of Windows XP running in a virtual machine courtesy of VirtualBox (I’m a big, BIG fanboy of free virtualisation).  In essence, it’s a fully updated Windows XP environment with all the prerequisites loaded, ready for the MSI to be installed for the very first time. Whenever I want to convince myself that the MSI will install into a “new” XP environment, I can try it out.  Once I’m satisfied, I can rewind back to a snapshot of a pristine environment.  All Registry, GAC, User and/or application configuration mess disappears. Isolation testing when I can see before and after changes to an Operating system that hasn’t seen our application before has already delivered gold several times.

I’ve come to depend on this isolation testing approach so much that it’s time I got serious about backing up the virtual machine image. Now, I installed VirtualBox without thinking about backups initially.  I’ve learned that by default, my virtual machine data is being written to my user “Documents and Settings” directory.  It’d be a lot more convenient for my to have them under my D drive which is already set up for no-hassle backups of the development environment.

In my naivety, I thought it would be as simple as just copying the virtual machine directory from “Documents and Settings” through to my D drive. Doesn’t work. The virtual hard-drive image file is marked with a UUID that very tightly couples it to its virtual machine.  I can’t even just change the file name without VirtualBox complaining long and hard that this is NOT the hard drive image it’s looking for.

After some frustration trying to get VirtualBox to use copied drives, virtual machines and snapshots, I gave up and consulted google.  I tried (and tried) to follow the instructions here, but they failed me miserably.  I really should have looked at the timestamp on this post. I finally read the entire, long comment history which lead me to gold.  Things are much easier than they were back then, and I’ve just spent the morning jumping through rings of fire whilst whacking an angry bear with a foam bat, when I could have lazily told VirtualBox to just “Make it so, No. 2”.

The first thing I need to do is to export the currently selected virtual machine image via the menu item “Export Appliance…” thusly:

Screenshot showin the exporting a VirtualBox image

Exporting a VirtualBox image

Then, I remove the image from VirtualBox (leaving the file structure intact, just in case it all goes pear-shaped) thusly:

Screenshot of the removing a VirtualBox Image

Removing a VirtualBox Image

Now, because I want all my VirtualBox shenanigans backed up, I change the default folder for new virtual images thusly:

Screenshot of setting the Default Machine Folder in VirtualBox

Setting the Default Machine Folder in VirtualBox

I next import the saved virtual machine export, being guided by the import wizard (not shown):

Screenshot of importing a virtual machine in VirtualBox

Importing a virtual machine in VirtualBox

And whallah, one moved virtual machine environment, sans the heartbreak required circa 2008:

Screenshot of the VirtualBox Image in its new home

VirtualBox Image in its new home

Finally, a word of warning:  The export will roll all your snapshots into one “current” one.  If you’re in love with a deeply nested set of snapshots (like say, Windows straight of the install CD, then another with all the updates laid down, etc), they will be gone in your moved image.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s