Open VM Tools on FreeBSD 10 with Xorg

It's possible to enable clipboard sharing and auto-resize features inside a FreeBSD guest running on VMWare. However you will need to use the emulators/open-vm-tools port or package.

UPDATE: This is the hard way. You might instead want a script that will do it automatically.

Requirements

  • FreeBSD 10.x (may also work on 9.x)
  • VMWare Workstation 9.x, 10.x, 11.x

These instructions also work with GhostBSD 4.x and 10.1.

Uninstall Conflicting Tools First

Before you can use emulators/open-vm-tools you must remove the officail VMWare tools or the VirtualBox tools if you have them installed.

To remove the VMware tools, use the uninstall script

vmware-uninstall-tools.pl

If you have VirtualBox tools, you can just disable them from /etc/rc.conf. VirtualBox is usually enabled automatically with GhostBSD

# Virtual Box adition configuration
#vboxguest_enable="YES"
#vboxservice_enable="YES"

Get the FreeBSD Source Code and Ports Tree

If your going to use pre-built binary packages or you already have the source you can skip this step.

The /usr/src directory must be empty before we can proceed. A fresh installation of FreeBSD leaves an empty 'sys' directory that will cause problems during code checkout. That needs to be deleted:

rmdir /usr/src/sys

Recent version of FreeBSD include the "svnlite" utility by default. Use this to perform the code download. Make sure you replace the release with your version of FreeBSD (use 'uname -a' to find out).

svnlite co svn://svn0.us-east.FreeBSD.org/base/release/10.1.0 /usr/src

You can also change the mirror to something closer. For a list of mirrors look at the FreeBSD handbook page. The checkout process could take a few minutes to a few hours depending on your Internet connection.

After the source code has been synchronized you should fetch the ports tree. Again, this is only required if you want to build your own packages instead of using pre-built packages.

portsnap fetch extract

Or if you already have the ports tree and want to update it:

portsnap fetch update

An important note. If you update your ports tree and already have ports installed you need to update them all before you proceed. That's beyond the scope of this article.

Install Packages or Ports

Install the required packages using the pkg utility.

pkg install -y open-vm-tools xf86-video-vmware xf86-input-vmmouse

If your building from source:

cd /usr/ports/emulators/open-vm-tools
make install
cd /usr/ports/x11-drivers/xf86-video-vmware
make install
cd /usr/ports/x11-drivers/xf86-input-vmouse
make install

Update System Configuration

Once you have the drivers and software installed you need to update your system's configuration files to make use of these new items. The first thing that needs to be modified is the /etc/rc.conf file.

Enable the required services at system start up by ensuring your /etc/rc.conf contains these items. (Some items may already be present, especially if you are using GhostBSD.

# Your keyboard and mouse won't work without this.
hald_enable="YES"
dbus_enable="YES"

# Mouse
moused_enable="YES"

# VMWare Tools
vmware_guest_vmblock_enable="YES"
vmware_guest_vmhgfs_enable="YES"
vmware_guest_vmmemctl_enable="YES"
vmware_guest_vmxnet_enable="YES"
vmware_guestd_enable="YES"

Next configure Xorg to use the VMware display and mouse drivers. If you are using GhostBSD 4.x you should already have an /etc/X11/xorg.conf file.

Note: GhostBSD 10.1 does not include one by default and one will need to be generated and placed in /usr/local/etc/X11/xorg.conf.d/.

In either case If you don't have an xorg.conf file, generate one using:

cd /root
Xorg -configure
mv /root/xorg.conf.new /usr/local/etc/X11/xorg.conf.d/vmware.conf

More information on this step can be found in the FreeBSD handbook.

Look for the following lines and edit them as shown below in the /etc/X11/xorg.conf file.

...
Driver      "mouse"
...
Driver      "vesa"
...

Changes to:

...
Driver      "vmmouse"
...
Driver      "vmware"
...

There is an issue with the newest Xorg in FreeBSD where device hot plugging will use the regular mouse driver instead of the vmmouse driver. To work around this issue you must disable hot plugging support.

Add this to the "ServerLayout" section of the xorg.conf file:

Section "ServerLayout"
...
Option       "AutoAddDevices" "Off"
...
EndSection

For those of you using a newer version of GhostBSD (10.3 or newer) just drop in the following configuration file into /usr/local/etc/X11/xorg.conf.d

Section "ServerFlags"
       Option             "AutoAddDevices"       "false"
EndSection
Section "InputDevice"
       Identifier "Mouse0"
       Driver             "vmmouse"
       Option              "Device"       "/dev/sysmouse"
EndSection

Try it Out

Reboot your system to automatically start the required services. If you have a display manager like GDM, PCDM, or Slim you should be able to log in graphically. Otherwise, issue the 'startx' command.

Copy and paste and automatic desktop resizing should work. The mouse should also be smooth and automatically switch between the guest and host machines on the edges.

As of this writing the user toolbox is not working. This is due to the vmblock kernel module not being able to load because of an issue with the open-vm-tools upstream code base. Normally, you would run this command from a terminal or add it to your startup applications.

vmware-user-suid-wrapper

If your getting virtualbox notification errors on login you should disable the virtualbox client from the session startup applications. GhostBSD 10.1 users will likely run into this problem.