4

A Win10 host, with WSL 2 running Ubuntu 18.04, has an SSD mounted as drive path (C:) \2 in Disk Management. (This was to quickly "grow" my C: SSD for software that insists on being installed on C: rather than the roomier but slower D: HDD.)

But from the Ubuntu shell, at /mnt/c, I can't cd 2, ls 2, etc. Most commands fail with

cannot read symbolic link '2': Input/output error.

WSL commands can access the rest of /mnt/c and /mnt/d.
Of course Windows can access C: and C:\2 and D:.

How can I get WSL to access /mnt/c/2?

(subst f: c:\2 makes f:, slightly differently in powershell than cmd.exe, but in neither case does WSL show a corresponding /mnt/f.)

2
  • Answers may differ for WSL1 and WSL2, so it would be useful if you could specify which one you are using. Nov 20, 2020 at 0:26
  • Good point. Edited: 2. Nov 20, 2020 at 4:35

2 Answers 2

3

It's a bug in WSL.

You can remount problematic mount point as a different dir in WSL, outside of /mnt/c:

sudo mkdir /mnt/2
sudo mount -t drvfs C:\\2 /mnt/2

(note the escaped backslash)

It can be inconvenient, since relative paths stop working. But at least you can access files.

2
  • The mount works as you describe. But how do "relative paths stop working?" I didn't notice any problems. Oct 18, 2021 at 3:16
  • 1
    @CamilleGoudeseune, imagine that you have a cross-platform script (for example, in Python) C:\2\script.py. This script tries to read file C:\SomeFolder\file using relative path (..\SomeFolder\file). Then such script won't work under WSL, since the path should be ../c/SomeFolder/file. Cross-platform script can deal with different slashes, but it doesn't know anything about different mount points. If you don't use use such scripts or don't share them between Windows and WSL then you are fine. Oct 20, 2021 at 1:52
1

Building on the @basil-peace answer:

SUBSTed drives still confuse WSL, although I can force-mount the drive and get around it during a session, no new mount point needed:

In CMD:

D:\>wsl
<3>WSL (318) ERROR: CreateProcessParseCommon:711: Failed to translate D:\
brbill@brbox:~$ ls /mnt/d
brbill@brbox:/mnt$ sudo mount -t drvfs D:\\ /mnt/d
[sudo] password for brbill:
brbill@brbox:/mnt$ ls /mnt/d
folder1        license.txt     readme.txt

If I leave the session and come back the error is no longer reported. If I delete the SUBSTed D: drive and then relaunch WSL, /mnt/d is shown as empty. If I reSUBST the D: drive again, the error comes back and /mnt/d must be remounted.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .