120

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?

quervernetzt
  • 10,311
  • 6
  • 32
  • 51

4 Answers4

176

Share Files, Folders or Drives Between Host and Hyper-V Virtual Machine

Prerequisites

  1. Make sure you have a Pro or Enterprise version of the Windows OS. The Home version does not provide you with this functionality! From the official documentation:

The virtual machine must have Remote Desktop Services enabled, and run Windows 10, Windows 8.1, Windows Server 2016, or Windows Server 2012 R2 as the guest operating system.

  1. 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".

    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.

    use-enhanced-session-mode

  2. 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.

    enable-guest-services

Steps to share devices with Hyper-v virtual machine:

  1. Start a virtual machine and click Show Options in the pop-up windows.

    connect-to-vm

    Or click "Edit Session Settings..." in the Actions panel on the right

    edit-session-sessions

    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.

  2. View local resources. Then, select the "More..." menu.

    click-more

  3. From there, you can choose which devices to share. Removable drives are especially useful for file sharing.

    choose-the-devices-that-you-want-to-use

  4. Choose to "Save my settings for future connections to this virtual machine".

    save-my-settings-for-future-connections-to-this-vm

  5. 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.

    shared-drives-from-local-pc

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)
Foad S. Farimani
  • 12,396
  • 15
  • 78
  • 193
laggingreflex
  • 32,948
  • 35
  • 141
  • 196
  • 2
    There's no dialogue for Show Options. There's only a start button. After clicking it, the system start. – lovetl2002 May 14 '20 at 11:10
  • @user2923419 There should be an "Edit Session Settings" [in the Actions panel on the right](https://i.imgur.com/El4VGxu.png) if the dialogue doesn't show up when connecting (since you must've checked the "Save my settings for future connections to this virtual machine" option) – laggingreflex May 15 '20 at 05:19
  • 5
    I finally figure out the reason. The VM I created was Gen 1. I recreate a Gen 2 VM and then the dialogue shows up on connection. – lovetl2002 May 15 '20 at 10:56
  • 1
    Hey man... This one should be marked as answer... The one with IP Addresses is too abstract & complicated.... Thanks for your hard work... It's worth a blog post! – Naeem A. Malik May 24 '20 at 00:54
  • 2
    @user2923419 have a gen 2 and there is only Settings, no Edit Session Settings. – Marco May 30 '20 at 14:09
  • @Marco You have to first **select** the machine in the left panel – laggingreflex May 30 '20 at 23:07
  • 1
    @laggingreflex Like I said, I already did that. https://i.ibb.co/7SDy36S/No-settings-edit.png The icon for "Edit settings" is missing (or I am missing something). – Marco Aug 15 '20 at 07:32
  • @Marco Hmm, I think it only appears when you're connected to it. Try going through an entire lifecycle of the VM (start > connect) while paying close attention to the Actions panel in the Hyper-V Manager, it should appear at some point.... (for me it seems to appear only when the machine's state is "Running" and I'm able to actually connect to it). – laggingreflex Aug 15 '20 at 17:32
  • @laggingreflex In the screenshot in the last command, the state was "Running" (in french). I try all states mods, on differents types of VM. Never get the "Edit Settings". – Marco Aug 15 '20 at 19:42
  • @Marco Are you able to connect to the VM? Does it have an OS installed, if so which? I think the "Edit Session Settings" might only appear when the OS is Windows and you're actually able to connect to it. – laggingreflex Aug 15 '20 at 20:25
  • @laggingreflex Thanks for your help. Never tried with Windows OS, it might be the problem. I tried with DockerDesktopVM et Ubuntu20.04. – Marco Aug 16 '20 at 08:39
  • Obviously, I was able to connect to both VM. – Marco Aug 17 '20 at 07:22
  • @laggingreflex It appears on VM with Ubuntu, too. Tested on Hyper-V with Ubuntu 20.4 – gotqn Nov 07 '20 at 17:08
  • Turning on these checkboxes helped me: 1. Hyper-V Settings > Enhanced Session Mode Policy > Allow enhanced session mode; 2. Hyper-V Settings > Enhanced Session Mode > Use enhanced session mode – oyaebunterkrah Feb 09 '21 at 07:54
  • 1
    For me, the popup that most of us couldn't find (the one with the screen resolution selection and the "show options" button) was in the window of the virtual machine connection (i.e., the client window) under the "View" menu. There was the menu item "Extended Session". So "View"->"Extended Session". – flu Aug 04 '21 at 14:25
  • Thank you @laggingreflex! This worked for me when I was unable to get a shared folder between host and guest. – xb353 Aug 05 '21 at 23:52
  • I already knew how to do this particular method, but is there a way that I can access the hard drives on the VM from the Host machine's Windows Explorer? I can see the C:\ of the host machine on my VM but I can't see the C:\ of the Guest machine from the Host machine. The reason I need it to be this way is because I'm trying to open this folder in another program and it can see network drives and things like that, but if I didn't have to set up network drives that would be much better. – Chris Aug 31 '21 at 00:42
  • @lovetl2002 I had to select gen1 while creating my VM, because otherwise i could not install OS from ISO. So how do I copy-paste resources in this case? The dialog really does not show up... – Alexander Sep 14 '21 at 19:48
  • I failed miserable at getting to the "edit session" options. Eventually what saved the day was running this command in elevated/administrator mode: `vmconnect localhost "My VM Name" /edit` – Martin Andersson Sep 29 '21 at 15:27
  • 3
    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. – sich Nov 01 '21 at 08:21
  • @sich yep, I realized that too. I've added it in the answer. – laggingreflex Nov 01 '21 at 09:58
  • 1
    Shame on you Microsoft... it took about 20 mouse clicks and various hidden menus and options to share by hard disk... honestly – Daniel Farrell Feb 02 '22 at 13:12
  • sent a [pull request](https://github.com/MicrosoftDocs/windowsserverdocs/pull/6473) to improve the documentation, and make sure the Home users will not suffer as much as I did! – Foad S. Farimani May 20 '22 at 13:57
  • I have to give credit where credit is due. Since I have Ubuntu as the VM, I thought it was not going to work but if you don't give up and keep trying new ways of starting the VM and watch carefully for what menus pop up during the process, you will find that "shared-drives" in the file manager in Ubuntu will have what you share !! Excellent work !! – xarzu Aug 20 '22 at 17:57
  • I don't think it's a good method, it even consumes more CPU than using SMB in a VM and is slower than SMB and sometimes unstable. – Kenvix Zure Jul 18 '23 at 02:48
68
  • 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

quervernetzt
  • 10,311
  • 6
  • 32
  • 51
  • 2
    Inability to enable Enhanced Session is the only pain! Nothing works, nothing. – Ajay Oct 29 '17 at 11:59
  • 7
    Rather than futzing with IPs, it's easier to just use the VM and Host computer names. That's what I use. Pinging can be skipped unless you actually have issues, then you can use it for diagnostic purposes. ;) – Chiramisu Apr 08 '18 at 06:02
  • this will not work if you got more than 20 VMs that need share the drive. Windows is hard limit to only allow 20 connection at a time. – CharlesC May 11 '18 at 18:29
  • 1
    Where do I go to "Create a new Network Adapter" on the virtual? – Stephen R Aug 21 '18 at 23:32
  • 1
    The static IP assignment part is not necessary (you can just use computer names). More important is not to forget to disable your firewall for the Hyper-V network adapters in the *public* profile on the host machine, otherwise the guest machine won't be able to reach it (see [this answer](https://superuser.com/a/1168712/563129)). – Géry Ogam Nov 12 '18 at 21:02
  • Worked for me, but would be worth to point out that firewall may have to be disabled or add new rules. – pompalini Dec 13 '18 at 17:05
  • This is the worst implementation among all VM solutions I know. Not only does it limit the guest to either internet access or file share, but the samba share inside windows is buggy and rarely works. Is there no other way? – Spero Dec 18 '18 at 19:50
  • @StephenR In the "action" menu. https://i.stack.imgur.com/tSKCz.png – Marco May 30 '20 at 14:15
  • The copy and paste work like a charm. I never realize I can directly copy files into VM that easily. – Qin Heyang Aug 27 '20 at 22:34
7

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.

Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
Dave Lydick
  • 79
  • 2
  • 2
-2

My version is Hyper-V Version: 10.0.22509.1000,I think the best and most convenient way in windows is that configuring the host and the vm in the same subnet,So you can just use the ctrl+c and ctrl+v Seamlessly between host and vm.