Mounting a windows share in Windows Subsystem for Linux
Assuming the host Windows OS can access a file share at "\\servername\sharename", try this command in bash. You will need to be root:
mkdir /mnt/mountedshare
mount -t drvfs '\\servername\sharename' /mnt/mountedshare
The single quotes are important!
Worked for me with a SharePoint Online UNC path. The permissions are screwy though. I can navigate through the folders and see the filenames, but I can't read files. So need to figure out the permissions thing. Let me know if you get anywhere with that.
While you have an a mount created to the windows host through /mnt/c
already created for you in WSL, if you want to mount a share from another machine, then you will need to create the mount point, e.g.
sudo mkdir -p /mnt/somename
Then you will need to mount the remotely shared smb://
filesystem at that mount point using mount.cifs
, e.g.
sudo mount.cifs //server/sharename /mnt/somename
Optionally, you will want to include options following /mnt/somename
such as
-o username=yourname,uid=YOURUID,noperm,password=yourpassforremoteshare
If it is an older WinXP share you are attempting to mount, then you will need to enable NTLMv1
authentication by including the sec=ntlm
or sec=ntlm1
. See mount.cifs
for further use of the sec=
option.
Actually if your windows share is already mapped to a drive in the Windows host, it can be even simpler. Let's suppose you already mounted the share on Z:
. In that case the following will work:
sudo mkdir /mnt/z
sudo mount -t drvfs 'Z:' /mnt/z
In WSL (I'm using Ubuntu) it looks like that when you install the cifs-utils it doesn't create the module file that cifs needs when mounting. Type: "modinfo cifs" and you will see. Anyway, the work-around is to map a drive letter in Windows and then mount to that, as mentioned above. Thanks gabuzo.
Maybe its that cifs-utils is looking in the wrong place for the module file. Or MS intentionally disabled it. They don't want WSL to be too useful.