How-To: Clone or Copy a VirtualBox Virtual Disk

As a virtual machine environment user, I regularly create ‘base’ images of machines that I can reuse – a base Windows Server 2003 environment, or SQL Server 2005 environment for example. That way, when I need a new machine, I can simply create a copy of the virtual disk and add any additional software I need, saving myself valuable time creating new virtual environments.

With VMWare’s various offerings, copying a virtual disk is easy: copy the disk in Windows Explorer and add it to a newly created VM; VMWare will detect that the disk was a copy and create a new unique identifier (UUID) for the disk before adding it to the VM. Easy and painless. Not so with VirtualBox.

With VirtualBox, copying a virtual disk is a bit of a pain. If you copy the disk in Windows Explorer and try and use it in a new VM, VirtualBox will have a hissy fit and display the error shown below. A bit of a ‘wordy’ way to say that it already knows about this disk, don’t you think?

VirtualBox - Add Copied Virtual Disk - Duplicate UUID Error

The publicised way around this is to use the command-line VBoxManage CloneHd tool, however there is another – secret and undocumented – way to clone a disk: the setvdiuuid tool. Lets look at these two methods in detail.

Cloning a Virtual Disk – The ‘Supported’ Method

Cloning a disk is (IMHO) a clunky and Unix-y type way of creating a duplicate disk. We need to invoke the CloneHd command of the VBoxManage tool, supplying the disk to clone and the name of the new ‘cloned’ disk. In its simplest form, you would do something like this at the command-line:

VBoxManage clonehd "DiskToClone.vdi" "ClonedDisk.vdi"

The VBoxManage tool will chug away and clone the disk for you, creating a new UUID in the process:


The cloned disk can now be used on a new VM without incurring the ‘I already know about this disk’ error.

Copying a Disk – The ‘Unsupported’ Method

The alternative to the CloneHd tool is an undocumented option available in VBoxManage – the setvdiuuid command. As the command help states: ‘This is a development tool and shall only be used to analyse problems. It is completely unsupported and will change in incompatible ways without warning’. Because of this, let me add a little disclaimer: I don’t accept any responsibility if you completely destroy your VM using this procedure. Having said that, it appears to work without issue, so I’m more than happy to use it myself – just make sure that you take a backup of you virtual disk before using it if necessary.

To use the tool, simply create a copy of the virtual disk’s VDI file in Windows Explorer; open the Windows command-line and issue the setvdiuuid command for the newly copied disk:

VBoxManage internalcommands setvdiuuid "CopiedDisk.vdi"

The tool will create a new UUID and assign it to the disk:


The new copied disk can now be used on a new VM without incurring the ‘I already know about this disk’ error.


39 thoughts on “How-To: Clone or Copy a VirtualBox Virtual Disk

  1. Amazingly simple. I’ve been trying the official method for ages and kept getting it all wrong. This is by far the easiest method I’ve come across and I guess would be very easy to make a GUI of. I’ve successfully copied and now running a second XP VW using a Win 7 host. Thanks for publishing

  2. I try to do method 2 and get error:

    ERROR: failed to create the VirtualBox object!
    ERROR: Could not lock the settings file ‘C:UsersCOPE7.VirtualBoxVirtualBox.x
    Details: code E_FAIL (0x80004005), component VirtualBox, interface IVirtualBox,

    • Are you currently running the VM you are trying to clone in VirtualBox, or otherwise have a handle open to the VDI file?

  3. Worked like a charm. I copied the .vdi, renamed to my liking, copied the command into the cmd prompt, opened the folder containing the new .vdi, clicked on it and dragged to the cmd window (I needed to do this to make sure the syntax was correct – seems to need exact capitalization), completed the quotes and ran: Voila!

  4. Thanks! This is great. I’ve cloned a number of images now using both Linux and XP. Saves me a lot of setup time. Since I need to test programs, this allows me to create a base in a very short time and I now always have an exact starting point.

  5. I use VirtualBox 3.0.4 r50677 in windows and I try several methods undocumented and documented but the 2nd clone machine does not complete the boot and freze in a black screen in about when it load mup.sys driver in safe mode in xpsp3. After 2 days with experiments I notice that I have checked 2 CPU cores in “master” pc but only ONE CPU to the 2nd clone. So beware the first time to try to start the clone machine the settings in system tab and/or anyware else to be the same in clone machines as in the master machine. Afterwards, I was able to change CPU cores for the 2nd clone machine and it just work (but not for the first time eg. the first boot must complete to be able to change CPU cores). Both the commands “VBoxManage clonehd scr.dvi dest.vdi” and “VBoxManage internalcommands sethduuid SimpleCopyFromMasterImage.vdi” are working fine. Also it doesn’t matter if I unload images or not before using these commands.

  6. Slightly off-topic, but I’m looking for some VirtualBox help and you seem to be the most knowledgeable person that knows how to present material and be understood. I have a WinXP host running VirtualBox 3.1.2 r56127. I have two VIMs, each running WinXP. Host computer has an instance of SQL Server 2005 Express installed. One of my two VIMs also has an instance of SQL Server 2005 Express installed. I can’t get my second VIM to connect to either database server. The only help I’ve gotten so far is to use “Bridged Adapters” for my network settings. Um, well, did that and it still ain’t working. There must be more to it. Can you help?

  7. Hi Jason,

    I had exactly the same problem with 3.1.2 r56127 running two Windows Server 2008 VM’s on a Windows 7 host. I found that if I started the VirtualBox Admin Console as an administrator (i.e. ‘Run as administrator’) and then started the VM’s the networking works! I think it must be a bug in this version – I suppose we just have to wait until the next release :-(

    Let me know if this solves your problem….


    ps. VirtualBox Bug Tickets and have been raised that address this issue.

  8. Hi Nick,
    Very useful post. I have a slightly tangential question. What do you do about differencing disks? In VPC I could have a base workdisk (say with VS installed) and then a diff disk (with BTS and SQL) and still use the base to create a number of other diff disks (and in fact use the diff disk itself as a base). I can go to 3 levels with this. Virtual Box doesnt have this kind of functionality. I can take a snapshot, but I cant just export that particular snapshot (or a base + a number of snapshots) into a single package and use that. I have to keep cloning the machine and installing particular software on the clone to mimic what we have in VPC.


  9. […] However, in my case this didn’t work.  I got basically the same error I showed above, along with some debug information for line 628 of VBoxManageDisk.cpp.  As my main task was not to debug the C++ code used to write VirtualBox, I continued looking for a simple way to clone a virtual drive.  I found it in this blog post. […]

  10. How do you specify the uuid explicitly, i.e. this method assigns the uuid, but I want to be able to specify the new uuid.

  11. Chris, I don’t believe that you can specify the new UUID yourself – the vboxmanage tool creates a new one automatically for you ‘on the fly’. Nick.

  12. Super. I’ve never been able to get the clonehd method to work. It takes forever and says it finished successfully, but there’s never a new vdi created. Weird. But this method worked both faster and correctly. Thanks for sharing!

  13. Hi Nick,

    I update to VirtualBox v3.2.4r62431, tested the “VBoxManage internalcommands setvdiuui” invocation and am happy to report that it still works.


  14. Hey Nick,
    Gr8 work bro…it’s working on VBox 3.2. I’ve been searching for a solution for cloning a hd for about a week coz the method explained in Help menu of VBox is a bit confusing for me…


  15. This is wrong:
    VBoxManage clonehd “DiskToClone.vdi” “ClonedDisk.vdi”

    You must specify the full path, otherwise it will not work! This is correct:
    VBoxManage clonehd C:FullPathDiskToClone.vdi C:FullPathClonedDisk.vdi

  16. I am using VBox 3.1.2 r56127 and tried to clone the disk like follows (but it didn’t work)

    D:workVDI>set PATH=%PATH%;c:Program FilesSunVirtualBox
    D:workVDI>vboxmanage clonehd “trunk.vdi” “work.vdi”
    VirtualBox Command Line Management Interface Version 3.1.2
    (C) 2005-2009 Sun Microsystems, Inc.
    All rights reserved.

    ERROR: Cannot register the hard disk ‘D:workVDItrunk.vdi’ with UUID {179d52d8-b463-40c7-a635-784f
    787c2648} because a hard disk ‘D:workVDItrunk.vdi’ with UUID {179d52d8-b463-40c7-a635-784f787c264
    8} already exists in the media registry (‘C:Usersbujy.VirtualBoxVirtualBox.xml’)
    Details: code E_INVALIDARG (0x80070057), component VirtualBox, interface IVirtualBox, callee IUnknown
    Context: “OpenHardDisk(Bstr(szFilenameAbs), AccessMode_ReadWrite, false, Bstr(“”), false, Bstr(“”),
    srcDisk.asOutParam())” at line 628 of file VBoxManageDisk.cpp


    D:workVDI>vboxmanage clonehd f950273f-7a42-46f4-90e4-93441f6cad45 ids_work.vdi –format VDI
    VirtualBox Command Line Management Interface Version 3.1.2
    (C) 2005-2009 Sun Microsystems, Inc.
    All rights reserved.

    Clone hard disk created in format ‘VDI’. UUID: 4b3300bd-4013-4913-a205-feb5fbf16f5c

    Basically instead of specifying the name of the DiskToClone.vdi I had to specify its UUID
    The new vdi was created on c:workVDI even if the clone command was executed on d:workVDI

  17. Can you explain why (on a Windows host) it is necessary to change the UUID using the command line?

    My coworker on a Mac host uses only the pulldown menus to Export a VM and then import several copies of it, and says there is no need to do anything with the command line at all and it should work the same way on a Windows host.

    I’ve been given a Windows host to do this same task.
    I am following his instructions — doing it his way so far.

    There have been some unexplained errors.

    Could someone spell out exactly what sorts of errors would be explained by omitting changing the UUID, with a Windows host?

  18. Sorry a little help needed by a novice user of Virtual Box 4.0.0

    I’m at the following prompt C:Program FilesOracleVirtualBox>

    and I add the following to the command prompt (above) – it doesnt work so I must be doing something wrong!

    VBoxManage internalcommands setvdiuuid “C:UsersOfficeVirtualBox VMsWindows XP Virtual DiskWindows XP Virtual Disk.vdi

    Im a first time user of Virtual Box and I need to make copies of my ‘base’ vdi so I can install different software on each copy.

    Thanks in advance.

  19. The command has changed to sethduuid…
    recommend building a simple batch file

    “C:Program FilesOracleVirtualBoxVBoxManage” internalcommands sethduuid “D:

    VirtualBox MachinesNewClone.vdi”

  20. Hi Nick,
    Great post… many thanks for explaining it in very simnple and elegant manner.
    I noticed that for cloning the Virtual Drive, the original setvdiuuid specified in your post did not work on my Virtualbox, however replacing it with sethduuid did the job, thought would let others know if original command does not seem to be working.

    Thanks again.

  21. Hi

    My suggestion is to do what Pat said.
    Create a txt file
    paste the following:
    “C:Program FilesOracleVirtualBoxVBoxManage” internalcommands sethduuid %1

    Save as .bat

    Now u can drag your vdi on to this file and it will reset the uuid :)

  22. This cloneHD command worked perfect!!! Thanks to Nick for the tips and also taking the time to add command line screen shots
    Much appreciated!!!
    Shah Murad

  23. The command has changed to “sethduuid” (I am using VirtualBox 4.1.8 version):

    C:Program FilesOracleVirtualBox>VBoxManage internalcommands sethduuid “C:CentOSDup.vdi”
    UUID changed to: ac3f7a4d-da4f-4077-be7b-4fcac9fd9f88

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your 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