none
Failed to import VM in Hyper-V 2008

    Question

  • I'm getting the following error when trying to import a VM using Hyper-V running on Windows Server 2008 R2.  The error is:

    "Import failed. Import task failed to copy the files from "E:\VMs\BaseVMServer2008R2\Virtual Hard Disks\AppServer.vhd' to 'C:\Users\Public\Documents\Hyper-V\Virtual Hard Disks\AppServer.vhd': The file exists."

    I'm using a Base VM that has Server 2008 R2 with Service Packs and it has been SysPrepped. I was able to use the BaseVM to import/create a VM and that is running fine. However, I am unable to create a second VM with the same Base VM. The error message above is clear, but I don't know why this is happening. In the dialog for Import I selected "Copy the virtual machine(create a new unique ID) and "Duplicate all files so that the same virtual machine can be imported again".  Thus, I don't know why the import fails when creating another VM.

    Any help would be greatly appreciated.

    Ed

    Friday, March 18, 2011 8:43 PM

Answers

  • As already pointed out, the export/import function is not intended for cloning. Trying to use it as such introduces a bunch of complications. Even renaming the file doesn't help because the XML file for the old VM still has references with machine name, vhd files, etc, so the import will still fail

    With that said, if I understand the process you used, I don't see a need to "import" at all.

    You have a good vhd, already sysprepped, for use. Simply create a new virtual machine, choose to not create a VHD at the time, and then make a copy of your "master" vhd and attach it to the new VM. Should work fine.

    Kristian (Virtualization and some coffee: http://kristiannese.blogspot.com )
    • Marked as answer by eddieWHS Monday, March 21, 2011 2:37 PM
    Monday, March 21, 2011 5:32 AM
  • Hi,

     

    In Windows Server 2008 R2, if you check the box "Duplicate all files so that the same virtual machine can be imported again" when you import a VM, the system will copy the VM files to C:\Users\Public\Docments\Hyper-V.

     

    As you can see in the following screen shot, I have two VMs, 001test and 002test, their VHD files are 001test.vhd and 002test.vhd, after the import,  both of them are in C:\Users\Public\Docments\Hyper-V\Virtual Hard Disks folder.

     

     

     

    In this way, if you import the same exported VMs twice with the same box "Duplicate all files so that the same virtual machine can be imported again" checked, you will get a "The file exists" error, because there is a VHD exist with the same name(the name of the VHD file in the exported folder will not be changed).

      

    By the way, it is recommend that you store the VMs in other partition such as D:, E: instead of the system partition. If do want to use the exported VMs to deploy other VMs, you can perform the following steps:

     

    1. Create a folder such as VMs under D:

    2. Create a sub folder such as D:\VMs\VM01

    3. Copy the exported VMs to D:\VMs\VM01

    4. Export the VMs under folder D:\VMs\VM01

    5. Report the step2 to step 5 if you need other VMs.

     

     

    Best Regards,

    Vincent Hu

     

     

     


    • Marked as answer by eddieWHS Monday, March 21, 2011 2:41 PM
    Monday, March 21, 2011 10:11 AM

All replies

  • Check this thread: 

    "The rule of thumb is that any particular export can only be imported one time.

    And, an Export is an entire folder, not just the .exp XML file.

    So, you would sysprep your VM, power off, Export.  then copy the entire export folder to a new folder, Import from the new folder.

    Each new VM from this Export, must be a full copy.

    R2 includes a feature to "copy a VM to allow it to be imported again" Hyper-V v1 does not. 

    Personally, I gave up trying to use this copy feature in R2 and simply duplicate the entire folder.  Then I know what is happening and I know where that VM is being stored.  I am a self admitted control freak of my environments."

    http://social.technet.microsoft.com/Forums/en-US/winserverhyperv/thread/0bc960ef-5ca3-44f3-8641-bdcce1e967ab


    Kristian (Virtualization and some coffee: http://kristiannese.blogspot.com )
    Friday, March 18, 2011 9:15 PM
  • Hi Kristian,

    Thanks so much for your reply. Unfortunately, I tried the suggestion above and received the same error message - that the .vhd file (AppServer.vhd) already exists. I followed the suggestion exactly I think by exporting the sysprepped VM (it was powered off), and then I copied the entire content of the export folder to a new folder and tried to import from the new folder.

    In some of the posts referred to in the link you posted (and elsewhere) it is mentioned that the new (imported VM) should have an new ID and that using the "copy" during import will enable a new ID to be created. Does this mean the .vhd  should be different also (i.e. AppServer.vhd in my case)? I think I'm making a simple mistake here but I don't know what it is.

    Thanks,

    Ed

    Sunday, March 20, 2011 11:00 PM
  • As already pointed out, the export/import function is not intended for cloning. Trying to use it as such introduces a bunch of complications. Even renaming the file doesn't help because the XML file for the old VM still has references with machine name, vhd files, etc, so the import will still fail

    With that said, if I understand the process you used, I don't see a need to "import" at all.

    You have a good vhd, already sysprepped, for use. Simply create a new virtual machine, choose to not create a VHD at the time, and then make a copy of your "master" vhd and attach it to the new VM. Should work fine.

    Kristian (Virtualization and some coffee: http://kristiannese.blogspot.com )
    • Marked as answer by eddieWHS Monday, March 21, 2011 2:37 PM
    Monday, March 21, 2011 5:32 AM
  • Hi,

     

    In Windows Server 2008 R2, if you check the box "Duplicate all files so that the same virtual machine can be imported again" when you import a VM, the system will copy the VM files to C:\Users\Public\Docments\Hyper-V.

     

    As you can see in the following screen shot, I have two VMs, 001test and 002test, their VHD files are 001test.vhd and 002test.vhd, after the import,  both of them are in C:\Users\Public\Docments\Hyper-V\Virtual Hard Disks folder.

     

     

     

    In this way, if you import the same exported VMs twice with the same box "Duplicate all files so that the same virtual machine can be imported again" checked, you will get a "The file exists" error, because there is a VHD exist with the same name(the name of the VHD file in the exported folder will not be changed).

      

    By the way, it is recommend that you store the VMs in other partition such as D:, E: instead of the system partition. If do want to use the exported VMs to deploy other VMs, you can perform the following steps:

     

    1. Create a folder such as VMs under D:

    2. Create a sub folder such as D:\VMs\VM01

    3. Copy the exported VMs to D:\VMs\VM01

    4. Export the VMs under folder D:\VMs\VM01

    5. Report the step2 to step 5 if you need other VMs.

     

     

    Best Regards,

    Vincent Hu

     

     

     


    • Marked as answer by eddieWHS Monday, March 21, 2011 2:41 PM
    Monday, March 21, 2011 10:11 AM
  • Hi Kristian,

    Thanks again for your quick reply. Yes, I guess I did misunderstand that the export/import function was not intended for cloning.  So I followed your suggestion to create the new VM, made a copy of the "master" vhd, renamed it and attached it to the new VM.  That worked fine.

    Thanks for clearing that up to me.

    Best regards,

    Ed

    Monday, March 21, 2011 2:37 PM
  • Hi Vincent,

    Thank you also for helping to clarify how the vhds are stored and the naming convention required. Fortunately, I did have 2 separate physical drives (and therefore partitions) for storing the VMs so I did get that right at the beginning. My confusion was about how to perform some kind of clone operation on the master VM that was created. With Kristian's response and yours I was able to get it working.

    Thanks and best regards,

    Ed

    Monday, March 21, 2011 2:41 PM