Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WSL2: can't access linux file system from windows #4260

Closed
martaver opened this issue Jul 2, 2019 · 74 comments
Closed

WSL2: can't access linux file system from windows #4260

martaver opened this issue Jul 2, 2019 · 74 comments
Assignees

Comments

@martaver
Copy link

martaver commented Jul 2, 2019

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.
@martaver
Copy link
Author

martaver commented Jul 2, 2019

Note: running explorer.exe . from a mounted windows drive, e.g. /mnt/c works fine.

This is a blocker, preventing me from opening a project located on the linux file system in VSCode.

@onomatopellan
Copy link

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.

@martaver
Copy link
Author

martaver commented Jul 2, 2019

I am mounting /mnt/... drive directly under / in my wsl.conf...

I ruled that out, though, because explorer.exe . works fine from within the mounted drive at /c/...

Would you mind giving me some more information on how I can debug this using dmesg?

VSCode remoting to WSL works quite nicely, btw.

@craigloewen-msft
Copy link
Member

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

@martaver
Copy link
Author

martaver commented Jul 3, 2019

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?

@craigloewen-msft
Copy link
Member

This seems to be an error with the Plan 9 server. @SvenGroot is the resident expert for this area!

@erikhakansson
Copy link

I suddenly have this issue too after upgrading to 18932. It worked previously but with issues (#4262)

@erikhakansson
Copy link

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.

@martaver
Copy link
Author

martaver commented Jul 4, 2019

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

@onomatopellan
Copy link

onomatopellan commented Jul 4, 2019

@martaver I think your issue it's very similar to #4027
Keep reading and try the registry workaraound that Sven suggested in that thread.

@stuffaboutpete
Copy link

I'm struggling with the same and the linked issue wasn't my problem - the registry values were already correct. apt upgrade also made no difference although running wsl --shutdown is helpful because it saves logging out or rebooting.

@peidaqi
Copy link

peidaqi commented Jul 25, 2019

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.

@enterit
Copy link

enterit commented Aug 14, 2019

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?

I am seeing exactly the same issue on my Windows 10 1903 18941.1001.
Updating Ubuntu or restarting WSL did not help.
@martaver, have you by any chance figured out how to fix this?

@shm-tar
Copy link

shm-tar commented Sep 12, 2019

Exact same issue on Windows 10 1903, but when running explorer.exe inside WSL, it opens Windows explorer on This PC page.

@David-Defoort
Copy link

David-Defoort commented Sep 14, 2019

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

@abreingan
Copy link

Hi I seem to have exactly the same problem as David-Defoort, but with the Debian distro.
1903 18362.356 also.

@aleblanco
Copy link

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

This solution worked perfectly for me. Thanks!

@abreingan
Copy link

I am now on 10.0.18362.388 and retried the disable wsl and that was successful (not sure if this is permanent or not).
I started cmd with admin authority and entered "wsl -t Debian"
After that File Explorer and enter \wsl$\Debian\ works.

@ferlauf
Copy link

ferlauf commented Oct 13, 2019

When it happens, I usually do "Get-Service LxssManager | Restart-Service" from the PS (Run as administrator).
I'm currently on 10.0.18999.1 and it seems WSL is a bit more stable now.

@benhillis
Copy link
Member

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.

@fracasula
Copy link

fracasula commented Nov 19, 2019

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?

@raphaeldisanto
Copy link

fracasula, come at it from the other angle.

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

@SvenGroot
Copy link
Member

@fracasula Does simply mapping \\wsl$\Ubuntu-18.04 not work for you? You should be able to do that and then access the folder as Z:\root\Code.

Is there any reason you have to map the specific folder to a drive?

@whaaaley
Copy link

whaaaley commented Dec 6, 2019

I was still having this problem up until today. Previously, my lowercase file path worked, \\wsl$\debian, but reading #4260 (comment) I tried uppercase to see if it fixed anything, \\wsl$\Debian, and it worked, and it also made the lowercase paths start working again. So check your casing. Weirdly, shortcuts with the uppercase version do not work, only the lowercase version. This is a very annoying inconsistency. Every time I start windows I have to type in the wsl path in explorer to open any projects.

@fracasula
Copy link

fracasula, come at it from the other angle.

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

I did not know that was possible, thanks 👍

@whaaaley
Copy link

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.

@DanielGoldfarb
Copy link

@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

@jpoles1
Copy link

jpoles1 commented Sep 14, 2020

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:

@manierim
Copy link

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

@gottfired
Copy link

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.

@saltazaur
Copy link

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

@nikoscvas
Copy link

@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.

@whaaaley
Copy link

It worked for me as well. I added this to my Debian install and I haven't had any issues since. Nice catch. Someone should probably make a new thread to report the missing conf files and reference this issue.

@CollapsedMetal
Copy link

@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!

@Ryuhouji
Copy link

fracasula, come at it from the other angle.
All of your windows files are accessible from within the linux distro under /mnt/, so just store the files there. That way, both windows and linux has access to them.

I did not know that was possible, thanks 👍

If you're using wsl2 this will cause a MASSIVE performance penalty. Always edit from inside your distro. If you use your distro with Windows paths, this is going to be very slow. This is NOT a solution, it's not even a good workaround.

@Ryuhouji
Copy link

I have the same problem. After feature upgrade to 20h2, linux filesystem is inaccessible to windows. VS Code remote works perfectly fine inside the distro. I need to be able to browse my project files for editing things other than code.
I've tried:
Rebooting PC
Rebooting wsl (shutdown/starting it)
Trying to set a new title with -t
explorer.exe . inside a linux path does nothing. The terminal acts as if it is still doing something, nothing happens.
Trying \\wsl\. . . causes explorer to hang and do nothing.

@eusoubrasileiro
Copy link

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

@speller
Copy link

speller commented Jan 18, 2022

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.

@NyaMisty
Copy link

NyaMisty commented Feb 5, 2022

Same as @speller , I'm on the fast ring of insider, with WSL kernel version 5.10.81.1

@feland207
Copy link

feland207 commented Mar 25, 2022

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 !

@beerth
Copy link

beerth commented Jun 9, 2022

its very important to do it from cmd.exe and NOT using Powershell for mapping the network drive!!!

@Tewuzij
Copy link

Tewuzij commented Nov 17, 2022

@fracasula Does simply mapping \wsl$\Ubuntu-18.04 not work for you? You should be able to do that and then access the folder as Z:\root\Code.

Is there any reason you have to map the specific folder to a drive?

I think there is, for example to access network files in a specific location without traversing back and forth between directories. See WSL2 network drive authentication issue

@Kimi450
Copy link

Kimi450 commented Dec 1, 2022

I was struggling with this issue for a while but today I stopped using the "default" install of Ubuntu that comes with WSL and installed a separate version (Ubuntu 20.04) and I havent encountered this issue on 20.04. Maybe thats the workaround? Install something separately from the store and that wont give you issues?

EDIT: Nevermind... its back...

@mbomb007
Copy link

This issue should be reopened...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests