Exporting to / Importing from a network share [Hyper-V]






The first thing that I needed to do as part of my big rebuild was to move non-critical virtual machines to a remote file server.  The easiest way to do this would have been to export the virtual machines to a local location and then move them up to a network share.  Unfortunately I did not have enough space on the local hard disk to do this.  So what I needed to do was to export the virtual machines directly to a remote network share.


Luckily I had two things working in my favor:



  1. Both my Hyper-V server and my file server (okay, it was actually my desktop computer) are in the same domain

  2. I was performing the operation directly from the Hyper-V console (not using remote management tools)

Now it is possible to do this still if the above two items are not true – but it gets a lot more complicated.


Given this setup I needed to create and configure a share for the exported virtual machines to be created on.  I logged into my desktop computer and created a share – which granted full access to my user account by default.  But this is not enough for Hyper-V.


Hyper-V does a lot of operations using local service accounts on the Hyper-V computer.  So the network share needs to have permission granted for both the user account that you are using and for the computer account for the Hyper-V server.  The user account is easy to setup (and in my case was setup by default).  Setting up the computer account is a little trickier.


To do this on a Windows 7 computer you will need to go to the folder that is being shared and:



  1. Right click on the folder and select Properties.

  2. Click on the Sharing tab.

  3. Click on the Advanced Sharing… button.

  4. Click on the Permissions button.

  5. Click on the Add… button.

    If your user account does not have access on the share – now is a good opportunity to add it.  The next step is a little bit tricky – because this dialog does not allow you to add computer accounts by default.


  6. Click on the Object Types… button.

  7. Check Computers and click OK.

    image 

  8. Type the name of Hyper-V server followed by a “$” into the text box and click OK

    My Hyper-V server is named “Hyper-V” (original – I know) so for me I have to type in “Hyper-V$”.


  9. Give the Hyper-V server computer account full control on the share (and your user account if you are adding it at the same time) by checking the Allow option next to Full Control when the computer account is selected.

  10. Click OK and click OK again.

  11. Click on the Security tab.

  12. Click Edit…

  13. Click Add…

  14. Click on the Object Types… button.

  15. Check Computers and click OK.

  16. Type the name of Hyper-V server followed by a “$” into the text box and click OK

  17. Give the Hyper-V server computer account full control on the share by checking the Allow option next to Full Control when the computer account is selected.

  18. Click OK

  19. Click Close

Now that all of that is done you can go to the Hyper-V server, select the virtual machine that you want to export, and when you are prompted for a location you can type in the UNC path of the share you have just created, and specify a subfolder for the virtual machine.  For example – if I was exporting a virtual machine called “WDS Server” to the “Export” share on my computer “Benjamins-PC” I would enter “\\Benjamins-PC\Export\WDS Server” into the export location for the virtual machine.


When you want to import the virtual machines back off the network share – you need to ensure that you select to “Duplicate all files so the same virtual machine can be imported again” – as we do not support running virtual machines from a network share.


One final note to make – while we do not support running virtual machines from folders where NTFS compression is enabled – you can enable it on a folder where you are storing exported virtual machines to reduce the amount of space needed.


Cheers,
Ben