Updated WSL in Windows 10 version 1903 lets you access Linux files from Windows
The marriage between Linux and Windows is getting stronger. Having embraced Linux with WSL (Windows Subsystem for Linux), Microsoft is now doing what users have been begging for: Windows 10 April 2019 Update makes it possible to access Linux files from Windows.
As well as enabling you to open Linux files from within Explorer, Windows 10 version 1903 gives you the option of editing Linux files from Windows.
See also:
- Microsoft takes Insiders into next year, with the release of the first Windows 10 20H1 build
- Forget Linux -- Here's how to install Windows 10 on Raspberry Pi 3
- Dirty_Sock vulnerability in Canonical's snapd could give root access on Linux machines
- Developer launches new version of Windows 95 that runs under Windows 10, macOS and Linux
While it was previously possible to access Linux files from Windows, it was a trickier affair, and there was always the risk of corruption. But with WSL in Windows 10 version 1903, this changes. As Microsoft explains, the next version of Windows includes updates to WSL: "These include accessing the Linux file system from Windows, and improvements to how you manage and configure your distros in the command line".
Microsoft's Craig Loewen says:
In the past, creating and changing Linux files from Windows resulted in losing files or corrupting data. Making this possible has been a highly requested and long anticipated feature. We're proud to announce you can now easily access all the files in your Linux distros from Windows.
So how does this work? He goes on to explain:
To put it briefly: a 9P protocol file server facilitates file related requests, with Windows acting as the client.
We've modified the WSL init daemon to include a 9P server. This server contains protocols that support Linux metadata, including permissions. There is a Windows service and driver that acts as the client and talks to the 9P server (which is running inside of a WSL instance). Client and server communicate over AF_UNIX sockets, since WSL allows interop between a Windows application and a Linux application using AF_UNIX as described in this post.
Using the feature is very simple:
The best way to get started with this feature is to open your Linux files in File Explorer! To do this, open your favorite distro, make sure your current folder is your Linux home directory, and type in:
explorer.exe .
This will open a File Explorer window, located inside of your Linux distro.
Microsoft says there are a few known issues at the moment, and issues the following warnings:
- As of right now, the distros files will only be accessible from Windows when the distro is running (We aim to add support for non-running distros in a future update)
Since the 9P file server runs inside of each distro, it is only accessible when that distro is running. The team is looking into ways to help resolve this. - Accessing Linux files is treated the same as accessing a network resource, and any rules for accessing network resources will still apply
e.g: When using CMD, cd \\wsl$\Ubuntu\home will not work (as CMD does not support UNC paths as current directories), however copy \\wsl$\Ubuntu\home\somefile.txt C:\dev\ will work - The old rules still apply, you should NOT access your Linux files inside of the AppData folder!
If you try to access your Linux files through your AppData folder, you are bypassing using the 9P server, which means that you will not have access to your Linux files, and you could possibly corrupt your Linux distro.