35

I'd like to mount a windows server from within WSL (Windows Subsystem for Linux). On Ubuntu (with unity interface) I can just type

gvfs-mount smb://domain\;user@server/share

and everything mounts just fine.

If I try this in WSL then I get the following error:

Error mounting location: volume doesn't implement mount
3
  • Use the mount command with fs type cifs Jul 21, 2017 at 18:45
  • Sure, is there an easy way to move it or do I just copy and paste it over there? Jul 25, 2017 at 16:38
  • I can't say I really use WSL much, so this is one of the first questions I had.. but then when I browsed to my /mnt directory, I realized all of my Windows drives are auto-mounted. Maybe this wasn't the case when WSL just came out but seems to be default behavior now. Just FYI. Thanks!
    – jacktrader
    Feb 8, 2023 at 0:59

5 Answers 5

69

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.

8
  • Hmm. I get mount: unknown filesystem type 'drvfs'.
    – chris
    Jun 1, 2018 at 16:19
  • 1
    Turns out (I guess) this is due to an old Windows build. github.com/Microsoft/WSL/issues/1975
    – chris
    Jun 1, 2018 at 16:29
  • BTW, could you fix the permissions in the meantime (I observe the same issue)?
    – kirk
    Mar 28, 2019 at 6:47
  • 5
    I knew that mount -t drvfs '<drive letter>:' /mnt/mountpoint was the way to do this for a normal disk partition, but never imagined that simply using a UNC path in place of the drive letter would automagically work as well! Many thanks and +1! :D
    – Kenny83
    Oct 30, 2019 at 14:37
  • 3
    I don't know about the rest of you, but the only option to connect to SMB share from WSL is to use the drive letter syntax (as answered by gabuzo below). If I use the unc drive syntax in single quotes '\\uncsharename\z', I get this error (i'm using WSL2 from Windows 10 v2004 Ubuntu 16 LTS) mount: /mnt/z: wrong fs type, bad option, bad superblock on \\uncsharename\z, missing codepage or helper program, or other error.<3>init: (8787) ERROR: UtilCreateProcessAndWait:489: /bin/mount failed with status 0x2000No error information
    – AdamE
    Aug 21, 2020 at 21:28
32

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
1
  • This is the solution that worked for me! Thanks
    – Nicolas
    Jan 2, 2021 at 2:46
12

Mounting an SMB server share should be straightforward, I tested this on Windows build 1909 and WSL 2.0 Ubuntu 20.04.1 LTS (GNU/Linux 4.19.128-microsoft-standard x86_64). You use mount just as usual:

sudo mount -t drvfs '\\server\share' /your/mount/folder

Nothing too hard, the source path of the mount is the regular UNC pathname. The important bits are the file system type ("drive filesystem"?) and the fact that you need to enclose the server path in single quotes (on the command line). As usual, your mount folder must also exist.

On this WSL issue I found good options (-o) that seem to work very well with creating, reading and writing files without sudo as well as reading correct modification/creation dates:

metadata,rw,noatime,uid=1000,gid=1000,umask=22,fmask=11

Because I like to have this server mounted always, I put the mount instruction into /etc/fstab to have it auto-mounted by WSL:

\\server\share /your/mount/folder drvfs metadata,rw,noatime,uid=1000,gid=1000,umask=22,fmask=11 0 0

(you can reload fstab with sudo mount -a)

Note that I have logged into the server on Windows itself and made it remember the user and password. @David C. Rankin's answer has some info on how to specify username and password if you need to do it separately.

7

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.

0
4

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.

2
  • CIFS mounts work fine in Debian in WSL, so I'm going to assume it is an Ubuntu-specific problem.
    – Foritus
    Aug 9, 2021 at 1:41
  • @Foritus they don't work for me
    – jurgen
    Jan 13, 2023 at 14:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.