Hyper-V: Create shared folder between host and guest with internal network
Set up:
- Host: Windows 10 Enterprise
- Guest: Windows 10 Professional
- Hypervisor: Hyper-V
Aim:
- Create a shared folder between Host and Guest via an internal network to exchange files
How can I achieve this?
Solution 1:
Share Files, Folders or Drives Between Host and Hyper-V Virtual Machine
Prerequisites
-
Ensure that Enhanced session mode settings are enabled on the Hyper-V host.
Start Hyper-V Manager, and in the Actions section, select "Hyper-V Settings".
Make sure that enhanced session mode is allowed in the Server section. Then, make sure that the enhanced session mode is available in the User section.
-
Enable Hyper-V Guest Services for your virtual machine
Right-click on Virtual Machine > Settings. Select the Integration Services in the left-lower corner of the menu. Check Guest Service and click OK.
Steps to share devices with Hyper-v virtual machine:
-
Start a virtual machine and click Show Options in the pop-up windows.
Or click "Edit Session Settings..." in the Actions panel on the right
It may only appear when you're (able to get) connected to it. If it doesn't appear try Starting and then Connecting to the VM while paying close attention to the panel in the Hyper-V Manager.
-
View local resources. Then, select the "More..." menu.
-
From there, you can choose which devices to share. Removable drives are especially useful for file sharing.
-
Choose to "Save my settings for future connections to this virtual machine".
-
Click Connect. Drive sharing is now complete, and you will see the shared drive in this PC > Network Locations section of Windows Explorer after using the enhanced session mode to sigh to the VM. You should now be able to copy files from a physical machine and paste them into a virtual machine, and vice versa.
Source (and for more info): Share Files, Folders or Drives Between Host and Hyper-V Virtual Machine
Drawbacks
- While this solution is easy and probably works faster then when using internal network, it has its own drawback: the drive is mapped only while there is a connection via the VMConnect client. If you run a vm with some background services or you connect to it via RDP, this approach isn't gonna work. (thanks @sich for pointing this out)
Solution 2:
- Open Hyper-V Manager
- Create a new internal virtual switch (e.g. "Internal Network Connection")
- Go to your Virtual Machine and create a new Network Adapter -> choose "Internal Network Connection" as virtual switch
- Start the VM
- Assign both your host as well as guest an IP address as well as a Subnet mask (IP4, e.g. 192.168.1.1 (host) / 192.168.1.2 (guest) and 255.255.255.0)
- Open cmd both on host and guest and check via "ping" if host and guest can reach each other (if this does not work disable/enable the network adapter via the network settings in the control panel, restart...)
- If successfull create a folder in the VM (e.g. "VMShare"), right-click on it -> Properties -> Sharing -> Advanced Sharing -> checkmark "Share this folder" -> Permissions -> Allow "Full Control" -> Apply
- Now you should be able to reach the folder via the host -> to do so: open Windows Explorer -> enter the path to the guest (\192.168.1.xx...) in the address line -> enter the credentials of the guest (Choose "Other User" - it can be necessary to change the domain therefore enter ".\"[username] and [password])
There is also an easy way for copying via the clipboard:
- If you start your VM and go to "View" you can enable "Enhanced Session". If you do it is not possible to drag and drop but to copy and paste.
Enhanced Session
Solution 3:
Sorry I'm forced to write this as an Answer rather than a Comment because of reputation, but for those who are having trouble getting the "Edit Session Settings..." dialog I found that I could get to the dialog box by having the guest machine running in windowed mode so that the top menu ("File Action Media Clipboard View Help") was visible, then selecting File > Exit (or clicking on the "X" at the top right of the guest machine window).
After that the dialog would launch from the Hyper-V Manager Actions "Edit Session Settings..." link.