Fix vagrant VMHGFS file corruption bug in VMWare 6.0.2 and 6.0.3

There is a problem in VMWare 6.0.2 and 6.0.3 where Sublime Text (and many other editors) partially save or corrupts files to the vmhgfs mount aka /vagrant directory on the VM. Most posts like this one on GitHub say you need to set this option in Sublime Text and the problem goes away:

    "atomic_save": false

This did not work for me on VMWare 6.0.3. Bah! Let's fix this once and for all. Thanks to Steve Goddard in on the VMWare forums I was able to fix the corruption bug by downgrading VMWare tools on my vagrant VM to 6.0.1. Below are the instructions in order on how to accomplish this annoying but necessary feat. You can also downgrade VMWare to 6.0.1 but I was tired of having to do this.

Download ISO for your Guest OS type

In my case, my guest os was Ubuntu 12.0.4 LTS from chefs vagrant cloud so the file I would need is called

From a terminal in your parent os in some temporary directory:

$ wget
$ tar xf
$ unzip

The file we care about is the linux.iso file that gets extracted from the zip file in the payload folder.

Set the VMWare tools into manual mode by editing the VMX file

This step is very important. If you skip this step, VMWare tools will automatically upgrade. You don't want that.

You will want to change the line tools.upgrade.policy to read tools.upgrade.policy = "manual" by option+rightclicking the VM in the library list and clicking "Open Config File in Editor"

OSX TEXT EDIT USERS VERY IMPORTANT While editing the .vmx file in TextEdit, disable Smart Quotes option from TextEdit > Preferences > New Document. Smart quotes, if enabled, will not work in the .vmx file and the virtual machine will fail to boot.

See how to edit your VMX file here:;=displayKC&externalId;=1014782

Mount the linux.iso file

Next we want to mount the linux.iso file we extracted in the instructions above onto the cd drive. Make sure the VM is halted

Screen Shot 2014-05-08 at 3.26.29 PM.png

Install VMware tools

vagrant up
vagrant ssh
sudo mkdir /mnt/cdrom
sudo mount /dev/cdrom /mnt/cdrom

At this point you should have a a tar file in /mnt/cdrom. Mine was called /mnt/cdrom/VMwareTools-9.6.0-1294478.tar.gz. Extract this file.

$ cd /tmp
$ tar zxpf /mnt/cdrom/VMwareTools-9.6.0-1294478.tar.gz
$ cd vmware-tools-distrib/
$ ./

Just accept all the defaults from the command

Most people at this point will just need to run vagrant halt then vagrant up and you're done. In my case, the vmhgfs driver did not compile correctly. I received this error:

/tmp/modconfig-2ot93R/vmhgfs-only/inode.c: In function ‘HgfsPermission’:
/tmp/modconfig-2ot93R/vmhgfs-only/inode.c:1893:29: error: ‘struct dentry’ has no member named ‘d_count’
make[2]: *** [/tmp/modconfig-2ot93R/vmhgfs-only/inode.o] Error 1
make[1]: *** [_module_/tmp/modconfig-2ot93R/vmhgfs-only] Error 2
make[1]: Leaving directory `/usr/src/linux-headers-3.11.0-15-generic'
make: *** [vmhgfs.ko] Error 2
make: Leaving directory `/tmp/modconfig-2ot93R/vmhgfs-only'

If that happens to you, root into the VM from the console and follow the instructions below.

Patching the inode.c file so it compiles on newer kernels

$ cd root/
$ wget
$ cd /usr/lib/vmware-tools/modules/source/
$ cp vmhgfs.tar /root  # copy just in case
$ tar xvf vmhgfs.tar
$ cd vmhgfs-only/
$ patch inode.c < /root/vmhgfs-d_count-kernel-3.11-tools-9.6.0.patch
$ cd ..
$ rm vmhgfs.tar
$ tar cvf vmhgfs.tar vmhgfs-only/*

Accept all the defaults from the command. Now you can vagrant halt and vagrant up and will never see file corruption again.

Happy Coding!