共用方式為


File System Improvements to the Windows Subsystem for Linux

This is part of a series of blog posts on the Windows Subsystem for Linux (WSL). For background information you may want to read the architectural overview, introduction to pico processes, WSL system calls, and WSL file system blog posts.

Posted on behalf of Sven Groot

Summary

In the latest Windows Insider build, the Windows Subsystem for Linux (WSL) now allows you to manually mount Windows drives using the DrvFs file system. Previously, WSL would automatically mount all fixed NTFS drives when you launch Bash, but there was no support for mounting additional storage like removable drives or network locations.

Now, not only can you manually mount any drives on your system, we've also added support for other file systems such as FAT, as well as mounting network locations. This enables you to access any drive, including removable USB sticks or CDs, and any network location you can reach in Windows all from within WSL.

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.

Volumes mounted on empty NTFS folders

If your system has any volumes that do not have drive letters but are instead mounted on an empty NTFS folder, you are now able to mount those as well. WSL only automounts volumes with drive letters, so up to this change volumes mounted on a directory could not be accessed.

To now mount such a volume in WSL, simply use the path to its mount point:

$ sudo mount -t drvfs 'C:\mountpoint' /mnt/myvolume

Note that the path you specify must be a mount point; you cannot use an arbitrary directory as the root of a drvfs instance. If you wish to accomplish this, you can already do so using bind mounts.

DrvFs behavior for different file systems

The way drvfs behaves may be slightly different depending on the underlying file system. Certain features may not be available with all file systems. For example, the FAT file system is not case sensitive, and does not support hard links or symbolic links.

With network file systems, DrvFs does not set the correct Linux permissions bits on a file; instead, all files are reported with full access (0777) and the only way to determine if you can actually access the file is by attempting to open it. Network file systems are also not case sensitive and do not support symbolic links.

Comments

  • Anonymous
    April 18, 2017
    Bring back the videos ;-) ... I really enjoy them.
  • Anonymous
    April 18, 2017
    I guess my next question is how about mounting samba shares from linux machines? Can you do that directly without going through drvfs? Which would then having the correct permissions etc?The community was close to getting it working here:https://github.com/Microsoft/BashOnWindows/issues/764
  • Anonymous
    April 18, 2017
    This is all fine. But what about the slow file system in general. 2 months ago with the insider's version I had bench marked simple tasks as:- tar/uncompress software packages (e.g. FFmpeg, samba)- Running simple programs e.g. launcing Apache server, some binaries that accessed a handfull of files- H.264/HEVC encoding/decodingCompared to a VM running on the same system (Surface Book), the first 2 tasks were done many times slower by WSL (by a factor of 4-5). Only native encoding and decoding were slightly faster on WSL (10-15% faster). But given the shortfalls, why would one go into all the trouble where many things have rough edges? Shortly speaking, I abandoned using WSL; back to good old VM.
    • Anonymous
      April 20, 2017
      Same slow disk for me. I tried WSL for compiling Inkscape and a no change make (which just checks dependencies) takes > 1 minute while inside VirtualBox, it only takes 30s.Could it be:Overhead of read & write system calls?Double caching? VirtualBox by default disables the host disk cache for accessing the disk imageNTFS not designed to handle all those small files?
    • Anonymous
      April 21, 2017
      WSL I/O performance will always be limited by the I/O performance of the underlying Windows kernel and filesystems.My perception is that Windows has always been slower than Unix when working with lots of small files. Creating/writing small files is particularly expensive on Windows compared to Unix. You can really see the difference when extracting archives. I believe it has something to do with the different cache strategies (file level vs. block level).Process creation is also more expensive on Windows vs. Unix. Programs designed for Unix often create many short-lived processes, and these run relatively poorly on Windows Programs designed for Windows tend to use threads.
      • Anonymous
        May 13, 2017
        Reminder: AV generally slows down things a lot. (Even Defender has nontrivial impact on large number of small access)
  • Anonymous
    April 19, 2017
    I arrived here from the Feedback Hub where an item is now marked as completed, but it doesn't look like it was actually completed. I am really hoping to be able to mount a remote linux filesystem within WSL.
  • Anonymous
    April 19, 2017
    What about the MAX_PATH value?
  • Anonymous
    April 19, 2017
    I had to use:$ sudo mkdir /mnt/d
    • Anonymous
      April 19, 2017
      Good catch. I have updated the instructions.
  • Anonymous
    April 19, 2017
    This is great. Still after fuse support however :)
  • Anonymous
    April 19, 2017
    Ok that's a great feature but what about the support of USB serial devices, This was the original request. We need USB serial ports to access sensors, robots, eprom programmers,... Are those supported?
    • Anonymous
      April 19, 2017
      Yes USB serial devices are now supported https://aka.ms/b0o8l9
      • Anonymous
        April 20, 2017
        Thank you
  • Anonymous
    April 19, 2017
    Yes USB serial devices are now supported in insider builds. More details in the blog post https://aka.ms/b0o8l9
    • Anonymous
      April 19, 2017
      Is NFS supported? I don't see that it seems to be working?
  • Anonymous
    April 19, 2017
    The comment has been removed
  • Anonymous
    April 19, 2017
    Is there a trick to read/write pendrive mounted as D:, E:,... without waiting for the next Windows upgrade? I am not an insider and it is very annoying every time to put data on C: and the to or from USB..I don't understand why the WSL developers haven't implemented this from the first release... It is the first thing to do otherwise WSL is an isolate, closed, uncommunicating system...
  • Anonymous
    April 19, 2017
    This is awesome. Makes WSL on my laptop so much more usable as the second hard drive is mounted to an empty NTFS folder on the primary C: drive. Until now that was inaccessible to WSL. Keep up the good work!
  • Anonymous
    April 20, 2017
    The comment has been removed
  • Anonymous
    April 20, 2017
    Hmmm maybe you could make a proper NTFS solution for linux to compete with Tuxera on routers using a unix base :P
  • Anonymous
    April 20, 2017
    What about NFS volumes from unix/linux? How do you manage permissions between windows and linux? can you easily control which gid/uid that you are using?
  • Anonymous
    April 21, 2017
    When is Ubuntu 17.04 coming for wsl or should I use the in official way
    • Anonymous
      April 24, 2017
      You are welcome to try doing a release upgrade to 17.04 but you may run into things that do not work. Our current focus is on making sure 16.04 is rock solid.
  • Anonymous
    April 22, 2017
    sorry, I'm not getting this to work at all:sudo mount -t drvfs D: /mnt/dmount: unknown filesystem type 'drvfs'what am I missing?I'm running: lsb_release -aNo LSB modules are available.Distributor ID: UbuntuDescription: Ubuntu 16.04.2 LTSRelease: 16.04Codename: xenial
    • Anonymous
      April 24, 2017
      What Windows build are you running? (type 'ver' in a Windows command prompt)
      • Anonymous
        May 13, 2017
        Same problem (unknown file system type 'drvfs'). Windows ver: 10.0.15063 ; Linux Ununtuu 14.04.5 LTS . How do I get latest versions? I've done "apt-get update"
        • Anonymous
          October 19, 2017
          workingn now - Windows ver: 10.0.16299.15 Now just wondering how to do this automatically; /etc/fstab doesn't seem to get run
      • Anonymous
        June 06, 2017
        I'm seeing this error on Ubuntu 16.04.02 and Windows Version 10.0.15063
  • Anonymous
    April 22, 2017
    AH! UFF! I'm not running Windows Insider builds. Ah! Uff! Must wait until this is released aftr Version 1703, OS Build 15063.138, which is what I'm running.
  • Anonymous
    April 23, 2017
    oh, it's perfect!can somebody tell me - is it possible to automount networkdrive using fstab? What options has drvfs?
  • Anonymous
    April 23, 2017
    Thanks for adding this feature. I've had good results with it so far. I second the suggestion for Fuse support, especially for something like sshfs, which seems to be there in the Windows Ubuntu build, but not available due to lack of kernel support.
  • Anonymous
    April 23, 2017
    The comment has been removed
    • Anonymous
      April 28, 2017
      The comment has been removed
      • Anonymous
        May 12, 2017
        The comment has been removed
  • Anonymous
    April 24, 2017
    Is there a technical reason why mount/drvfs doesn't have the option to do translation from forward slash to backslash when providing a mount path? It is strange to have to different method of delineating directories given in the same command.Is DrvFs support for CDFS limited to UDF/Joilet or will it present Rock Ridge extensions such that the file names and permissions appear the way expected in a bash environment?Does Drvfs finally add any concept of a loop mount against a flat file as a file system? Does this have the ability to mount/modify a Windows Imaging (WIM) file similar to the WAIK ImageX command?Lastly, is the source code available?
  • Anonymous
    April 25, 2017
    Great work!!I am wondering how could I apply this build to my machine?
    • Anonymous
      April 25, 2017
      You can access pre-release builds of Windows by joining the Windows Insider program.
  • Anonymous
    April 26, 2017
    I suspect that the three issues now marked closed didn't actually need to be closed just yet - I'll have to test Android connections once I get this build, and then open at least one of those issues again...
  • Anonymous
    April 27, 2017
    Am I the only one this isn't working for? The mount command doesn't give any error messages but it doesn't actually do the mount.
  • Anonymous
    April 29, 2017
    In the Bash on Ubuntu on Windows FAQ, under "How do I use a Windows file with a Linux app?", it says, "One of the main limitations of using WSL is that changing Linux files with a Windows app or tool is not allowed. See: Do not change Linux files using Windows apps and tools".Do the improvements described in this article change that? If so, how?If not, when will it be possible to "change Linux files using Windows apps and tools"?Thanks.Love and peace,Joe
  • Anonymous
    May 08, 2017
    Perhaps a newbie question. I am in trouble. My external SSD (formatted in exFAT), U:, contains a directory "Windows" with files, all accessible from Windows 10. If I try to access the directory from WSL ( sudo mount -t drvfs 'U:Windows' /mnt/u, then cd /mnt/u, then ls), WSL does not see anything.If I issue from WSL a sudo touch /mnt/u/afile.txt, then ls /mnt/u, I do see the afile.txt, but not from Windows. I do not understand whether that is standard behaviour or not. Moreover, should I not issue some ln -s somewhere in WSL ?Thanks in advance if anyone can help.(Sandisk Ultra-II 960 GB connected to an USB3 port on an Asus ROG G20 via an Ugreen adapter)
  • Anonymous
    May 10, 2017
    So I can also do sudo umount /mnt/dfollowed by a sudo mount -t lxfs D: /mnt/d?That would be so awesome!
  • Anonymous
    May 11, 2017
    So I'm having good success defining a networked mount point in /etc/fstab and mounting it manually, but I'm smashing my face against having it mount when I open a new WSL session.This syntax works to define a mount point, but what am I missing with getting it to mount automatically?\server\path\to\share /mnt/h drvfs defaults 0 0Thanks for getting this built in, this is the feature I've been looking for since WSL came out!
  • Anonymous
    May 15, 2017
    Thank you guys for your work. Interop between subsystems is a great step to environment unification for many developers.But I want Would wsl be available on win10 for arm?
  • Anonymous
    May 18, 2017
    When is this coming to regular windows updates? and not just an Insider build?
  • Anonymous
    May 26, 2017
    You guys are doing amazing work with WSL. Keep it up!
  • Anonymous
    May 28, 2017
    Not sure I need to mount an SMB share, but drive-letters mapped to network drives in my Windows 10 system don't show up in /mnt, so I'm guessing that to access them I have to mount them separately in WSL. So, if I try to do it, I get no error, but it also doesn't prompt me for credentials, and it doesn't seem to mount the share. ddb@DDB4:~$ sudo mount -t drvfs '\fsfs\ddb' /mnt/ddb[sudo] password for ddb:ddb@DDB4:~$ ls /mntc e h i j l oddb@DDB4:~$ ls /mnt/ddbls: cannot access /mnt/ddb: No such file or directorymount reports I do have it mounted (and lists it three times if I try three times; no errors on any of the mount commands). Any ideas?
  • Anonymous
    June 14, 2017
    I have a windows 10 vm (using vmware pro 12.5.6 build-5528349) and I am using the latest WSL on the guest. The host is windows 10. I have a shared folder from the host that is visible outside wsl bash in the guest but I can't mount it or access it within wsl. Has anybody tried getting this to work?
  • Anonymous
    June 23, 2017
    WSL is good , most of my work under Ubuntu can be moved to window, but there is still some problem happed when I use WSL. I am running a program writed by Fortran languge under WSL , the program will creat a file with " : " in the filename , which is not supported by window file system, so the program runs to an I/O error. I know this can be passed by changing the program , but it still a problem for WSL, otherwise, change the program is just not so easy sometime. I wonder if there is a solution for this.
  • Anonymous
    July 07, 2017
    Hey! You guys are doing Great work. . keep it up!
  • Anonymous
    July 11, 2017
    followed your advice but bash in windows 10 does not recognize drvfs or DrvFs. i am trying to mount a usb deviceas F:
    • Anonymous
      July 21, 2017
      Could you ensure you are running build 16176 or later (type ver at the command prompt)?
      • Anonymous
        August 29, 2017
        Hello,What if my windows version is Microsoft Windows [version 10.0.15063] ? How can I upgrade ? I have a look in Windows update parameter. It is saying that I am up to date !!
        • Anonymous
          September 21, 2017
          Looks like you're running Windows 10 Anniversary Update in the Preview Ring. You should be able to upgrade to Creators Update by now. Fall Creators Update is shipping in October 2017.
  • Anonymous
    November 09, 2017
    Thanks for this, it's working fine for me. Now, how do I make it permanent? I have a 200GB SD card that I leave in my Surface Book as a permanent D drive. The problem is that I can run these commands, and the mount works. However, I have to run it EVERY time I open Bash. Is there a way to make the mount permanent? I know I should be able to use /etc/fstab, but I've spent 2 hours Googling and Binging for a solution to no avail.Thanks!
    • Anonymous
      November 20, 2017
      You can use and edit this script, which adds your mount command to fstab and reloads it everytime you open a shell.https://gist.github.com/sgtoj/f82990bcd9e89db49b84e2d2e70b281d
  • Anonymous
    November 15, 2017
    HiI'm used to Cygwin.I need a way to mount network drives automatically. It is an Apple Time Capsule I'm using. I can mount the drive manually with sudo mount -t drvfs '\server\share' /mnt/share but in Cygwin network drives are mounted automatically.
    • Anonymous
      April 13, 2019
      The comment has been removed
  • Anonymous
    November 17, 2017
    While I do some things in WSL, until the USB ports work properly it's just going to be mostly play time me.
  • Anonymous
    November 20, 2017
    Hi guys,I am trying to run a tool for calculating the power consumption due to I didn't have a Linux PC. I install WSL on my machine, and when I run modprobe msr, I got this error.root@DESKTOP-MUPJIP0:~# sudo modprobe msrmodprobe: ERROR: ../libkmod/libkmod.c:586 kmod_search_moddep() could not open moddep file '/lib/modules/4.4.0-43-Microsoft/modules.dep.bin'modprobe: FATAL: Module msr not found in directory /lib/modules/4.4.0-43-MicrosoftI had read in GitHub the problem not solve on April just wondering the latest Windows update does give a solution to the problem?Thanks a lot.
    • Anonymous
      December 04, 2017
      WSL is only an imitation of Linux. Things that require modprobe will not work, because modprobe is what Linux uses to load driver and other low-level stuff. Look into Linux LiveCD for these.
  • Anonymous
    November 24, 2017
    budi@DESKTOP-JHFL5D4:~$ sudo mount -t drvfs /mnt/c/Users/sven/PhpstormProjects/ /mnt/projects/mount: wrong fs type, bad option, bad superblock on /mnt/c/Users/sven/PhpstormProjects, missing codepage or helper program, or other error In some cases useful info is found in syslog - try dmesg | tail or so.
    • Anonymous
      November 20, 2018
      Have you figured this out? I'm having the exact same problem
  • Anonymous
    December 28, 2017
    Have a Movidius device connected on Windows (USB) Any idea how I can access the device in Linux subsystem?
  • Anonymous
    January 20, 2018
    No updates in a while...
  • Anonymous
    November 20, 2018
    I'm getting the following error when trying to mount:mount: wrong fs type, bad option, bad superblock on \oh-col-fs03, missing codepage or helper program, or other error'\oh-col-fs03' is the name of the network drive I'm trying to mount.
  • Anonymous
    February 06, 2019
    Good one
  • Anonymous
    March 19, 2019
    wondering why it is so hard to mount nfs volumes. bzanaj@linux:~$ showmount -e 192.168.0.21Export list for 192.168.0.21:/mnt/nfs 192.168.0.0/24,0.0.0.0/24bzanaj@linux:~$ sudo mount 192.168.0.21:/mnt/nfs /mnt/test/mount.nfs: No such devicebzanaj@linux:~$
  • Anonymous
    March 25, 2019
    Hi, I use ROS (Robotic Operating System) in Ubuntu, however, I'd like test this option, but I need use a web cam and I cannot configure it, It is supported, yet?