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?
4 Answers
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_79rhkp1fndgscdirectory.
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.
-
-
I cannot add it to Quick Access of Windows Explorer as a bookmark to find it easy.– johnMay 16, 2016 at 16:07
-
4A user-neutral copy-paste-able version:
%USERPROFILE%\AppData\Local\Lxss\rootfs
– SilveriAug 3, 2016 at 9:04 -
3Warning: According to Microsoft, you should not modify your linux filesystem using Windows applications. blogs.msdn.microsoft.com/commandline/2016/11/17/…– KoreyNov 30, 2017 at 20:12
-
1You can simplify the first part of that path a lot by using
%LOCALAPPDATA%
instead of%USERPROFILE%\AppData\Local
– HerohtarOct 18, 2019 at 2:12
For WSL2 you can access to home directory from windows explorer like this :
\\wsl$
Sorry to be late at the party!
-
8
-
1Yes 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.– WhomeMar 26, 2021 at 12:55 -
-
-
@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 dowslpath -m /home
, you'll get back//wsl.localhost/Ubuntu/home
... Now that's a user friendly feature (-;!– shellterFeb 13 at 2:16
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
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.
mount
in abash
shell?rootfs on / type rootfs
cat /etc/fstab
?LABEL=cloudimg-rootfs / ext4 defaults 0 0