Changing the UUID of a hard disk image in VirtualBox

VirtualBox is a virtual machine software that can run a couple of operating systems. A virtual machine is usually using a disk image instead of a real hard disk. A common operation is copying disk images in a clone-like manner. Unfortunately copying images with the command line cp command won’t work: VirtualBox will tell you it already knows this disk images UUID.

Solution

There’s a very easy solution for this problem that is not so obvious. You can change a disk images UUID using the sethduuid command of the virtual box management command. It’s important that you specify the absolute path to the disk image, otherwise you’ll get a cryptic error message and the command will fail. Example:

~$   VBoxManage internalcommands sethduuid /home/fury/Blah.vdi
 Oracle VM VirtualBox Command Line Management Interface Version 3.2.6
 (C) 2005-2010 Oracle Corporation
 All rights reserved.
UUID changed to: 364cf332-f11b-43f6-9f6c-498f3d259073
~$   VBoxManage internalcommands sethduuid /home/fury/Blah.vdi
 Oracle VM VirtualBox Command Line Management Interface Version 3.2.6
 (C) 2005-2010 Oracle Corporation
 All rights reserved.
UUID changed to: 3d4d6145-82f2-40a2-b2f7-44567661d33f

As you can see the command above just sets the disks UUID to a new random value that is probably not used.

Final words

Please also be aware that there’s an official approach using

VBoxManage clonehd /path/infile /path/outfile