22

It's pretty clear that Windows' 10 "host" filesystem is mounted at /mnt/c/ from "Linux" perspective of view. But is it possible to get an access to "Linux" filesystem from Windows? If so, where it is?

  • What is the output from mount in a bash shell? – DavidPostill Apr 19 '16 at 17:39
  • This doesn't return any clues: rootfs on / type rootfs – There Are Four Lights Apr 19 '16 at 17:45
  • Hmm. Ok. What about cat /etc/fstab? – DavidPostill Apr 19 '16 at 17:58
  • Nope, unfortunately from the "linux" perspective it's looking sitting on hardware: LABEL=cloudimg-rootfs / ext4 defaults 0 0 – There Are Four Lights Apr 19 '16 at 18:46
  • OK. No other ideas. – DavidPostill Apr 19 '16 at 18:49
24

The single root file system was located here until Windows 10 Fall Creators update (released in Oct. 2017):

%LOCALAPPDATA%\Lxss\rootfs

For example, C:\Users\Vigo\AppData\Local\Lxss\rootfs\

Other mount points are located one level up in the lxss directory. For example, your own home directory within Linux will be in %LOCALAPPDATA%\Lxss\home.

Starting from the Fall Creators update, it is possible to install more than one instance of Linux and run them in parallel. The existing instance (a.k.a. legacy) will stay in its directory but new instances created are located under:

%LOCALAPPDATA%\Packages\<distribution_specific_name>_<random_string>\LocalState\rootfs

For example, my Ubuntu 18.04 installation is located under the

CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc
directory.

Warning: Beware not to create, modify or delete files located under the lxss or distribution specific tree from Windows.

Exploring and reading files is the only harmless operation. See this Microsoft blog page for details.

Note that starting from Build 1903, there is an alternative way to access the files of a running distribution that doesn't exhibit the previously mentioned issues.

Just use the path \\wsl$\<distribution_specific_name>\ and you'll be able to create and modify files. The AppData is still not a supported way to access files with build 1903.

  • It was hidden :) – Y2K May 15 '16 at 13:03
  • I cannot add it to Quick Access of Windows Explorer as a bookmark to find it easy. – john May 16 '16 at 16:07
  • 4
    A user-neutral copy-paste-able version: %USERPROFILE%\AppData\Local\Lxss\rootfs – Silveri Aug 3 '16 at 9:04
  • 3
    Warning: According to Microsoft, you should not modify your linux filesystem using Windows applications. blogs.msdn.microsoft.com/commandline/2016/11/17/… – Korey Nov 30 '17 at 20:12
  • 1
    You can simplify the first part of that path a lot by using %LOCALAPPDATA% instead of %USERPROFILE%\AppData\Local – Herohtar Oct 18 at 2:12
8

Nowadays, you can install multiple Linux distributions. Therefore, each distribution will have their own filesystem located in a different folder.

  • If you install some linux distributions from the Windows Store, the filesystems are located under %USERPROFILE%\AppData\Local\Packages\...\LocalState\rootfs
  • If you have installed, moved or duplicated a linux distribution using LxRunOffline or any version of the WSLDistroLauncher, the filesystem can be located in any folder of your computer.

Obtaining the information from the Registry

The location of each filesystem can be obtained from the Windows Registry. The data is located under

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss

You can start a PowerShell window and execute the following command to obtain the locations of the filesystems

PS> (Get-ChildItem HKCU:\Software\Microsoft\Windows\CurrentVersion\Lxss | ForEach-Object {Get-ItemProperty $_.PSPath}) | select DistributionName, @{n="Path";e={$_.BasePath + "\rootfs"}}

You will get a table with information like the following

DistributionName Path
---------------- ----
Ubuntu           C:\Users\Jaime\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs
Ubuntu-18.04     C:\Users\Jaime\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc\LocalState\rootfs
mydistro         C:\wsl\mydistro\rootfs

Using lxRunOffline

LxRunOffline is a tool for managing linux distributions installed on WSL. You can use LxRunOffline to get the directory used by an installed distribution

# lxrunoffline get-dir -n <name of the distro>

C:\> lxrunoffline get-dir -n backup
c:\wsl\installed\backup

C:\> lxrunoffline get-dir -n Ubuntu
C:\Users\Jaime\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState
1

The later version of the linux subsystem installs the file system under packages so the full path would be something like:

C:\Users\myUserName\AppData\Local\Packages\UbuntuLinux.someUID\LocalState\rootfs\root

or:

C:\Users\myUserName\AppData\Local\Packages\UbuntuLinux.someUID\LocalState\rootfs\home\myLinuxUserName

... depending of course on the mount point. Doing a directory search for .bashrc would reveal these paths...

Alternatively use readlink . within the linux shell to post the current linux path as a 'DOS' path to windows clipboard. Paste somewhere sensible to read the actual physical path.

1

Looks like Microsoft has changed/hidden it some more, currently it's at:

%USERPROFILE%\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_?????????????\LocalState\rootfs

As this could further change in the future, just do PGP's suggestion of doing a file search of .profile or .bashrc files.

1

For WSL2 you can access to home directory from windows explorer like this :

\\wsl$

Sorry to be late at the party!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.