在Windows中,我可以从\\wsl$下访问所有WSL容器的文件系统。
从WSL容器内部,我可以作为/mnt/c访问windows C:\驱动器。
但是如何从WSL容器内部访问另一个容器的驱动器呢?
我正在尝试从WSL容器中访问\\wsl$\othercontainer\some\file。
wslpath通常可以将Windows文件路径转换为可从WSL访问的路径:
WSL2@~» wslpath 'C:\Windows\System32\drivers\etc\hosts'
/mnt/c/Windows/System32/drivers/etc/hosts但它不适用于:
WSL2@~» wslpath '\\wsl$\othercontainer\some\file'
wslpath: \\wsl$\othercontainer\some\file
WSL2@~» echo $?
1当然还有:
WSL2@~» ls -l '\\wsl$\othercontainer\some\file'
ls: cannot access '\\wsl$\othercontainer\some\file': No such file or directory发布于 2021-06-11 03:56:03
This answer给出了答案:
sudo mkdir /mnt/othercontainer
sudo mount -t drvfs '\\wsl$\othercontainer' /mnt/othercontainer
ls -l /mnt/othercontainer/some/file注释:看起来不支持符号链接。当遇到一个错误时,我们会得到如下错误:
$ ls -l /mnt/othercontainer/bin
ls: cannot read symbolic link '/mnt/othercontainer/bin': Function not implemented
lrwxrwxrwx 1 root root 7 Apr 23 2020 /mnt/othercontainer/binhttps://stackoverflow.com/questions/67900684
复制相似问题