WSL: WSL2: can't access linux file system from windows

Please fill out the below information:

/c/WINDOWS/explorer.exe: Invalid argument
  • Strace of the failing command, if applicable: No other errors logged. If I’m given instructions I’m happy to run diagnostic commands and report back.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 14
  • Comments: 74 (5 by maintainers)

Most upvoted comments

sudo apt update && sudo apt upgrade followed by wsl --shutdown and then starting wsl again resolved the issue for me.

But I don’t know if it’s permanently or not.

Ah, so from File Explorer, browsing to \\wsl$\Ubuntu-18.04\ gives me error:

\\wsl$\Ubuntu-18.04 is not accessible. You might not have permission to use this network resource. Contact the administrator of this server to find out if you have access permissions.

Attempt to access invalid address.

Can’t quite tell if this is a permissions issue, or ‘invalid address’… any ideas?

fracasula, come at it from the other angle.

All of your windows files are accessible from within the linux distro under /mnt/<drive letter>, so just store the files there. That way, both windows and linux has access to them.

Another troubleshooting idea: If you go into File Explorer and type in: \\wsl$\<yourDistroName\ into the address bar (replacing <yourDistroName> with the name of your distro which you can see from wsl -l), does that work or does that result in an error?

@fracasula

Any ideas?

Yeah, use subst:

From cmd.exe: subst S: \\wsl$\Ubuntu\home\elan\source\repos

Now to goto your s: drive

image

This is still an issue in March 2020. It happens 50% of the time. Sometimes it randomly starts working after 50 tries.

I gave up trying to get this to work consistently, I bit the bullet and moved all my projects out of WSL and rewrote my file watching scripts to work with Window’s janky file change events 😃 ~ I’m about to buy another SSD just so I can install Debian… It’s starting to not be worth the headache… Honestly…

This thread shouldn’t have been closed before anyone could confirm that the updates actually solved this issue.

This issue (or a related one) should really be reopened @benhillis. It’s been nearly a year and this is still not working properly.

I’ve had to resort to creating a .bat file which makes it easier to create a “network” drive to my ubuntu files:

subst L: /d
subst L: \\wsl$\<DistroNameHere>\
explorer.exe L:

Same here, tried all the solutions, nothing works. \wsl$\Ubuntu is unreachable. explorer.exe only works in windows mount points. WSL2 is basically unusable this way.

@ElanHasson Elan, Thanks! Worked like a charm. (Although, to get it to work, I had to first delete that bad s: drive i had created yesterday).

C:\Users\dgold>subst s: /d
C:\Users\dgold>wsl --list
Windows Subsystem for Linux Distributions:
Ubuntu-20.04 (Default)
C:\Users\dgold>subst s: \\wsl$\Ubuntu-20.04\home\

All the best! --Daniel

I’ve updated to 1903 18362.356 as of yesterday and I’m having this issue as well

  • Explorer shows Ubuntu under \\wsl$ but when I double click I get: image
  • inside a cmd, dir \\wsl$\Ubuntu does not works (“The system cannot find the path specified.”)
  • (in bash) explorer.exe . inside a /mnt point works fine. Explorer.exe comes up to the expected path location
  • (in bash) explorer.exe . outside a /mnt point does nothing, it does not even bring explorer at all
  • (in bash) code does not work outside /mnt points, which is what bothers me the most. It used to work and I became dependent of it…

I tried to:

  • apt-get update/upgrade no effect
  • uninstall/reinstall Ubuntu and Ubuntu-18.04, no effect
  • disable WSL, reboot, re-enable, no effect
  • verified the registry as #4027 said, no effect
  • as suggested in this issue: image

I have another PC where that works as expected on 1903, explorer.exe . etc…

@saltazaur solution worked for me as well!

/etc/wsl.conf was not there! Iv’e copied the one mentioned on https://docs.microsoft.com/en-us/windows/wsl/wsl-config#configure-per-distro-launch-settings-with-wslconf. Rebooted and done!

I had tried solutions listed in this topic, but in my case it occured that I didn’t have wsl.config in my Ubuntu, now after adding the file with default settings, I can access Ubuntu from Windows and all problems are solved (code . …) Info on wsl.conf: https://docs.microsoft.com/en-us/windows/wsl/wsl-config#configure-per-distro-launch-settings-with-wslconf

@erikhakansson’s steps didn’t change the problem for me.

I know it’s not much of a help. But my HD crashed a few weeks ago which forced me to reinstall Windows. Now everything is working fine.

Same here.

\wsl$ is very unstable and drops from time to time. This seems to have something to do with number of writes - I often have the problem after working with a project from VSCode (and save the files several times).

It can be decieving that sometimes \wsl$\ can still be accessed, but this is from cache. If you try to actually open the files using notepad/vscode you will still have a filesystem error.

Restarting WSL with wsl --shutdown seems to fix it temporarily.

@thisismydesign This is a known issue that was recently fixed. When you install a WSL2 distro from an elevated process, the VHD is owned by the Administrators group rather than your account, so depending on the permissions of the parent folder it’s possible that only elevated users can start the VM.

We have recently made a fix that makes sure the VHD is owned by your account even if created when elevated.

FWIW. I was having issues with file watching when storing files Windows side, so depending on your needs, accessing files via /mnt may not be viable.

It would be great if it’d be possible to map a network drive that points to a folder in the Linux subsystem:

Annotation 2019-11-19 083927

Unfortunately that doesn’t work and I don’t see other options for editing those files with editors like JetBrains’ (I’m talking about running the editor from the host, not the VM of course).

Any ideas?

There have been a handful of fixes around the \wsl$\ paths so things should be much more robust now. Please reopen a new issue if you continue to see issues after build 19002.

For me the solution was to run: subst S: \\wsl$\Ubuntu-20.04\ from cmd.exe

I got an icon like this in Network locations: image

Properties: image

Despite the Disconnected Network Drive, when I File Explorer this Drive, I can see the Linux file system from Windows. Happy days:)

PD: I have WSL2 (Ubuntu-20.04) and Windows 10

Thanks, @ElanHasson !

I just hit this issue. I can access Docker Desktop WSL folders but can’t access my Ubuntu installation folders:

image image

All file exploring tools I tried from Windows hang infinitely connecting to the folder (Explorer, PowerShell, Total Commander). The distro is accessible from the terminal and works well.

Shutting down WSL doesn’t help.

System reboot helped.

@saltazaur 's solution worked for me. I had the wsl.conf file but root = /windir/ wasn’t there. After I added it, and restarted for good measure, the problem went away.

I too have this problem. I can use an un-elevated powershell to access the mount-point (\wsl$\Ubuntu-20.04), but explorer.exe doesn’t recognize it, and neither does the powershell in elevated mode. Any hint as to how to fix this, or a timeframe for an available hotfix will be greatly appreciated.

what worked for me

subst s: \\wsl$\Ubuntu-20.04\home\
; run in a admin cmd or powershell
; this makes \\wsl$ work again from explorer

Based on above here @jpoles1

Is there any update?

Still experiencing this. Can map a network drive to \wsl$\Ubuntu and access its contents.

But explorer or any other window executable (launched from Windows or from a WSL prompt) can access \wsl$\Ubuntu.

Win 1903 build 18362.1139 Ubuntu App 2004.2020.812.0

Ubuntu 20.04.1 LTS (Focal Fossa) Linux 4.19.128-microsoft-standard x86_64

@ElanHasson Regarding https://github.com/microsoft/WSL/issues/4260#issuecomment-622107929

This is what I get when I try it:

C:\Users\dgold>subst S: \\wsl$\Ubuntu\home
Path not found - \\wsl$\Ubuntu\home

This is what I see looking regular:

C:\Users\dgold>dir AppData\Local\Packages\CanonicalGroupLimited.Ubuntu20.04onWindows_79rhkp1fndgsc\LocalState\
 Volume in drive C has no label.
 Volume Serial Number is DA84-E891

 Directory of 
C:\Users\dgold\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu20.04onWindows_79rhkp1fndgsc\LocalState

08/12/2020  12:07 AM    <DIR>          .
08/12/2020  12:07 AM    <DIR>          ..
08/13/2020  09:56 PM     6,296,698,880 ext4.vhdx
               1 File(s)  6,296,698,880 bytes
               2 Dir(s)  358,663,135,232 bytes free

With WSL2 the entire file system is one file (virtual disk).
Any ideas? (Your post above seemed promising but didn’t work for me; Am I doing something wrong?)

Thanks in advance. --Daniel

For me the issue turned out to be that via Chocolatey WSL Ubuntu is installed to require admin rights (choco install wsl2 wsl-ubuntu-1804). This is also reflected in that the command line is only accessible when running as an admin. I tried running explorer as admin but that didn’t help.

It was solved by:

  • Navigate to (C:\ProgramData\chocolatey\lib\wsl-ubuntu-1804\tools\unzipped) and change the folder permissions to full control for “users”

Afterward:

  • I can open WSL terminal without admin privileges
  • I can cd ~ && explorer.exe .
  • I can navigate to \\wsl$\Ubuntu-18.04 manually from explorer

@gottfired This thread is closed. Better follow #5307. We are waiting for the team to answer there.

Thanks a lot @ElanHasson , now I can work with PhpStorm on my WSL2 distro without using FTP connection!

Things I’d try: -Try using the real bash terminal or the new Windows terminal, not the one inside Vscode. -Look at /etc/wsl.conf content. (that /c/WINDOWS/ is fishy) -See dmesg output to see if it tells what’s happening.