19

I am using the VMware Player with a Windows 8.1 host and an Ubuntu 16.04 guest and I have a shared folder shared_folder that I want to mount to a specific location at boot: /shared_folder. I can manually do that using the command

vmhgfs-fuse .host:/shared_folder /shared_folder

Now I would like to do that automatically during boot. Since I am a beginner with Ubuntu, maybe someone can point me to the solution of my problem. Thanks

takahashi
  • 2,081
  • 3
  • 14
  • 24

2 Answers2

44

So after half a day of googling, try-and-error, 5mins after I post this question I find a working solution. I added the following line to /etc/fstab:

.host:/shared_folder /shared_folder fuse.vmhgfs-fuse allow_other,uid=1000,gid=1000,auto_unmount,defaults 0 0

Which sets the options (sources: vmhgfs-fuse --help and man fstab):

  • allow_other "allow access to other users"
  • uid and gid the user and group ID to set for files
  • auto_unmount "auto unmount on process termination"
  • defaults "use default options: rw, suid, dev, exec, auto, nouser, and async."
Luc
  • 5,339
  • 2
  • 48
  • 48
takahashi
  • 2,081
  • 3
  • 14
  • 24
  • 1
    In my case, the allow_other has solved a perms problem. uid and gid were 0 (root) until I used that parameter (obviously I was using uid=1000 and gid=1000). – kikeenrique Feb 12 '17 at 21:53
  • 1
    That to your half a day of googling and try-and-error, you saved me going through the same pain. Your solution was exactly what I was looking for. :-) – Frerich Raabe Sep 14 '17 at 06:48
  • Thank you! Very helpful. I did end up wasting an hour before reaching this page :( – leodotcloud Jan 30 '18 at 05:53
  • WARNING! Adding removable resources to `fstab` may lead to boot problems – voromax Jun 23 '19 at 08:48
  • 2
    added entries to `fstab` can (and should) be tested with `sudo mount -a` and `sudo umount -a` before rebooting the system – wolfrevo Apr 15 '21 at 15:37
2

I am running CentOS 7 but this handy ArchLinux doc saved me. I had tons of permission issues with Apache in a shared folder, and after hours of digging, I was able to enable the mount as a systemd service. After reboot all is well.

Create a service for the directory you want to mount:

$ sudo touch /etc/systemd/system/<shared folders root directory>-<shared_folder>.service

Using a text editor, set the service's contents to the following, replacing each <...>.

[Unit]
Description=Load VMware shared folders
Requires=vmware-vmblock-fuse.service
After=vmware-vmblock-fuse.service
ConditionPathExists=.host:/<shared_folder>
ConditionVirtualization=vmware

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/vmhgfs-fuse -o allow_other -o auto_unmount .host:/<shared_folder> <shared folders root directory>

[Install]
WantedBy=multi-user.target

NOTE: On openSUSE, the vmware-vmblock-fuse service is instead called vmblock-fuse.service.

Make sure <shared folders root directory> exists as the systemd service depends on it.

$ mkdir -p <shared folders root directory>

Finally, enable the service.

$ sudo systemctl enable <shared folders root directory>-<shared_folder>.service
Peyton
  • 3
  • 6
Zacho
  • 831
  • 11
  • 19