FreeBSD 10 with VMWare and Xorg

The official VMware Tools for FreeBSD 10 needs to be patched in order for it to build properly. For VMware Workstation 8, 9 ,10, and ESXi 5.x you will need to download the following patches:

UPDATE: This guide will not working on newer version of FreeBSD. Try this script instead.

fetch -o /tmp/vmware-tools-distrib.diff http://www.unibia.com/unibianet/sites/default/files/vmware-tools-distrib.diff 
fetch -o /tmp/vmblock-only.diff http://www.unibia.com/unibianet/sites/default/files/vmblock-only.diff
fetch -o /tmp/vmmemctl-only.diff http://www.unibia.com/unibianet/sites/default/files/vmmemctl-only55.diff

All other products including VMWare Fusion for MacOS X will need these patches:

fetch -o /tmp/vmware-tools-distrib.diff http://www.unibia.com/unibianet/sites/default/files/vmware-tools-distrib.diff 
fetch -o /tmp/vmblock-only.diff http://www.unibia.com/unibianet/sites/default/files/vmblock-only.diff
fetch -o /tmp/vmmemctl-only.diff http://www.unibia.com/unibianet/sites/default/files/vmmemctl-only.diff

Patches provided by http://ogris.de/vmware/freebsd10.html.

You will also need the following additional patch to allow the VMWare tools configure script to load the vmblock module in FreeBSD 10:

fetch -o /tmp/vmware-config-tools.diff http://www.unibia.com/unibianet/sites/default/files/vmware-config-tools.diff 

Download the FreeBSD Sources

You will need the FreeBSD kernel sources in order to build the VMware kernel modules. If you do not have the sources installed execute the following:

rm -Rf /usr/src/sys
svnlite checkout svn://svn.freebsd.org/base/release/10.0.0 /usr/src

If you have some sources installed or your /usr/src directory is not empty the svn checkout will not download a complete source tree. If you run into any problems during the checkout select the "postpone" option and then run the following when it's completed:

svnlite revert -R /usr/src

Ensure your sources match the running system by running "freebsd-update fetch" and then "freebsd-update install". Reboot to apply any changes.

freebsd-update fetch
freebsd-update install
reboot

Update or Download the Ports Tree

If you already have the ports tree update it with:

portsnap fetch update

If you do not have the ports tree installed, you will need to use:

portsnap fetch extract

Install Dependencies

This step is the key to making the keyboard, mouse, and video drivers work. You need to build them from ports. Using the packaged versions from "pkg install" will not work.

If you already have the packaged versions installed, remove them first.

pkg delete xf86-video-vmware xf86-input-vmmouse xf86-input-keyboard

Build and install from the ports.

cd /usr/ports/x11-drivers/xf86-video-vmware/
make install clean
cd ../xf86-input-vmmouse/
make install clean
cd ../xf86-input-keyboard/
make install clean

Finally install the compatibility package

pkg install compat6x-amd64

Configure Xorg

Backup any existing "/etc/X11/xorg.conf" configuration and make a new one:

mv  /etc/X11/xorg.conf /etc/X11/xorg.conf.origional
edit /etc/X11/xorg.conf

Use the following Xorg configuration:

Section "ServerLayout"
Identifier     "X.org Configured"
Screen      0  "Screen0" 0 0
InputDevice    "Mouse0" "CorePointer"
InputDevice    "Keyboard0" "CoreKeyboard"
EndSection

Section "Files"
ModulePath   "/usr/local/lib/xorg/modules"
FontPath     "/usr/local/lib/X11/fonts/misc/"
FontPath     "/usr/local/lib/X11/fonts/TTF/"
FontPath     "/usr/local/lib/X11/fonts/OTF/"
FontPath     "/usr/local/lib/X11/fonts/Type1/"
FontPath     "/usr/local/lib/X11/fonts/100dpi/"
FontPath     "/usr/local/lib/X11/fonts/75dpi/"
EndSection

Section "Module"
Load  "dbe"
Load  "dri"
Load  "dri2"
Load  "extmod"
Load  "glx"
Load  "record"
EndSection

Section "InputDevice"
Identifier  "Keyboard0"
Driver "keyboard"
EndSection

Section "InputDevice"
Identifier  "Mouse0"
Driver      "vmmouse"
Option     "Protocol" "auto"
Option     "Device" "/dev/sysmouse"
Option     "ZAxisMapping" "4 5 6 7"
EndSection

Section "Monitor"
Identifier   "vmware"
VendorName   "VMware, Inc"
        HorizSync    30-100
        VertRefresh  56-120
EndSection

Section "Device"
Identifier  "VMware SVGA"
Driver      "vmware"
EndSection

Section "Screen"
Identifier "Screen0"
Device     "VMware SVGA"
Monitor    "vmware"
EndSection

Apply Patches and Build/Install Modules

Assuming you have already started the VMWare Tools installation, simply issue the following commands to start patching and building.

mount -t cd9660 -o ro /dev/cd0 /media
cd /tmp
tar -zxvf /media/vmware-freebsd-tools.tar.gz
cd /tmp/vmware-tools-distrib
patch -p1 < /tmp/vmware-tools-distrib.diff
patch -p1 < /tmp/vmware-config-tools.diff
cd lib/modules/source
tar -zxvf vmblock.tar
tar -zxvf vmmemctl.tar
cd vmblock-only
patch -p1 < /tmp/vmblock-only.diff
make && make install
cd ../vmmemctl-only
patch -p1 < /tmp/vmmemctl-only.diff
make && make install
cd ../../../../

Finally run the VMWare Tools installer:

./vmware-install.pl -d

Configure Services

Enable the required services by editing your /etc/rc.conf

fusefs_enable="YES"
hald_enable="YES"
dbus_enable="YES"
moused_enable="YES"
vmware_guest_vmblock_enable="YES"
vmware_guest_vmhgfs_enable="YES"
vmware_guest_vmmemctl_enable="YES"
vmware_guest_vmxnet_enable="YES"
vmware_guestd_enable="YES"

Then reboot

reboot

Start the vmware-user-wrapper from withing your desktop environment

vmware-user-wrapper &

Alternative: Open VMWare Tools

The official VMware Tools package has a problem where the clipboard sharing and auto-resize features won't work. The only option is to use the open-vm-tools package from the ports.

If you want to use open-vm-tools instead of the official tools, you must remove the VMWare version if you have installed it:

vmware-uninstall-tools.pl

Then install the open source tools from ports. See this page http://www.unibia.com/unibianet/freebsd/open-vm-tools-freebsd-10-xorg for instructions on how to do that.