Access Linux filesystems in Windows and WSL 2

Pierre Boulay

Starting with Windows Insiders preview build 20211, WSL 2 will be offering a new feature: wsl --mount. This new parameter allows a physical disk to be attached and mounted inside WSL 2, which enables you to access filesystems that aren’t natively supported by Windows (such as ext4).

So, if you’re dual booting with Windows & Linux using different disks, you can now access your Linux files from Windows!

Getting started

To mount a disk, open a PowerShell window with administrator privileges and run:

wsl --mount <DiskPath>

To list the available disks in Windows, run:

wmic diskdrive list brief

To unmount and detach the disk from WSL 2, run

wsl --unmount <Diskpath>

The disks paths are available under the ‘DeviceID’ columns. Usually under the \\.\\\.\PHYSICALDRIVE* format. Below is an example of mounting a specific partition of a given hard disk into WSL and browsing its files.

terminal with wsl text

Accessing these files with File Explorer

Once mounted, it’s also possible to access these disks through the Windows explorer by navigating to \wsl$ and then to the mount folder.

Accessing an EXT4 partition with file explorer

Limitations

By default, wsl --mount attempts to mount the disk as ext4. To specify a filesystem, or for more advanced scenarios, check out Mount a disk in WSL 2.

Also please note that this feature comes with the limitation that only physical disks can be attached to WSL 2. At this time, it’s not possible to attach a single partition. More details on the limitations here.

Give us your feedback!

If you run into any issues, or have feedback for our team please file an issue on our Github , and if you have general questions about WSL you can find all of our team members that are on Twitter on this twitter list.

42 comments

Discussion is closed. Login to edit/delete existing comments.

  • JinShil 0

    But, can you edit the files?

    • Emmanuel Adebiyi 0

      Of course

    • Pierre BoulayMicrosoft employee 0

      Yes, that’s the whole point 🙂

      • Amedea Ramsey 0

        Please I need someone to teach me programming and coding willingly.

  • Ascii Wolf 0

    Cool! Now, if only SFTP support was added to Explorer as well, I would be happy. 🙂

    • Pierre BoulayMicrosoft employee 0

      You can mount an SFTP share in WSL, and then access it through the \WSL$ path in the Windows Explorer.

      • Ryan Avery 0

        Pierre, does this actually work? I just tried mounting an SSHFS system in WSL2. It mounts fine and files are available in Ubuntu, but when I use Explorer and browse to the mounted folder, I get the error message:

        “\wsl$\Ubuntu\mnt\test_mount is not accessible. You might not have permission to use this network resource. Contact the administrator of this server to find out if you have access permissions.

        Attempt to access invalid address.”

        If it helps, I am using the following to mount:

        sshfs -o idmap=user server:/files /mnt/test_mount

        And server is aliased in my .ssh/config to the hostname, port, and username for that server

        Note that when unmounted, windows explorer can open the folder, but of course the contents are empty.

        Thanks!

        • Pierre BoulayMicrosoft employee 0

          This is probably caused by a uid mismatch.

          To make the mountpoint accessible in the explorer, the uid needs to match the default wsl user for your distro.

          To figure out your uid, run id -u inside WSL.
          Once you have that, change your mount command line to something like:

          sshfs -o idmap=user server:/files /mnt/test_mount uid=[uid here (without the brackets)]
          

          If that doesn’t work, I recommend creating an issue

  • Jason Jarvis 0

    How’s the performance?

    • Pierre BoulayMicrosoft employee 0

      Should be close to native from inside WSL 2. From the Windows Explorer there is some penalty

  • Stefan Maric 0

    If the whole device is exposed to the Linux kernel, does that mean I could mount an encrypted LUKS volume inside WSL and navigate the fs using explorer.exe?

    That would be awesome. It would mean one doesn’t need VeraCrypt for disk encryption interop between windows and linux.

    • Pierre BoulayMicrosoft employee 0

      You can as long as the Linux kernel supports dm-crypt.

      Unfortunately the kernel that we currently ship doesn’t, but you can build you own (just make sure that CONFIG_DM_CRYPT is ‘y’), and then install in %windir%\system32\lxss\tools\kernel

      • Simon Kostede 0

        will a future kernel support dm-crypt natively? I imagine quite a few people run Linux from encrypted and LVM-d filesystems.

      • Stefan Maric 0

        Interesting. Any plans on have it enabled in the default distribution in the future?

        I guess that before WSL having support for disks mounts it made no sense to enable it, but now I would include any disk mapper supported by the linux kernel.

        But exiting news nonetheless!

  • Ben Beige 0

    Will this work with LVM partitions as well?

    • Pierre BoulayMicrosoft employee 0

      Unfortunately not, because lvm relies on a daemon that isn’t running in WSL 2.

      It might be possible to get it to work if you manually start lvmetad, but this scenario isn’t supported at this time.

  • Marcel Lunes Palau 0

    Exactly what linux file systems will be accessed?
    I use xfs and I would like it to be able to access that file system from windows.

    • Pierre BoulayMicrosoft employee 0

      All filesystems supported by the kernel you’re running can be mounted from WSL (in your case, xfs is supported by the kernel we ship).

      For more complex use cases, you can run wsl --mount <Device> --bare, and then manually mount the device from inside WSL.

      • Marcel Lunes Palau 0

        In PowerShell “Invalid command line option: –mount”

        • Pierre BoulayMicrosoft employee 0

          There are two dashes (-) on this argument.
          If that doesn’t help, please create an issue

  • K Kaland 0

    Does the limitation of only working with disks mean it’s not possible to mount Linux partitions if they are on the same physical disk (boot disk) as Windows, e.g. on a laptop?

    • Pierre BoulayMicrosoft employee 0

      Yes, this scenario isn’t supported at this time.

  • Pavel Minaev 0

    Does this make it possible to use a physical disk for a WSL root filesystem? It would be truly amazing if one could have a full-fledged dual-boot setup that could also double as WSL.

    • Pierre BoulayMicrosoft employee 0

      That’s an interesting idea.

      It’s not possible to boot directly on a mounted disk, but you can chroot into it after mounting it.

      • Ihor Dutchak 0

        but you can chroot into it after mounting it

        Would be cool to have a way to chroot to a specific device quickly, like wsl –chroot \.\PHYSICALDRIVE… without need to mount a drive -> mount all the /dev/… /proc/… etc. -> chroot…

  • tsuki Shimo 0

    Can WSL2 mount other filesystem like JFS with this function?

    • Pierre BoulayMicrosoft employee 0

      The kernel that we officially ship doesn’t support JFS at this time, but if you build your own, you should be able to mount a JFS volume.

  • Rohat Bozyil 0

    Hello Pierre

    Is this functionality only limited to storage devices, or would it enable me to make use of peripheral devices which connect through the same USB receptacles?
    An example would be if I could use a wired joystick-controller that makes use of the USB type-A interface, the same way I use USB type-A for my flash drive.

    • Pierre BoulayMicrosoft employee 0

      This feature is only limited to storage devices. Unfortunately it can’t be used to pass-through a USB device to WSL 2.

Feedback usabilla icon