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 (52)

  1. Eric L. Frederich says:

    Bring back the videos 😉 … I really enjoy them.

  2. Riley says:

    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

  3. Wacky says:

    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/decoding
    Compared 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.

    1. Yale Zhang says:

      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 image
      NTFS not designed to handle all those small files?

    2. John Doe says:

      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.

      1. Klimax says:

        Reminder: AV generally slows down things a lot. (Even Defender has nontrivial impact on large number of small access)

  4. rewen says:

    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.

  5. Carlos says:

    What about the MAX_PATH value?

  6. I had to use:
    $ sudo mkdir /mnt/d

    1. Jack Hammons says:

      Good catch. I have updated the instructions.

  7. wsl user says:

    This is great. Still after fuse support however 🙂

  8. Poliakoff says:

    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?

    1. Deepu Thomas says:

      Yes USB serial devices are now supported https://aka.ms/b0o8l9

  9. Deepu Thomas says:

    Yes USB serial devices are now supported in insider builds. More details in the blog post https://aka.ms/b0o8l9

    1. Paul Stejskal says:

      Is NFS supported? I don’t see that it seems to be working?

  10. L. says:

    Oh, that’s very good! Except for the final part: “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.” This is going to be slightly painful. Hopefully you will improve this soon. Is it possible to pass umask=??? to mount so that something other than full access is reported?
    What about symlink interop between wsl and win32? Any change?
    @wsl user; yeah, fuse would be nice. Moreover, it would make it possible to work around many limitations of the current implementation (e.g. cygwin-like tricks could be used to emulate symbolic links on network drives).
    @Paul Stejskal: Good question, I hope they answer it (and maybe talk a bit about future plans for NFS). I would guess that currently NFS is handled as any other (meaning, cifs/smb2/smb3) network filesystem, with the limitations described in the post.

  11. Angelo says:

    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…

  12. Robert Oeffner says:

    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!

  13. Pavel says:

    I don’t seem to be able to access (read) files which do not have execute flag set..
    I have shared disk mounted, i create a file – i can access it. Then with ssh to Linux machine if i do chmod a-x on it, i can’t read it anymore from WSL (from Windows itself file is still good).

  14. alystair says:

    Hmmm maybe you could make a proper NTFS solution for linux to compete with Tuxera on routers using a unix base 😛

  15. @davikes says:

    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?

  16. Aritra Jana says:

    When is Ubuntu 17.04 coming for wsl or should I use the in official way

    1. Ben Hillis says:

      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.

  17. Rodrigo Lopez says:

    sorry, I’m not getting this to work at all:

    sudo mount -t drvfs D: /mnt/d
    mount: unknown filesystem type ‘drvfs’

    what am I missing?

    I’m running:
    lsb_release -a
    No LSB modules are available.
    Distributor ID: Ubuntu
    Description: Ubuntu 16.04.2 LTS
    Release: 16.04
    Codename: xenial

    1. Ben Hillis says:

      What Windows build are you running? (type ‘ver’ in a Windows command prompt)

      1. Richard says:

        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”

      2. Matthew Buckett says:

        I’m seeing this error on Ubuntu 16.04.02 and Windows Version 10.0.15063

  18. Rodrigo Lopez says:

    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.

  19. Vladimir says:

    oh, it’s perfect!
    can somebody tell me – is it possible to automount networkdrive using fstab? What options has drvfs?

  20. Bob Rodriguez says:

    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.

  21. Melvin Backus says:

    It seems like mounting non-Windows file systems, particularly the more common ones like EXT2, etc., should be high on the list. After all, if I’m wanting you use a *nix BASH command line, I probably have lots of *nix disks to access as well. Any timeline on that ability? Is there another way to mount it under Windows directly so it will show up?

    1. Karl says:

      WSL depends on the Windows NT Kernel, so the Kernel needs to be updated to allow native support for ext3 or you could use SAMBA to mount a “SAMBA” share, on a *nix box.

      1. James LaBarre says:

        WSL depends on the Windows NT Kernel, so the Kernel needs to be updated to allow native support for ext3 or you could use SAMBA to mount a “SAMBA” share, on a *nix box.

        I had thought this was the purpose of the IFS / installable filesystem.

  22. Ben says:

    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?

  23. Thanapong says:

    Great work!!

    I am wondering how could I apply this build to my machine?

    1. Ben Hillis says:

      You can access pre-release builds of Windows by joining the Windows Insider program.

  24. Menasheh says:

    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…

  25. Dave M says:

    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.

  26. Joe Dorocak says:

    In the [Bash on Ubuntu on Windows FAQ,](https://msdn.microsoft.com/en-us/commandline/wsl/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

  27. Armingaud says:

    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)

  28. Steve Ballmer says:

    So I can also do

    `sudo umount /mnt/d`

    followed by a

    `sudo mount -t lxfs D: /mnt/d`?

    That would be so awesome!

  29. Eddie says:

    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 0

    Thanks for getting this built in, this is the feature I’ve been looking for since WSL came out!

  30. Ivanov Ivan says:

    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?

  31. Mark H says:

    When is this coming to regular windows updates? and not just an Insider build?

  32. Tibor Djurica Potpara says:

    You guys are doing amazing work with WSL. Keep it up!

  33. 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 /mnt
    c e h i j l o
    ddb@DDB4:~$ ls /mnt/ddb
    ls: cannot access /mnt/ddb: No such file or directory

    mount 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?

  34. lucidbee says:

    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?

  35. sds says:

    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.

  36. krishi says:

    Hey! You guys are doing Great work. . keep it up!

  37. jim desanti says:

    followed your advice but bash in windows 10 does not recognize drvfs or DrvFs. i am trying to mount a usb device
    as F:

    1. Ben Hillis says:

      Could you ensure you are running build 16176 or later (type ver at the command prompt)?

Skip to main content