Wednesday, March 25, 2009

Virtual Box - Resetting Virtual Hard Drive UUID

I wanted to create two RHEL5 VMs with VBox. So installed and setup one virtual machine and then remembering what I used to do with MS Virtual Machine, copied the virtual hard disk of the newly created VM to another location. Then from the VBox GUI I tried to add a new virtual machine by pointing it into an existing hard disk ( which is the newly copied VHD). And then I got this pop-up message:

Failed to open the hard disk D:\VirtualMachines\V-Cent5-3\Cent5-3.vdi.
Cannot register the hard disk 'D:\VirtualMachines\V-Cent5-3\Cent5-3.vdi' with UUID {5eaa4ad6-2742-480b-88f1-364b82c63c3d} because a hard disk 'D:\VirtualMachines\V-Cent5-2\Cent5-2.vdi' with UUID {5eaa4ad6-2742-480b-88f1-364b82c63c3d} already exists in the media registry ('C:\Documents and Settings\safeer\.VirtualBox\VirtualBox.xml').

Result Code: E_INVALIDARG (0x80070057)
Component: VirtualBox
Interface: IVirtualBox {779264f4-65ed-48ed-be39-518ca549e296}

A quick look into the vbox's xml configuration file told me that it keeps a unique id for each hard disk, and this is set within the virtual hard disk. So I started looking for a solution. The first one that came across while googling was to rgenerate the UUID of the newly copied hard disk as follows.

C:\Program Files\Sun\xVM VirtualBox>VBoxManage internalcommands setvdiuuid "D:\VirtualMachines\V-Cent5-3\Cent5-3.vdi"
VirtualBox Command Line Management Interface Version 2.2.0
(C) 2005-2009 Sun Microsystems, Inc.
All rights reserved.

UUID changed to: 5eaa4ad6-2742-480b-88f1-364b82c63c3d

I just did this and voila, VBox accepted my copied hard disk without complaints. :) That did the trick, but later in another forum post I found out a better method of cloning an existing VHD, it will not only copy the generated hard disk to a specified location, but will also generate a new UUID for the disk.

C:\Program Files\Sun\xVM VirtualBox>VBoxManage clonehd "D:\VirtualMachines\V-Cent5-3\Cent5-3.vdi" "D:\VirtualMachines\V-Cent5-3\Cent5-4.vdi"
VirtualBox Command Line Management Interface Version 2.2.0
(C) 2005-2009 Sun Microsystems, Inc.
All rights reserved.

Clone hard disk created in format 'VDI'. UUID: 7934dd80-0ce6-4530-b471-835af980190a

This looks more straight forward approach. But ofcourse the choice is yours.


  1. thanks this helped me....!!! good job

  2. Thank you very much. Your solution saved a lot of my time.

  3. I could not get the first solution to work. But I was able to run

    VBoxManage internalcommands sethduuid "FILENAME.vdi"

    Which worked great.

  4. Thanks, this post help me.
    But this command support only english letters.