使用open-vm-tools启用共享文件夹。

我在Windows 7上的VMware Player中运行Ubuntu 14.10。由于VMware的软件无法编译所需的内核模块以进行文件共享,因此我安装了open-vm-tools而不是VMware Tools。我无法使用sudo mount -t vmhgfs .host:/$(vmware-hgfsclient) /mnt/hgfssudo vmware-hgfsmounter .host:/$(vmware-hgfsclient) /mnt/hgfs来挂载我的共享文件夹。两者都返回Error: cannot canonicalize mount point: No such file or directory。我不知道这是什么意思,也不知道如何解决它。

截至2016年5月,当前的open-vm-tools软件包存在一些问题;您需要从源代码自行编译它:https://github.com/vmware/open-vm-tools/issues/62 - user260281
6个回答

我的解决方法是使用安装了open-vm-tools的vmhgfs-fuse来解决这个问题。
要么使用vmhgfs-fuse .host:/$(vmware-hgfsclient) ~/some_mountpoint在本地挂载,要么使用sudo mount -t fuse.vmhgfs-fuse .host:/ /mnt/hgfs -o allow_other全局挂载。然后,为了使全局挂载持久化,在你的/etc/fstab中添加以下行: .host:/ /mnt/hgfs fuse.vmhgfs-fuse allow_other 0 0

我对这个解决方案唯一要补充的是,你可能考虑其他文件系统选项,例如"allow_other,uid=1000,gid=1000,auto_unmount,defaults"。我通过将VMware指向下载的ISO镜像来安装了客户操作系统。我没有明确让VMware为我安装工具,并且最初更新了Ubuntu安装。在那时,open-vm-tools已经被安装了,我不需要手动安装该软件包,而且vmware-config-tools.pl似乎不是已安装软件包的一部分。 - MFB
确认这也适用于16.04版本。 - Kenneth
1同样适用于17.04版本,并且绝对是比黑客攻击open-vm-tools更好的解决方案。 - fmo
1Ubuntu 14.04安装了open-vm-tools,但没有vmhgfs-fuse - Mithril
使用Kubuntu 16.04.3,我安装了open-vm-tools-desktop软件包,创建了目录/mnt/hgf,重新启动系统,将.host:/ /mnt/hgfs fuse.vmhgfs-fuse allow_other 0 0添加到/etc/fstab中,然后执行mount -a命令。 - Cyrus
已验证通过Ubuntu 17.10 "artful"。 - Daniel Alder
在Q4OS上对我有用。 - Felipe
在Ubuntu 20.04上,我只需将以下行添加到/etc/fstab文件中,就能够完成这个操作: .host:/ /mnt/hgfs fuse.vmhgfs-fuse auto,allow_other 0 0 - Keith Bennett
在本地挂载的方式中,你创建目录的方式有些奇怪 - 我可以以超级用户身份列出它,但我无法进入它(sudo cd)。 - Line

由于其他答案对我没有用,经过长时间的搜索,我终于在这个链接上找到了解决方法:Ubuntu虚拟机中/mnt/hgfs文件丢失?,PieCot给出了解决方案。
$ git clone https://github.com/rasa/vmware-tools-patches.git
$ cd vmware-tools-patches
$ ./patched-open-vm-tools.sh

这个答案是有效的,尽管我不确定它是否支持使用open-vm-tools共享文件夹。它似乎是直接从VMware下载工具并进行修补。 - Shawn Hoover
这是我唯一让它工作的方法(尝试从源代码构建open-vm-tools,但在Debian Jessie上没有成功)。一个小提示是确保你的用户在sudoers列表中,否则你必须从脚本中删除sudo调用,并手动运行patched-open-vm-tools.sh中的命令,就像我做的那样。 - Geradlus_RU
在这里工作是为了Ubuntu Gnome 16.04 LTS。 - FourtyTwo
对我来说没成功。 :-( - Felipe


在虚拟机上,请确保:

您已启用文件夹共享功能

您至少有一个在主机和客户机之间共享的文件夹

在Ubuntu客户机上:

检查/mnt/hgfs以查看是否可以访问该文件夹,如果无法访问,请运行以下工具命令:

sudo vmware-config-tools.pl

更新 fstab 文件的方法如下:
gksu gedit /etc/fstab

使用文本编辑器在文件末尾输入以下内容:
.host:/{shared-folder} /{path-to-mount-on} vmhgfs defaults,ttl=5,uid=1000,gid=1000   0 0

最后一步是重新启动您的虚拟机(您可能需要重新启动它,或者会出现无法挂载的错误,只需跳过此步骤并重新启动几次)!
谢谢,希望这对您有所帮助!

我在回答你的问题时参考了这个链接:http://askubuntu.com/questions/29284/how-do-i-mount-shared-folders-in-ubuntu-using-vmware-tools - Trevor Clarke
2我没有使用VMware Tools,所以在我的安装中不存在"vmware-config-tools.pl"。我不使用它是因为之前给我带来了麻烦。 - Melab
我正在使用 open-vm-tools。我无法使用 VMware 的软件成功执行指令。你还有其他的东西吗? - Melab
这在Ubuntu的较新版本(从16.04以后的版本)可能不起作用。请参阅:https://github.com/vmware/open-vm-tools/issues/248 - prusswan
你需要在最新版本中将vmhgfs替换为vmhgfs,请参考https://stackoverflow.com/questions/38737254/vmhgfs-fuse-at-boot-with-vmware-windows-8-1-host-and-ubuntu-16-04-guest - Étienne

这在Debian上对我有用,我认为在Ubuntu上也是一样的。
安装open-vm-tools-dkms软件包。
apt-get install open-vm-tools-dkms

创建一个挂载点。
mkdir /mnt/hgfs

在挂载点上挂载所有的文件系统,授予所有用户权限。
/usr/bin/vmware-vmblock-fuse /mnt/hgfs -o allow_other

这只是意味着你的挂载点不存在。
$ ll /mnt
total 12
drwxr-xr-x  3 root root 4096 Feb 22 20:37 ./
drwxr-xr-x 22 root root 4096 Feb 22 20:16 ../
drwxr-xr-x  2 root root 4096 Jan  3 04:56 cdrom/

$ sudo mount -t vmhgfs .host:/Share /mnt/hgfs/Share
Error: cannot canonicalize mount point: No such file or directory

$ sudo mkdir -p /mnt/hgfs/Share

$ ll /mnt/hgfs
total 12
drwxr-xr-x 3 root root 4096 Feb 22 20:52 ./
drwxr-xr-x 4 root root 4096 Feb 22 20:52 ../
drwxr-xr-x 2 root root 4096 Feb 22 20:52 Share/

$ sudo mount -t vmhgfs .host:/Share /mnt/hgfs/Share