3

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 '20 at 0:26
  • Good point. Edited: 2. Nov 20 '20 at 4:35
1

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 '21 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 '21 at 1:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.