Exporting Hyper-V VMs Over the Network

Exporting Hyper-V VMs Over the Network

  • Comments 21
  • Likes

I received a comment via e-mail that it can take 2-3 times as long to move a VM from one Hyper-V host to another host, when compared to VMware or Virtual Server.  I do not think that the person mentioning this was super familiar with Hyper-V export, but their comment did make a good point about the portability of VMs between hosts.  Their goal was to efficiently migrate VMs from one host to another as part of an upgrade, and they were concerned about downtime.

You can copy a VHD from one host to another, but the configuration must be re-created.  It’s very hard to replicate a VMs configuration (MAC addresses for NICs, memory configuration, other virtual hardware attributes) simply by moving a VHD.  Hyper-V includes an export / import feature to encapsulate the configuration with associated VHDs for reuse.  Exporting a VM duplicates the (sometimes) large VHD files from the source VM to another location.

The e-mail comment made it clear that the person had not considered exporting a virtual machine over the network to a new host, rather than to local disk on the source.  They also didn’t know that SCVMM has a fantastic capability to move VMs from one host to another (similar to export and import), without the requirement of block level shared storage.  I’m not going to talk about SCVMM here, since it’s really easy (point and click) to relocate a VM using SCVMM (check it out!).

I am going to detail how to export a Hyper-V VM over the network, since I don’t see it covered anywhere else (I Binged hard, I swear!).

In order to export a VM to a network share (on the ultimate Hyper-V target host) a network share must be created with the appropriate rights granted to the exporting Hyper-V host. 
This may not be entirely intuitive, since you as the administrator are actually kicking off the export.  To put it simply Hyper-V is doing the export, so it needs rights to the remote share, not you! 

I just did this in my lab using two systems Hypernode1 (new host) and Hypernode2 (old host from which I want to export).  Here are the steps I followed (FYI, I blanked out the domain name in all the screen shots):

  1. Create share on Hypernode1 – I shared out C:\VMs – creating the \\Hypernode1\VMs share

  2. I granted rights on the share to the Hypernode2 system.  This can be a little tricky, since the “Select Users, Computers, Service Accounts, or Groups” dialog does default to searching for computers. 
    You have to remember to search for “Computer” objects rather than the typical Users or Groups.  You have to change the Object Types to easily find a system (shown below):

    clip_image002[4]    

  3. Once the “Object Types” are squared away, you can enter your host name, and grant it rights to the share: 

    image

  4. You will want to grant sufficient share permissions to the host as well – not just READ:

    image
  5. You will also need to ensure that the exporting host has sufficient NTFS permissions – changing the “Select” is again something to do.  The permissions I used are as follows:

    clip_image002[10]

Once I granted the exporting host rights to the share and the folder (NTFS), I was able to export my VM over the network in one step from Hypernode2, and then import the VM on Hypernode1:

clip_image002[12]

Let me know if you have any questions or comment!

-John

Comments
  • Is it possible to do export/import of VM from command line?

  • Yes you can export / Import from the command line using the Hyper-V Powershell Management Library found up on CodePlex  - http://pshyperv.codeplex.com/(that's another great blog post I need to write!).  

    You can check out James O'Neill's blog for more details (http://blogs.technet.com/jamesone/archive/2008/06/18/hyper-v-powershell-library-now-on-codeplex.aspx)

    I use the version of the library that was posted on CodePlex from January '09, because it is most familiar to me and installs simply (http://pshyperv.codeplex.com/wikipage?version=9).

    You could also write your own WMI scripts to handle it as well, but James' library is AWSOME!

  • I am running Hyper-V Server 2008 R2 and tried to export to a share on a Windows 7 and it is failing with Access Denied (0x80070005). I verified all the share settings are for the HYPERV host.

    I am very familiar with the system's account access over the network and adding hosts to shares (work's great with SQL Server for exporting/importing).

    I RDP'ed into the HyperV host and mapped a drive and could map a drive to the share and create folder. Obviously this was running under the Administror context, but I new the share was working.

    Is there something special about the core OS that would prohibit this from working?

  • It should work if you've also adjusted the NTFS permissions on the target directory - not sure why it isn't working for you.  I don't have a Win 7 host in my lab right now, I can give it a whirl once I get into the office again and see if I run into the same issue.

    -John

  • Mark - WOW!   I RAN INTO THE SAME ISSUE EXPORTING TO A WINDOWS 7 SHARE!

    I have no idea what the issue is (I don't use Windows 7 as a file server), but I was able to successfully export if I gave EVERYONE "full control" on the share (I also had  the exporting computer in the local administrators group, and had granted full access to the directory in NTFS).

    I don't recommend  this as a solution, but then I don't recommend Windows 7 as a file server!  I'll have to check in with a Windows 7 security expert to see what's up with that!

    -John

  • Your solution looks great but what about this. 2008 Data Center in WORKGROUP with a VM on the domain. Not enough room on the drive to export the VM. Can't give the Data Center (computer rights) to the share i would like to export to on the computer on the domain that has room. If Data Center was on the domain i think i would be ok. I tried a USB drive and got Access Denied (0x80070005). I realy have to get this moved. It is on a temp server in production. I have been looking all day and this is the best blog i have seen.

    Thanks, all ideas will bee appreciated,

    tg

  • What about joining the domain with the DataCenter server? What problems would that cause with the VM?

  • TG,

    I export to USB drives most of the time - it should not matter which versions of Windows Server 2008 you use (Data Center, Enterprise, or Standard).  I have not seen an Access Denied message exporting to a USB drive.  You may need to go into Server Manager and bring the drive on online.  Also, the drive should be formatted NTFS (large VHD files may not work otherwise).

    -John

  • TG,

    I have not joined a Hyper-V host to a domain AFTER I have configured it, but I do not expect you should have any problems.  The process outlined in the blog post should work for you then.

    -John

  • John,

    The USB Drive was formated with FAT32. I re-formated it to NTFS and it is now exporting. When I get this VM up and running on the new server I will see what happens if i join the domain with the Data Center in workgroup and how it effects the VM.

    Thanks,

    TG

  • TG - glad to hear an NTFS formatted volume is working for you!

    -John

  • John,

    I one I've been called in on. This is the Scenario.

    5 blades running 2008 Datacenter and Hyper-V with a failover cluster. The domain is core.*****.pri. They put the DC for the domain in a VM in the cluster. After a complete power down the cluster can't start because the DC is unavailable. They have 2 VMs on the cluster running production.  If I set up 2 datacenter machine and use the dirver and build a cluster on them will the vm's be there?

    Thanks,

    TG

  • TG,

    I have no idea the specifics of the configuration.  I've seen folks virtualize their only Domain Controller many times and almost always be sorry for doing it.  I would think you could log in locally or via cached credentials, access Hyper-V Manager and get to the VM to move it off, but I really can't say.

    -John

  • double checked share and ntfs (win7 domain member) destination perms. for our hyper-v computer account (a 2k8R2 data center - has FC in both share and ntfs)

    oubiously binged (39 results :( and checked kb2008849

    still getting access denied error 0x80070005.

    so frustrating...

    I expect has not to do with http://www.aperture.ro/index.php/2009/01/intel-releases-patch-for-ipmi-driver-causing-conflicts-in-microsoft-hyper-v cause, but if yes...

  • Marcelo - are you exporting to a Win7 system?  As noted earlier, I ran into a similar issues using Win7 as a destination - had to give "everyone" full control (I don't recommend Win 7 as a file server, but I did get it to work).

    I'm not sure if the IMPI driver is related.  I'm away from my lab this week so I can't do much in the way of testing.  

    -John

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment