我使用subst R: .来更快地访问文件夹。
是否可以将R:“驱动器”安装到WSL?当我尝试运行sudo mkdir /mnt/r然后运行sudo mount -t ntfs R: /mnt/r时,会遇到以下错误:
ntfs-3g: Failed to access volume 'R:': No such file or directory
ntfs-3g 2017.3.23AR.3 integrated FUSE 28 - Third Generation NTFS Driver
Configuration type 7, XATTRS are on, POSIX ACLS are on
Copyright (C) 2005-2007 Yura Pakhuchiy
Copyright (C) 2006-2009 Szabolcs Szakacsits
Copyright (C) 2007-2017 Jean-Pierre Andre
Copyright (C) 2009 Erik Larsson
Usage: ntfs-3g [-o option[,...]]
Options: ro (read-only mount), windows_names, uid=, gid=,
umask=, fmask=, dmask=, streams_interface=.
Please see the details in the manual (type: man ntfs-3g).
Example: ntfs-3g /dev/sda1 /mnt/windows
News, support and information: http://tuxera.com 提前感谢!
在StackOverflow上问了同样的问题,但意识到那不是正确的地方.
发布于 2021-01-16 06:49:05
虽然WSL无法自动或甚至直接访问subst驱动器,但有一些方法可以映射它们。这里有几条路线可供选择,具体取决于您的工作流程。
要记住的主要事情是:
sudo mount --bind . /mnt/r大致相当于subst R: .。如果您不需要在Windows下访问相同的驱动器号,那么这可能就是您所需要的全部。您甚至可以在bash中创建一个与Windows非常接近的subst函数。bind在这里可能有点过分了。您很可能只想要一个符号链接,比如ln -s /mnt/c/Users/username ~/r。只要您有对目标位置的权限,这就不需要根用户。subst在Windows中创建的映射,可以通过调用PowerShell (如:powershell.exe -c subst )来检索Linux中的substituted路径grep和sed:powershell.exe -c "subst" | grep "^R" | sed "s/^R:\\\\: => //"将其过滤到R:映射(如果有多个驱动器/目录( substituted ),只查找R:驱动器,然后删除目录路径之前的所有内容)。tr -d "\r"的内容。wslpath命令将Windows路径转换为等同于Linux/WSL的路径。将所有这些放在一起,您就可以得到可以将R:转换为/mnt/r (如果更方便的话是~/r )的脚本:
rpath=$(powershell.exe -c "subst" | grep "^R" | sed "s/^R:\\\\: => //" | tr -d "\r")
sudo mount --bind $(wslpath "${rpath}") /mnt/r/或者与ln等效。
当然,您需要将它分配给一个函数,这样就更容易重复了。
https://unix.stackexchange.com/questions/629400
复制相似问题