7

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?

VJZ
  • 306

2 Answers2

8

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$\.

NotTheDr01ds
  • 28,025
2

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.

VJZ
  • 306