Access Windows Subsystem for Linux files from Windows

Related: Mount external drives in WSL


Since Windows 10 version 1903, it is possible to safely access WSL filesystem from Windows via a 9P server. This currently means the WSL distro of interest must be running for the Linux files to be accessible from Windows.

The WSL files are available from Windows on path like:

\\wsl$\Ubuntu\home\username

for an Ubuntu home directory, for example.

To keep things simpler and more consistent to use, we still recommend keeping files that need to be accessed from WSL and Windows under the usual Windows file system, making softlinks in WSL as useful.

For example, if I keep code in Windows under c:/users/username/code then in WSL I do one-time:

ln -s /mnt/c/users/username/code ~

Raw WSL files

Windows Subsystem for Linux places files for each WSL image uniquely named like:

WSLWindows
~%LOCALAPPDATA%\Packages\CanonicalGroupLimited.UbuntuonWindows*\LocalState\rootfs\home
/ %LOCALAPPDATA%\Packages\CanonicalGroupLimited.UbuntuonWindows*\LocalState\rootfs

Do not create/edit files from Windows in the “APPDATA” directories as it will corrupt the WSL filesystem.

Notes

Microsoft says don’t edit/write WSL files from Windows.