Zhixian's Tech Blog


Change the UUID of a Virtual Box hard disk

Filed under: computing — Tags: , , — Zhixian @ 10:09:06 am

At times while using a Virtual Box (VB) guest, I would find myself wanting to clone my current working environment so as to try out something. This involves cloning the hard-disk file (better know as VDI files for the .VDI file extension that it uses) that your current guest environment is utilizing (since the hard-disk is where your operating environment resides). There are 2 ways of doing this.

  1. The incorrect but no-brainer way
  2. The correct but involves you reading the included help files way

Both methods involves using a very useful command-line tool VBoxManage that can be found in your Virtual Box installation directory.

I’ll cover the correct way first. The proper way to clone the hard-disk is to use the command:

VBoxManage clonehd <source-file> <target-file>

This command in effect performs 2 operations:

  1. copies the source VDI file to the new target filename that you defined
  2. assign a new UUID to the new target file

Step 2 is important only if you are reusing a VDI file on the same Virtual Box machine. This is because Virtual Box tracks all the hard-disks attached by its guest operating systems by means of this UUID. A Virtual Box host cannot have 2 VDI files with the same UUID. This brings us back to the 2nd method of cloning Virtual Box VDI files, the no-brainer method.

The no-brainer method comes with the realization that each hard-disk utilized by Virtual Box is simply a file. This inspires the thought that “Hey! I can just simply copy the file to so-call ‘clone’ the hard-disk.” and that’s what most people do without reading the product documentation not realizing that the UUID of the hard-disk is a factor.

The realization of the UUID as a factor would come when we try to attached the copied hard-disk file to a the new guest operating system that we are defining.


“Hmm..So what do I do now?” would be a common thought. This is especially if you had copied a fairly large VDI file (50GB?!!). Luckily, there’s a hidden command in the VBoxManage command tool for circumstances such as this.

Note that hidden command is development tool, is completely unsupported and is subjected to changes in incompatible ways without warning (ie. use at your own risk). Having said that the command we will be using is:

VBoxManage internalcommands sethduuid <target-file>

Note the command parameters “internalcommands” and “sethduuid” are case-sensitive.

After entering this command you should see something along the lines:

UUID changed to: 8c9882f0-95f8-46ad-8e93-79cb53fa24b9

After which you should be able to attach the copied file to the guest operating system now.

Blog at WordPress.com.