To mount a network location in Windows Subsystem for Linux, use the following commands.
Mounting DrvFs
In order to mount a Windows drive using DrvFs, you can use the regular Linux mount command. For example, to mount a removable drive D: as /mnt/d
directory, run the following commands:
$ sudo mkdir /mnt/d
$ sudo mount -t drvfs D: /mnt/d
Now, you will be able to access the files of your D: drive under /mnt/d
. When you wish to unmount the drive, for example so you can safely remove it, run the following command:
$ sudo umount /mnt/d
Mounting network locations
When you wish to mount a network location, you can of course create a mapped network drive in Windows and mount that as indicated above. However, it’s also possible to mount them directly using a UNC path:
$ sudo mount -t drvfs '\server\share' /mnt/share
Note the single quotes around the UNC path; these are necessary to prevent the need to escape the backslashes. If you don’t surround the UNC path with single quotes, you need to escape the backslashes by doubling them (e.g. \\\\server\\share
).
WSL does not have any way to specify which credentials to use to connect to a network share. If you need to use different credentials to connect to the server, specify them in Windows by navigating to the share in File Explorer, using the Windows Credential Manager, or the net use
command. The net use
command can be invoked from inside WSL (using net.exe use
) via interop. Type net.exe help use
for more information on how to use this command.
Additional information: https://blogs.msdn.microsoft.com/wsl/2017/04/18/file-system-improvements-to-the-windows-subsystem-for-linux/