Multiple HGFS Shares with VMware Tools on CentOS

Recently setup a container with CentOS 6.5 and discovered a few relevant things.

A) In case VMware services cannot be stopped and the kernel module update fails,
there is an undocumented parameter, which makes it ignore start/stop errors
(a snapshot before doing so is suggested, even if it should just work): -skip-stop-start

B) In case additional HGFS file-systems are mounted with /etc/fstab
VMware Tools will attempt to un-mount twice, resulting in an unclean shutdown.

That’s because the kernel module cannot be stopped, while it has shares mounted.

The error on system shutdown should look about like this:

Stopping VMware Tools services in the virtual machine:
   Guest operating system daemon:                          [  OK  ]
   VMware User Agent (vmware-user):                        [  OK  ]
   Blocking file system:                                   [  OK  ]
   Unmounting HGFS shares:                                 [  OK  ]
   Guest filesystem driver:                                [FAILED]
   VM communication interface socket family:               [  OK  ]
   VM communication interface:                             [FAILED]

In order to shutdown Linux properly, the init script has to unmount all of them:

nano /etc/init.d/vmware-tools

The default share /mnt/hgfs is already in there, so it’s easy to extend the existing code;
like this it’s even possible to R/W mount a Google Drive directory on a Windows host:


Additional functions are required (of course existing functions could be extended, as well):

is_drive_mounted() {
  if grep -q " $vmhgfs_drive vmhgfs " /etc/mtab; then
    echo "yes"
    echo "no"

vmware_unmount_drive() {
  if [ &quot;<code>is_drive_mounted</code>&quot; = &quot;yes&quot; ]; then
    vmware_exec_selinux &quot;umount $vmhgfs_drive&quot;

vmware_mount_drive() {
  if [ &quot;<code>is_drive_mounted</code>&quot; = &quot;no&quot; ]; then
    vmware_exec_selinux &quot;mount -t vmhgfs .host:/ $vmhgfs_drive&quot;

“&& vmware_mount_drive” was added to the call:

vmware_exec 'Mounting HGFS shares:' vmware_mount_vmhgfs && vmware_mount_drive

“&& vmware_unmount_drive” was added to the call:

vmware_exec 'Unmounting HGFS shares:' vmware_unmount_vmhgfs && vmware_unmount_drive

For testing purposes, one can run the script directly, no reboot required:

/etc/init.d/vmware-tools restart

C) In order to get the “soundcard” working under X – without any stuttering:

yum -y erase alsa