48

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?

8

4 Answers 4

37

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.

8
  • It was hidden :)
    – Y2K
    May 15, 2016 at 13:03
  • I cannot add it to Quick Access of Windows Explorer as a bookmark to find it easy.
    – john
    May 16, 2016 at 16:07
  • 4
    A user-neutral copy-paste-able version: %USERPROFILE%\AppData\Local\Lxss\rootfs
    – Silveri
    Aug 3, 2016 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, 2017 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, 2019 at 2:12
35

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

\\wsl$

Sorry to be late at the party!

5
  • 8
    This should be updated to be the correct answer
    – getglad
    Jan 15, 2020 at 16:23
  • 1
    Yes this magic address in WindowsFileManager goes to a linux subsystem files, I did not have %LOCALAPPDATA%\Packages\<distribution_specific_name>_<random_string>\LocalState\rootfs file.
    – Whome
    Mar 26, 2021 at 12:55
  • This works like charm. Thank you. Jun 2, 2021 at 4:57
  • This seems not to work any more. (Feb 2023) Feb 18, 2023 at 19:13
  • @DanNissenbaum : worked for me today when I used the full \\wsl$ . ... But ... $ ?? wth is that? You can see how little I know about "modern" windows (-; /mnt/c/Users/<username> would be bad enough, but if you do wslpath -m /home, you'll get back //wsl.localhost/Ubuntu/home ... Now that's a user friendly feature (-;!
    – shellter
    Feb 13 at 2:16
14

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .