September 10th, 2020

Access Linux filesystems in Windows and WSL 2

Pierre Boulay
Senior Software Engineer

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.

Category
Command Line

Author

Pierre Boulay
Senior Software Engineer

42 comments

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

  • Neo Yang

    “At this time, it’s not possible to attach a single partition.” is confusing me.

    But the sample you demonstrates does mount a single partition to wsl.

    So may I know what’s real limitation of that?

    • Pierre BoulayMicrosoft employee Author

      What is meant by that statement is that it’s not possible to have one partition attached to WSL 2 while the disk is in use in Windows.

      Concretely, this means that the entire disk must be attached to WSL 2, regardless of which partitions are mounted in there.

  • Radu Tomuleasa

    When is this coming to stable release of Windows 10? I need this, but don’t want to go to Dev Preview on my main dev machine.

  • Nathan Doyle

    How disappointing, this Insider build was pulled from service, as they found a bug (see note in the announcement.) Any other way to get this feature without having access to the build, by chance? I was really looking forward to accessing my Linux drives.

      • Natetronn

        Thanks for that.

        Okay, I've switched to the dev branch and am downloading 20231 as I write this.

        This is the only features I need and although I chose not to wait, as I have many ext4 drives, I'd really like to be back on stable again. That said, can I leave Insiders at some point and be back to stable, say, if stable catches up and reaches 20231 will I be moved back again? ...

        Read more
      • Craig LoewenMicrosoft employee

        Jumping in to help with this question:

        Yes you can leave Insiders at any point and be back to stable! The only stipulation here is that you can't go backwards to an older Windows release. So for your use case it'd probably make sense to start in the Dev Channel (which gives new builds each week) to get access to wsl --mount, and then in the future you can change your settings to the beta channel...

        Read more
      • Natetronn

        That's great, thanks Craig!

        I'm testing the feature out as we speak...

        Okay, I ran into an issues and will detail why and how I fixed it:

        The code above is missing any reference to the --partition flag, although I now see it's in the image. I'm leaving this here for others, should they run into the same issue and or until the code above has been clarified.

        I get an error and am told:

        <code>

        Which I narrow down...

        Read more
  • Janosch Hoffmann

    When will this be available for windows 10 stable? Thanks.

  • wang fengtu

    Is it supported WSL1 ?

    • Pierre BoulayMicrosoft employee Author

      No. wsl –mount is only supported by WSL 2.

  • Rohat Bozyil

    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 Author

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

  • tsuki Shimo

    Can WSL2 mount other filesystem like JFS with this function?

    • Pierre BoulayMicrosoft employee Author

      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.

  • Pavel Minaev

    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 Author

      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

        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…

  • K Kaland

    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 Author

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

  • Marcel Lunes Palau

    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 Author

      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

        In PowerShell “Invalid command line option: –mount”