Share directory on Windows Hyper-V Host with Ubuntu VM
Good question.
The bad news is that, unlike VirtualBox or VMWare that allows you to define "Shared Folders" which are directories on your host that are exposed to the guest, Windows 8 Hyper-V does not provide such feature at all.
The good news is that, since there is not such feature provided out of box from Hyper-V at all, there won't be necessary special purposed tools for it, e.g., for mounting vboxsf
file systems. You just going through the official/standard way, accessing your host share folders as network shared folders.
The smbclient
, the command-line SMB/CIFS
clients for Unix, is the command-line tool to access to your Windows host share folders. Below are two examples that I found. Again, nothing special, access it the same way as you access any other Windows network shared folders.
How can I connect from Ubuntu 12.10 to file shares on a Windows 8 system
https://askubuntu.com/questions/245106/how-can-i-connect-from-ubuntu-12-10-to-file-shares-on-a-windows-8-system-using-a
Perfect Ubuntu setup on Hyper-V in Windows 8
http://webdevtooling.com/webdevtooling.com/tutorials/perfect-ubuntu-setup-on-hyper-v-in-windows-8/
I'll repost the "Configure a shared folder" section from the second link:
We need to share out a folder in the host to the guest. Guest can mount this on boot. For this tutorial, I’ll assume we are sharing it from a this location %USERPROFILE%\workspace
In the VM, edit the /etc/fstab
:
//WinHost/users/username/workspace /home/username/workspace cifs defaults,soft,uid=username,gid=users,file_mode=0777,dir_mode=0777,credentials=/home/username/.cifs-credentials,soft
Also, add a credentials file for the mount to work. Put the following content in there:
[email protected]
password=something
That should be it.
More references for GUI based mounting:
http://www.wikihow.com/Mount-a-Windows-Share-on-an-Ubuntu-Server
http://www.liberiangeek.net/2013/04/how-to-access-windows-network-shares-in-ubuntu-13-04-raring-ringtail/
http://www.7tutorials.com/how-access-windows-7-shared-folders-ubuntu
https://help.ubuntu.com/community/MountWindowsSharesPermanently
If it doesn't work for you at first, try with a Windows based client first to access the host share folders. Again, nothing special, access it the same way as you access any other Windows network shared folders. I.e., some how-tos says that you "must have Created Internal Virtual Switch Via Virtual Switch Manager" to use the host share, that is purely not necessary and it gives you no benefits/advantages at all, since we are just accessing it as a normal Windows network shared folder. To recap, here are the steps:
On your Hyper-V host, create a shared folder and assign Change permission to Everyone.
On the virtual machine running on the host, open the Network and Sharing Center and enable File and Printer Sharing.
On the virtual machine, click Start and type
\\host_name\share_name
wherehost_name
is the name of your Hyper-V host andshare_name
is the name of the share you created.Press ENTER and an Explorer window will open in the VM showing the contents of the shared folder on the host.
You can now copy files from the VM to the host and vice versa as needed.
References:
https://stackoverflow.com/questions/1386754/edit-source-directly-on-ubuntu-vm-from-windows-host/1386764#1386764
How to share files between a Hyper-V host and its virtual machines
http://www.windowsnetworking.com/kbase/WindowsTips/WindowsServer2008/AdminTips/VirtualPlatforms/HowtosharefilesbetweenaHyper-Vhostanditsvirtualmachines.html
The answer for Windows 8 and Ubuntu 14.04 or 14.10 seems to be a bit different.
When I click on the Files icon in the taskbar, it allows one to browse the network; the host machine is listed as a machine on the network. Clicking on the host machine opens up a dialog box where it demands a password. It took me a while to find the right combination of entries in the dialog which work.
The dialog shows values for User and Password. The User value is prefilled with the account name you created on Ubuntu. This is probably NOT what you want. Take a look at the C:\Users folder on your Windows system. Whatever name has been used for that folder which contains your personal Windows files (and a lot more) is the name you want to plug into the Ubuntu dialog box. Then enter your Windows sign-in password into the password field.
After your password has been accepted, you will be able to navigate to your files in the C:\Users folder and have full access to them. Access to other files and folders depends on the Windows permissions.