Wednesday, April 15, 2009

Getting Vmware Tools VMHGFS working on BackTrack 4 Beta

The stock Vmware Tools compile almost perfectly on BackTrack 4, with the exception of VMHGFS, which provides file sharing between the guest and host machine.


The compile error looks like this :

CC [M]  /tmp/vmware-config0/vmhgfs-only/module.o
CC [M] /tmp/vmware-config0/vmhgfs-only/page.o
/tmp/vmware-config0/vmhgfs-only/page.c: In function ‘HgfsDoWriteBegin’:
/tmp/vmware-config0/vmhgfs-only/page.c:763: warning: ISO C90 forbids mixed declarations and code
/tmp/vmware-config0/vmhgfs-only/page.c: In function ‘HgfsWriteBegin’:
/tmp/vmware-config0/vmhgfs-only/page.c:867: error: implicit declaration of function ‘__grab_cache_page’
/tmp/vmware-config0/vmhgfs-only/page.c:867: warning: assignment makes pointer from integer without a cast
make[2]: *** [/tmp/vmware-config0/vmhgfs-only/page.o] Error 1
make[1]: *** [_module_/tmp/vmware-config0/vmhgfs-only] Error 2
make[1]: Leaving directory `/usr/src/linux-source-2.6.28.1'
make: *** [vmhgfs.ko] Error 2
make: Leaving directory `/tmp/vmware-config0/vmhgfs-only'
Unable to build the vmhgfs module.


A quick Google search brought me to a vmhgfs patch that fixes this compile error.
To fix this:

0) Extract kernel sources and build dependancy scripts!
1) Start the Vmware tools install
2) Copy the vmware tools to /tmp
3) Replace the vmhgfs package with the patched one and install vmware tools


root@bt# tar zxpf VMwareTools-7.9.3-159196.tar.gz
root@bt# cd vmware-tools-distrib/
root@bt# cd lib/modules/source/
root@bt# rm vmhgfs.tar
root@bt# wget www.offensive-security.com/vmhgfs.tar
root@bt# cd /tmp/vmware-tools-distrib/
root@bt# ./vmware-install.pl

Don't forget to enable file sharing in VMWare after installing the tools.

After a restarting the vmware-tools service (or a reboot), you should see your share with a "mount" command.


root@bt# mount |grep hgfs

.host:/ on /mnt/hgfs type vmhgfs (rw,ttl=5)

root@bt# ls -l /mnt/hgfs/

total 1

drwxr-xr-x 1 501 dialout 204 2009-04-12 11:48 bt4

root@bt#