VirtualBox UUID Change Script

UPDATE: Oracle has decided to change the command from setvdiuuid to sethduuid for version 4 of VirtualBox. Please make this correction if you are using version 4.

How many times do you simply copy a virtual hard drive when you want to stand up a development environment? In VirtualBox, it isn’t as simple as a simple copy, paste, and rename. Each virtual hard drive in the VirtualBox world (.vdi files) gets its own universally unique identifier, or UUID. When you copy a vdi file with your file explorer it also brings over the UUID. Fortunately, VirtualBox has a command to generate a new UUID for a copied vdi file.

%ProgramFiles%\Oracle\VirtualBox\VBoxManage.exe internalcommands setvdiuuid

Being in the SharePoint development world, I create new virtual machines all the time so I created a script to take care of the UUID change. I have a batch file named changeUUID.bat that this script is contained.

@ECHO OFF
IF "%1"=="" GOTO Error
"c:\Program Files\Oracle\VirtualBox\VBoxManage.exe" internalcommands setvdiuuid %1
GOTO Exit
:Error
ECHO No file path given!
:Exit
PAUSE

Gist Link: https://gist.github.com/knight0323/4488526

NOTE: VirtualBox does offer a command called clonevdi which will copy the vdi and ensure a new UUID is assigned to the clone. The setvdiuuid command is just a personal preference.

Advertisements

3 thoughts on “VirtualBox UUID Change Script

  1. Michał Nikołajuk March 14, 2011 / 7:39 am

    You have small mistake with script.
    Change setvdiuuid -> sethduuid

  2. Jeremy March 14, 2011 / 3:36 pm

    I have a notice at the beginning of the post pertaining to this issue.

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