Open natehsu opened 4 years ago
This bug exists as long as I remember, I can reproduce it almost in every distro I have installed.
@silverqx Thanks for sharing
Please see https://kb.vmware.com/s/article/74650 , I hope that helps.
Great, if I create this systemd service, it works like expected, mount points are still there after restart, if I check / uncheck some mount point, this change is immediately reflected in /mnt/hgfs folder, would be nice to have similar service in open-vm-tools by default, for System V and Initd systems too.
I'm going to try original vmware tools and look how they handle this problem.
Ok, here is what I discovered, in original vmware tools shared folders work by default after a restart, this functionality is provided by /etc/init.d/vmware-tools
service, exactly this code in main
function is responsible for automount hgfs during system start:
if [ "`is_vmhgfs_needed`" = 'yes' -a "`is_ESX_running`" = 'no' ]; then
vmware_exec 'Guest filesystem driver:' vmware_start_vmhgfs
exitcode=$(($exitcode + $?))
vmware_exec 'Mounting HGFS shares:' vmware_mount_vmhgfs
# Ignore the exitcode. The mount may fail if HGFS is disabled
# in the host, in which case requiring a rerun of the Tools
# configurator is useless.
fi
Would be nice to have something like this in open-vm-tools.
I searched little open VM tools and try to find code, which is currently responsible for mounting hgfs, when I enable shared folders in VM settings, without success for now ☹. @oliverkurth do you have some idea where can I find this code?
I found another issue #201 which is related to this, maybe @lousybrit can help
We do have a plan to add this to open-vm-tools, but it hasn't been prioritized. So far, the kb article is the best solution.
I created openrc service /etc/init.d/vmware-hgfs
for gentoo:
#!/sbin/openrc-run
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
description="vmware shared directory mounter"
vmhgfsfuse_command="/usr/bin/vmhgfs-fuse"
vmhgfsfuse_pidfile="/run/vmhgfs-fuse.pid"
depend() {
need fuse
after vmware-tools
}
start_pre() {
checkpath -d -m 0755 -o root:root /mnt
}
start() {
ebegin "Starting vmhgfs-fuse"
start-stop-daemon --background --make-pidfile --pidfile "${vmhgfsfuse_pidfile}" --start "${vmhgfsfuse_command}" -- /mnt/hgfs -orw,default_permissions,allow_other,dev,suid -f
eend $? "Failed to start vmghfs-fuse"
}
stop() {
ebegin "Stoping vmhgfs-fuse"
start-stop-daemon --stop --pidfile "${vmhgfsfuse_pidfile}"
eend $? "Failed to stop vmhgfs-fuse"
}
You can enable it by sudo rc-update add vmware-hgfs default
so how do i resolve this if i want to mount several host folders to several different guest folders? i can see that the [Mount] property in the service script seems to mount everything to the hgfs folder What=vmhgfs-fuse
and Where=/mnt/hgfs
i cant find any documentation on this syntax.
Hi there
You can have several mounts to direct shares instead or as well as the default shared folder mount. I do this sort of thing quite often.
The syntax for the default mount is "/usr/bin/vmhgfs-fuse .host:/ /mnt/hgfs -o subtype=vmhgfs-fuse,allow_other" will give you the mount Guest OS mount path "/mnt/hgfs" points to server name and share root ".host:/" and all shares are listed under the guest path "/mnt/hgfs"
If you have VMware Tools Shared Folders called: Foo Bar Fred which all point to different locations on the host you can mount them directly in the guest. For example: sudo mkdir /mnt/Foo sudo mkdir /mnt/Bar sudo mkdir /mnt/Fred /usr/bin/vmhgfs-fuse .host:/Foo /mnt/Foo -o subtype=vmhgfs-fuse,allow_other /usr/bin/vmhgfs-fuse .host:/Bar /mnt/Bar-o subtype=vmhgfs-fuse,allow_other /usr/bin/vmhgfs-fuse .host:/Fred /mnt/Fred -o subtype=vmhgfs-fuse,allow_other
Now using df or other file IO operations you should see the same host files under /mnt/Foo and /mnt/hgfs/Foo Similarly for the other 2 examples.
Hope this helps explain the syntax. Thanks Steve
The problem that folders are not mounted after restart still persists though.
An option that works for me is to add entries to the ./etc/fstab Using the above example: .host:/Foo /mnt/Foo fuse.vmhgfs-fuse defaults,allow_other 0 0 .host:/Bar /mnt/Bar fuse.vmhgfs-fuse defaults,allow_other 0 0 .host:/Fred /mnt/Fred fuse.vmhgfs-fuse defaults,allow_other 0 0
or the general share case .host:/ /mnt/hgfs fuse.vmhgfs-fuse defaults,allow_other 0 0
manually editing the ./etc/fstab is a pretty ugly solution especially as im trying to setup mounts using ansible and manually editing files does not work well will automated solutions.
i managed to eventually find the .host:\
syntax but like in most cases, vmwares own documentation leaves a lot to the imagination.
Right now im trying to get the mounting to work using systemd
which is a more automated-friendly way. I still find this overly complex just to mount a folder.
Yes it is not the long-term solution but as Oliver indicated earlier in this thread an improved solution is in the plans. Other priorities have prevented this work from being scheduled recently.
We can also do an improved job with documenting some behaviors for sure. If you feel there are pieces like this that require more details and has been overlooked, please do report them on these forums. Thaniks
I created a script which auto-mounts the HGFS shared folders after reboot under, id 1000, the non-root user. Here's the gist. :)
Make sure the shared folder option is enabled but no folders are shared. Reboot after running the commands or script for it to take effect.
#!/bin/bash
# This file enables the persistent mounting of HGFS VMware shares.
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
cat <<EOT > /etc/systemd/system/mnt-hgfs.mount
[Unit]
Description=VMware mount for hgfs
DefaultDependencies=no
Before=umount.target
ConditionVirtualization=vmware
After=sys-fs-fuse-connections.mount
[Mount]
What=vmhgfs-fuse
Where=/mnt/hgfs
Type=fuse
Options=default_permissions,allow_other,uid=1000,gid=1000
[Install]
WantedBy=multi-user.target
EOT
echo "fuse" > /etc/modules-load.d/open-vm-tools.conf
modprobe -v fuse
systemctl enable mnt-hgfs.mount
systemctl start mnt-hgfs.mount
Please see https://kb.vmware.com/s/article/74650 , I hope that helps.
I just ran into this issue on a Fedora 37 vm. Based on what I'm reading, it's up to the distro to include the mount file needed for hgfs? I never had to add it in Ubuntu based OSes before.
Dear developers, this bug is really annoying. Shared folders is the basic functionality, one of the most popular. With the installation of the operating system (in my case Debian 12) and enabling shared folders, everything works. But after the reboot, the shared folders just disappear, without any warnings or logs except the following:
$ sudo journalctl --system | grep hgfs
Jul 01 13:26:54 dev systemd[1]: Unmounting mnt-hgfs.mount - /mnt/hgfs...
Jul 01 13:26:54 dev systemd[1]: mnt-hgfs.mount: Deactivated successfully.
Jul 01 13:26:54 dev systemd[1]: Unmounted mnt-hgfs.mount - /mnt/hgfs.
You have to spend time reading the forums, and understand why this happens. Then create manually configurations according to the article in KB.
This bug should be prioritized and corrected as soon as possible. Four years to fix it is a mockery of end users. Really, guys.
They don't provide these services for every Linux distribution, they could but rather the idea here is that every distribution should handle it itself, as you can see, so it's up to you or it's up to the distribution how this will be solved.
They of course could create a systemd service that should solve this problem, or init.d script for distros that don't have systemd, but they won't solve this problem this way.
Also, there is nobody who would solve this issue, maybe in the far future this will be solved.
Dear developers, this bug is really annoying. Shared folders is the basic functionality, one of the most popular. With the installation of the operating system (in my case Debian 12) and enabling shared folders, everything works. But after the reboot, the shared folders just disappear, without any warnings or logs except the following:
For automatic mount on boot, you can add an entry to fstab. I have the following: vmhgfs-fuse /mnt/hgfs fuse defaults,allow_other 0 0
Or for a details :
Here is the text from the other thread about fstab and shared folder mounts: There are 2 ways to specify the Shared Folders mounts persistently in /etc/fstab Below there are both samples /etc/fstab line to mount a FUSE vmhgfs export.
Method 1: Specifying the file system
Replace with vmhgfs-fuse. Replace with the local file system on which the exported directory is mounted, which default replacement is to use /mnt/hgfs Replace with fuse. e.g. vmhgfs-fuse /mnt/hgfs fuse defaults,allow_other 0 0
Method 2: Specifying the remote server and share
:</remote/export> </local/directory> Replace with the hostname .host the shared folders name of the host server exporting the hosts file system. Replace </remote/export> with the path to the exported directory which defaults to/or you can use the /share-name-you-created. Replace </local/directory> with the local file system on which the exported directory is mounted, which defaults to /mnt/hgfs. Replace with fuse.vmhgfs-fuse. Eg. .host:/ /mnt/hgfs fuse.vmhgfs-fuse defaults,allow_other 0 0
Hi,
I already add shared folders to vm(ubuntu 18.04.4), and it works. But the shared folder disappear after I reboot vm.
My settings: Win10 1909 vmware workstation 15 pro 15.5.6 settings - options - Shared Folders - Always enabled
I would appreciate your help.