WSL: WSL2: can't access linux file system from windows
Please fill out the below information:
-
Your Windows build number: 10.0.18922.1000
-
What you’re doing and what’s happening: Using visual studio code’s bash terminal for WSL, I
cd ~and attempt toexplorer.exe .as per documentation here: https://docs.microsoft.com/en-us/windows/wsl/wsl2-ux-changes#place-your-linux-files-in-your-linux-root-file-system -
What’s wrong / what should be happening instead: Instead of opening
explorer.exeat the corresponding folder in the linux file system, I get the error:
/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)
sudo apt update && sudo apt upgradefollowed bywsl --shutdownand 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: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 fromwsl -l), does that work or does that result in an error?@fracasula
Yeah, use subst:
From cmd.exe:
subst S: \\wsl$\Ubuntu\home\elan\source\reposNow to goto your s: drive
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:
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).
All the best! --Daniel
I’ve updated to 1903 18362.356 as of yesterday and I’m having this issue as well
\\wsl$but when I double click I get:dir \\wsl$\Ubuntudoes not works (“The system cannot find the path specified.”)explorer.exe .inside a /mnt point works fine. Explorer.exe comes up to the expected path locationexplorer.exe .outside a /mnt point does nothing, it does not even bring explorer at allcodedoes 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:
I have another PC where that works as expected on 1903,
explorer.exe .etc…@saltazaur solution worked for me as well!
/etc/wsl.confwas 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
/mntmay 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:
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.exeI got an icon like this in Network locations:
Properties:
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:
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.conffile butroot = /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
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:
This is what I see looking regular:
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:
Afterward:
cd ~ && explorer.exe .\\wsl$\Ubuntu-18.04manually 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
dmesgoutput to see if it tells what’s happening.