0

I have been using Windows Subsystem for Linux (WSL) and when I create a file in the home directory of WSL, where does it actually exist in file explorer, also, since my C: drive is in /mnt/c/ does that mean Linux is on a seperate partition or mount?

When I run list directory in root for WSL:

bin  boot  dev  etc  home  init  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var

Where does the var or bin or home folder exist in normal file explorer?

3
  • %LOCALAPPDATA%\Lxss\rootfs or %LOCALAPPDATA%\Packages\{package}\LocalState\rootfs. If you want direct access, you can Map a network drive and enter \\wsl$ as the path – Narzard Apr 16 at 19:31
  • \\wsl$\<dsitroname> is automatically created by WSL. You should not map it manually to the %localappdata% location. See my answer for more information. – NotTheDr01ds Apr 16 at 20:50
  • 1
    Please speicfy WSL1 or 2 .. they are very different beasts – Señor CMasMas Apr 17 at 2:02
0

Ack- No! Regarding the comment and your corresponding self-answer, please never access files directly through %LOCALAPPDATA%\Packages\TheDebianProject.DebianGNULinux_76v4gfsz19hv4\LocalState\rootfs. While it is true that, for WSL1, the files are stored there by WSL, accessing them directly can cause WSL corruption. Also note that for WSL2, the files are inside a virtual HDD (ext4.vhdx), so it prevents you from using this technique at all.

To quote Microsoft's DevBlog on the topic:

There is one hard-and-fast rule when it comes to WSL on Windows:

DO NOT, under ANY circumstances, access, create, and/or modify Linux files inside of your %LOCALAPPDATA% folder using Windows apps, tools, scripts, consoles, etc. Opening files using some Windows tools may read-lock the opened files and/or folders, preventing updates to file contents and/or metadata, > essentially resulting in corrupted files/folders.

Creating/changing Linux files in your Appdata folder from Windows will likely result in data corruption and/or damage your Linux environment requiring you to uninstall & reinstall your distro!

The correct answer is also found in that page. WSL provides a \\wsl$\<distroname> pseudo-network-share that will allow you to safely access the WSL filesystem from Windows. Note that the WSL instance does need to be running in order to show up in \\wsl$\.

2
  • But I'm not looking to write anything, I was just wondering where the files are stored in the system relative to the C: drive. – VJZGamingHD Apr 16 at 22:12
  • Ok, good to know. The comment under the main question mentioned mapping a drive letter for "access", so that got me worried. Regardless, other readers can come along and find this question/answer, so I like to be sure to make sure we warn them properly. – NotTheDr01ds Apr 16 at 22:44
0

As per the comment by @Narzard, the correct answer in my case was to go to this folder:

%LOCALAPPDATA%\Packages\TheDebianProject.DebianGNULinux_76v4gfsz19hv4\LocalState\rootfs

Since I have a debian distro, your package folder name may differ from mine but the general idea of it is the same. And indeed when I go to that path, the root folders of linux all appear.

As @NotTheDr01ds pointed out, you shouldn't perform any operations on this folder as it could corrupt your WSL. This is just the "actual folder" if for some reason you wanted to know.

1
  • You can perform "operations" on this folder.. just not WRITE or MODIFY operations. ;) The reason it can corrupt the files is because WSL1 is FAKING Linux attributes using external metadata for the files and need to stay in sync. – Señor CMasMas Apr 17 at 2:04

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.