Thursday, July 10, 2014

Movin on Up: Converting a VDI to a VHD to move from VirtualBox to Azure

Months (years?) behind the rest of the world, I've finally decided it's time to get my VMs up to Azure (no more SSD swapping between PC and laptop despite having a easily mountable caddy in my work laptop and this sweet caddy in my PC.

As a loyal VirtualBox user I opted for VDI rather than VHD, but now I must convert.  So here's what I did:

  1. Uninstall VBox Guest Additions from the VM
  2. Shut the VM down (don't save the state).
  3. Remove the VDI from the Virtual Media Manager in Virtual box before running the command below
  4. Run the following command using Run As Administrator by right-clicking on the command prompt (from the VBox Install directory unless you've set the PATH variable):  VBoxManage clonehd e:\SP2013DEV.vdi  c:\SP2013DEVaz.vhd --format VHD

    In the above command the first file is the source VDI the second is the destination VHD.
  5. Wait for the magic to happen it should take a while since VMs with SP on them are pretty big.  Going from one drive to another should help a bit.
  6. Upload to Azure and config a new VM to use that VHD.
  7. Profit
I ran into a hiccup in that it appears my vbox installation got messed up during an upgrade and kept telling me that VBoxManage was not a vaild win32 application because it was a zero byte file.   Reinstalling VBox did the trick.

I may go to just configuring straight in Azure from now on. I do like the option of building locally then uploading, but I will probably just start with the VHD format from now on since conversion is really just an extra step if you plan on going to Azure.

No comments: