Where is the Linux Subsystem's filesystem located in Windows 10?

28,405

Solution 1

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.

Solution 2

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

\\wsl$

Sorry to be late at the party!

Solution 3

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

Solution 4

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.

Share:
28,405

Related videos on Youtube

There Are Four Lights
Author by

There Are Four Lights

Updated on September 18, 2022

Comments

  • There Are Four Lights
    There Are Four Lights almost 2 years

    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?

  • Y2K
    Y2K about 8 years
    It was hidden :)
  • john
    john about 8 years
    I cannot add it to Quick Access of Windows Explorer as a bookmark to find it easy.
  • Silveri
    Silveri almost 8 years
    A user-neutral copy-paste-able version: %USERPROFILE%\AppData\Local\Lxss\rootfs
  • Korey
    Korey over 6 years
    Warning: According to Microsoft, you should not modify your linux filesystem using Windows applications. blogs.msdn.microsoft.com/commandline/2016/11/17/…
  • jlliagre
    jlliagre over 6 years
    @Korey Thanks for reminding that point, answer updated.
  • tvdo
    tvdo almost 6 years
    Even reading is not necessarily harmless. As the MS blog post mentions, some programs will lock (or even modify) files on 'open', i.e. it's not truly read-only. The only safe-ish operation I can think of is copying the file elsewhere, and even that depends on what you use to copy it (I believe open for reading will lock against deletion?). Better to not touch it at all - use WSL to copy to a DrvFs mountpoint. I feel like your warning should be more prominent and at the start of the answer - there is almost never a good reason to do anything beyond deleting the entire directory.
  • Herohtar
    Herohtar over 4 years
    You can simplify the first part of that path a lot by using %LOCALAPPDATA% instead of %USERPROFILE%\AppData\Local
  • jlliagre
    jlliagre over 4 years
    @Herohtar Thanks, updated.
  • getglad
    getglad over 4 years
    This should be updated to be the correct answer
  • Whome
    Whome over 3 years
    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.
  • Tarun Upadhyay
    Tarun Upadhyay about 3 years
    This works like charm. Thank you.