Reputation: 6117
I'm using eclipse on windows to connect to files on a wsl, and I have run into what is apparently an eclipse bug which file names such as \wsl$\folder1\pom.xml get mangled. https://bugs.eclipse.org/bugs/show_bug.cgi?id=577938
A comment in the bug report suggests a possible workaround
A workaround is to map the UNC path to a drive letter, but this shouldn't be necessary
How would I do that?
Upvotes: 4
Views: 6595
Reputation: 4711
As answered here, the command-line tool
Associates a path with a drive letter.
SUBST [drive1: [drive2:]path]
SUBST drive1: /D
drive1: Specifies a virtual drive to which you want to assign a path.
[drive2:]path Specifies a physical drive and path you want to assign to
a virtual drive.
/D Deletes a substituted (virtual) drive.
Type SUBST with no parameters to display a list of current virtual drives.
Source: A very similar question/answer
In my specific case;
GET-CimInstance -query "SELECT * from Win32_DiskDrive"
wmic diskdrive list brief
.
> wmic diskdrive list brief
Caption DeviceID Model Partitions Size
SK hynix PC801 HFS001TEJ9X101N \\.\PHYSICALDRIVE0 SK hynix PC801 HFS001TEJ9X101N 3 1234567890120
Samsung SSD 840 PRO Seri SCSI Disk Device \\.\PHYSICALDRIVE1 Samsung SSD 840 PRO Seri SCSI Disk Device 6 256128643216
.
> wsl --mount \\.\PHYSICALDRIVE1 --bare
The operation completed successfully.
.
~~~@~~~~~:/$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 388.4M 1 disk
sdb 8:16 0 4G 0 disk [SWAP]
sdc 8:32 0 1T 0 disk /snap
/mnt/wslg/distro
/
sdd 8:48 0 238.5G 0 disk
├─sdd1 8:49 0 499M 0 part
├─sdd2 8:50 0 300M 0 part
├─sdd3 8:51 0 128M 0 part
├─sdd4 8:52 0 190.1G 0 part
├─sdd5 8:53 0 31G 0 part
├─sdd6 8:54 0 15.4G 0 part
└─sdd7 8:55 0 1024M 0 part
~~~@~~~~~:/$ sudo blkid -s TYPE /dev/sdd4
/dev/sdd4: TYPE="ntfs"
~~~@~~~~~:/$ sudo blkid -s TYPE /dev/sdd5
/dev/sdd5: TYPE="ext4"
~~~@~~~~~:/$ ls /mnt/
c d wsl wslg
~~~@~~~~~:/$ sudo mkdir /mnt/g
~~~@~~~~~:/$ sudo mount -t ext4 /dev/sdd5 /mnt/g
> subst g: \\wsl.localhost\Ubuntu\mnt\g\
Upvotes: 1
Reputation: 113
I did it this way (drive j: was available)
net use j: \\wsl$\Ubuntu
Note that this is persistent, and if not deleted can cause wsl2 to restart by itself. After doing this I was able to access files on the Ubuntu distro from windows emacs.
to delete it:
net use /del j:
Upvotes: 9