bash 在适用于 Linux 的 Windows 子系统中挂载 Windows 共享
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/45244306/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Mounting a windows share in Windows Subsystem for Linux
提问by David Hoffman
I'd like to mount a windows server from within WSL(Windows Subsystem for Linux). On Ubuntu (with unity interface) I can just type
我想从WSL(适用于 Linux 的 Windows 子系统)中安装 Windows 服务器。在 Ubuntu(带有统一界面)上,我可以输入
gvfs-mount smb://domain\;user@server/share
and everything mounts just fine.
一切都很好。
If I try this in WSL then I get the following error:
如果我在 WSL 中尝试此操作,则会收到以下错误:
Error mounting location: volume doesn't implement mount
回答by LaVache
Assuming the host Windows OS can access a file share at "\\servername\sharename", try this command in bash. You will need to be root:
假设主机 Windows 操作系统可以访问位于“\\servername\sharename”的文件共享,请在 bash 中尝试此命令。您将需要成为 root:
mkdir /mnt/mountedshare
mount -t drvfs '\servername\sharename' /mnt/mountedshare
The single quotes are important!
单引号很重要!
Worked for me with a SharePoint Online UNC path. The permissions are screwy though. I can navigate through the folders and see the filenames, but I can't read files. So need to figure out the permissions thing. Let me know if you get anywhere with that.
使用 SharePoint Online UNC 路径对我来说有效。虽然权限很糟糕。我可以浏览文件夹并查看文件名,但我无法读取文件。所以需要弄清楚权限的事情。如果你有任何进展,请告诉我。
回答by gabuzo
Actually if your windows share is already mapped to a drive in the Windows host, it can be even simpler. Let's suppose you already mounted the share on Z:
. In that case the following will work:
实际上,如果您的 Windows 共享已经映射到 Windows 主机中的驱动器,则它可以更简单。假设您已经在Z:
. 在这种情况下,以下将起作用:
sudo mkdir /mnt/z
sudo mount -t drvfs 'Z:' /mnt/z
回答by K. Taylor
In WSL (I'm using Ubuntu) it looks like that when you install the cifs-utils it doesn't create the module file that cifs needs when mounting. Type: "modinfo cifs" and you will see. Anyway, the work-around is to map a drive letter in Windows and then mount to that, as mentioned above. Thanks gabuzo.
在 WSL(我使用的是 Ubuntu)中,看起来当您安装 cifs-utils 时,它不会创建 cifs 在挂载时需要的模块文件。输入:“modinfo cifs”,你会看到。无论如何,解决方法是在 Windows 中映射一个驱动器号,然后安装到该驱动器,如上所述。谢谢加布佐。
Maybe its that cifs-utils is looking in the wrong place for the module file. Or MS intentionally disabled it. They don't want WSL to be too useful.
也许是因为 cifs-utils 在寻找模块文件的错误位置。或者 MS 故意禁用它。他们不希望 WSL 太有用。
回答by David C. Rankin
While you have an a mount created to the windows host through /mnt/c
already created for you in WSL, if you want to mount a share from another machine, then you will need to create the mount point, e.g.
虽然你已经/mnt/c
在 WSL 中为你创建了一个挂载到 windows 主机,但如果你想从另一台机器挂载共享,那么你需要创建挂载点,例如
sudo mkdir -p /mnt/somename
Then you will need to mount the remotely shared smb://
filesystem at that mount point using mount.cifs
, e.g.
然后您将需要smb://
使用mount.cifs
例如在该挂载点挂载远程共享文件系统
sudo mount.cifs //server/sharename /mnt/somename
Optionally, you will want to include options following /mnt/somename
such as
或者,您需要包含以下选项,/mnt/somename
例如
-o username=yourname,uid=YOURUID,noperm,password=yourpassforremoteshare
If it is an older WinXP share you are attempting to mount, then you will need to enable NTLMv1
authentication by including the sec=ntlm
or sec=ntlm1
. See mount.cifs
for further use of the sec=
option.
如果您尝试挂载的是较旧的 WinXP 共享,则需要NTLMv1
通过包含sec=ntlm
或来启用身份验证sec=ntlm1
。有关mount.cifs
该sec=
选项的进一步使用,请参阅。