Link to home
Start Free TrialLog in
Avatar of jkeegan123
jkeegan123Flag for United States of America

asked on

Is there a way to import a Hyper-V VM into a Hyper-V Server without an export file?

If you export a Hyper-V VM from Hyper-V manager to a folder, it will create a folder inside that folder with the name of the VM being exported, and within that folder will be an XML file that is used for importing, along with the VHD's of the VM, and any configuration files required for the VM to function.

Running VM's within Hyper-V are typically running inside a folder named for the name of the VM as well.  examples:

D:\VM-DATA\VM1 = working folder for VM1
D:\VM-DATA-VM2 = working folder for VM2

If I shut down VM1, copy the folder D:\VM-DATA\VM1 to another Hyper-V server and try to import the VM, I am not able to because of the absence of an export file.  I can create a NEW VM manually and point the hard drives of the new VM to the VHD files contained in the copied folder, however when this VM's boots up none of the NIC settings will be configured and the NIC's that are attached to the new VM will show up with a new name (LOCAL AREA CONNECTION 3, 4, 5, etc...).  The reason for this is the MAC address of the original NIC(s) was contained in the configuration file of the VM, and when we create a new VM but use existing VHD's, a new configuration XML file is generated and that includes a new MAC address for the NIC.

Is there a way to copy the entire VM folder from one server to another and ADD that VM to the target server without importing it?  Or asked a better way, how is the import file formatted, and is there a way to generate an import file from the current configuration files?  

I'm thinking about this from a disaster recovery point of view...we have had operating systems of VM-Hosts corrupt but the data partition stay intact.  We have been able to pull the entire content of folders off of dead VM Hosts and pull them into currently working hosts, but we end up having to create a new VM shell to host the "transplanted" VM VHD's and data services...the biggest issue being that we have a new MAC address of the VM-NIC and the settings default to DYNAMIC.  We need to set the MAC address sometimes (depending on the APP) and reset the NIC from dynamic to STATIC.  If there was a way to import without an import file, or generate one from the existing setup files, OR create a new VM shell and then replace the configuration file generated with the configuration file that was in the original VM's folder, any of these options would make life much easier.

I know that the right way to attack this requirement would be to put the VM's on external storage like iSCSI SAN, and cluster the VM's using Windows clustering services....but this is not an option and we're trying to mitigate the risk of not having that by coming up with a better way to transplant VM's without an import file.
Avatar of Lee W, MVP
Lee W, MVP
Flag of United States of America image

What version of Hyper-V?  I believe 2012 can import VMs without an export
Avatar of jkeegan123


Hyper-V v2 on Windows 2008 R2.  Currently you cannot import a VM without an export file.
Upgrading to 2012 is not an option?

All these actions can be automated with Powershell scripts. This is not exactly what you're asking, but here's an example of a ps script that will turnoff/export a VM:

You could modify it or look for other ps scripts as needed.
@leew:  Upgrading to 2012 is definitely an option, but I'm looking for an easy way to deal with 2008R2 disasters, so not in this case.

@Eddie-Lopez:  Thanks, but I'm looking for a way to deal with the VM's in a disaster environment where there would be no time for a script to run, or no way to run it.

I'm looking for a way to get an existing VM with configuration file into a new / different Hyper-V server.
I see...

Looks like "Hyper-V Replica" feature would probably fit your needs, unfortunately it involves upgrading to Windows server 2012...

You could also make a PS script that on a schedule (once a day, for example) that would turn off, export, and copy your VM files to your disaster recovery host. Or simply a scheduled batch file that copies your VM vhd to your DS host.

That way if your host fails, you have an updated version of your VM to do a failover.
Avatar of jkeegan123
Flag of United States of America image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This was the only solution that met the posted questions requirements.