Access Windows Subsystem for Linux files from Windows

It is possible to safely access the WSL filesystem from Windows. For WSL2, the WSL distro need not be running first to access the files within. WSL2 will automatically start the requested filesystem Linux image and the 9P file server in less than a second upon attempting to access the WSL2 image filesystem.

The WSL distro files are available from Windows under:

\\wsl$\Ubuntu\

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

For example, code in Windows under c:/users/username/code is accessed from WSL by one-time:

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

Notes

Raw WSL files

DO NOT EDIT THESE RAW FILES!

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

%LOCALAPPDATA%\Packages\CanonicalGroupLimited.UbuntuonWindows*\LocalState\rootfs\ext4.vhdx

Mount external drives in WSL