This is an old revision of the document!


Open VM Tools Background and Assumptions

This page is under construction. Proceed at your own peril. May be ready on 2013-06-19.

The procedure for making the proprietary VMWare Tools and Open VM Tools are very similar. As it turns out, the Open VM Tools package is incomplete, and so we must fill in the gaps based on what we know from VMWare Tools. In particular, two files in the /etc directory which are critical for the Open VM Tools to work are provided here because they do not get built during the make process.

This procedure details how to build an Open VM Tools extension only. How to make an extension for VMWare Tools is left as an exercise for the reader. The Open VM Tools extension is much smaller than the the VMWare Tools extension because the VMWare Tools comes with most of the dependent libraries built in, whereas Open VM Tools has the same libraries as dependencies.

The resulting extension will be kernel version specific because kernel modules will be built and loaded. It is not known if it is possible to build the programs and modules separately, or if programs and modules compiled against different versions could be separated and still interoperate. This has been tested on 32-bit only and has not been tested on 64-bit systems.

Creating an Open VM Tools TCZ Extension

This article assumes the user is comfortable at the command line. Using these instructions, the user will:

  • create temporary files and directories
  • output the final files to a temp directory
  • compile applications from source

Required:

  1. compiletc
  2. linux-headers-KERNEL
  3. glibc_apps
  4. glib2-dev
  5. gtk2-dev
  6. gtkmm-dev
  7. Xorg-7.6-dev
  8. procps
  9. libdnet
  10. fuse
  11. squashfs-tools-4.x

Abbreviated steps

  1. Compile Open VM Tools
  2. Create Open VM Tools setuid links
  3. Create Configuration Files and Scripts
  4. Create TCZ extension

Compile Open VM Tools

Download the latest version of the open-vm-tools from Sourceforge. Do not be fooled by the link to the latest version above the version directories. Unpack the open-vm-tools source code and cd into the new directory:

tar xfz open-vm-tools-X.Y.Z-build_number.tar.gz
cd open-vm-tools-X.Y.Z-build_number
./configure --prefix=/usr/local --without-pam --without-icu --disable-static RPCGEN=$(readlink -f $(which rpcgen)) RPCGENFLAGS="-Y $(dirname $(which cpp))"

Edit modules/Makefile before running make:

  1. Update the MODULES_DIR path to /usr/local/lib/modules/3.0.21-tinycore/kernel/. Use your target kernel version if it is different.
  2. Either: Add vmblock to the list of modules to be built on the line which begins with MODULES =, Or: Add fuse.tgz to the list of dependencies for the extension.

Run as root, if not already su'ed, for the rest of this procedure. Run make:

make
mkdir TCZ
sudo sh
TCZROOT=$(pwd)/TCZ
make DESTDIR=$TCZROOT install-strip

It's a feature of the setuid wrapper that the executables must be in specific place defined in the locations file in the /etc/vmware-tools directory, and that they be referenced through one and only one link. The extension process will make everything links, but this isn't a problem because we know the links will be in the /tmp/tcloop/open-vm-tools/usr/local subdirectories.

cd $TCZROOT/usr/local/lib/open-vm-tools
mkdir bin sbin lib
cd $TCZROOT/usr/local/lib/open-vm-tools/bin
mv $TCZROOT/usr/local/bin/* .
ln -s vmware-user-suid-wrapper vmware-user
chmod u+s vmware-user-suid-wrapper
cd $TCZROOT/usr/local/bin
for a in ../lib/open-vm-tools/bin/*; do ln -s /tmp/tcloop/open-vm-tools/usr/local/lib/open-vm-tools/bin/$(basename $a); done
cd $TCZROOT/usr/local/lib/open-vm-tools/sbin
mv $TCZROOT/usr/local/sbin/* .
cd $TCZROOT/usr/local/sbin
for a in ../lib/open-vm-tools/sbin/*; do ln -s /tmp/tcloop/open-vm-tools/usr/local/lib/open-vm-tools/sbin/$(basename $a); done
cd $TCZROOT/usr/local/lib/open-vm-tools/lib
mv $TCZROOT/usr/local/lib/lib* .
# we don't need links for the libraries

Clean up files we don't need:

rm -rf $TCZROOT/usr/local/etc
rm -rf $TCZROOT/usr/local/share
rm -rf $TCZROOT/usr/local/include
rm -rf $TCZROOT/usr/local/lib/pkgconfig
rm -rf $TCZROOT/sbin

Create Configuration Files and Scripts

Make the TinyCore extension specific vmware paths locations file:

cd $TCZROOT/etc/vmware-tools
cat > locations <<EOF
answer BINDIR /tmp/tcloop/open-vm-tools/usr/local/bin
answer INITDIR /etc/init.d
answer INITSCRIPTSDIR /etc/init.d
answer SBINDIR /tmp/tcloop/open-vm-tools/usr/local/sbin
answer LIBDIR /tmp/tcloop/open-vm-tools/usr/local/lib/open-vm-tools
EOF
ln -s /tmp/tcloop/open-vm-tools/usr/local/lib/open-vm-tools/plugins plugins

Make the Tinycore extension initialization script

mkdir -p $TCZROOT/usr/local/tce.installed
cd $TCZROOT/usr/local/tce.installed
cat > open-vm-tools <<EOF
#!/bin/sh
#
/etc/init.d/open-vm-tools start
EOF
chmod a+x open-vm-tools

Make the open-vm-tools startup script

mkdir -p $TCZROOT/etc/init.d
cd $TCZROOT/etc/init.d
cat > open-vm-tools <<EOF
#!/bin/sh
# Start, stop, and restart vmtoolsd

unload_module() {
lsmod|grep -q ^$1 && rmmod $1
/sbin/udevadm settle
}

load_module() {
lsmod|grep -q ^$1 || modprobe $1
/sbin/udevadm settle
}

case "$1" in
start)
# Ensure kernel modules can be loaded
depmod -a

# Interface check
NIF1=$(wc -l < /proc/net/dev)

# Load vmhgfs module
load_module vmhgfs

# Mount vmhgfs
vmhgfs_mnt=/mnt/hgfs
[ -d $vmhgfs_mnt ] || mkdir -p $vmhgfs_mnt
sed /hgfs/d -i /etc/fstab
echo ".host:/ $vmhgfs_mnt vmhgfs defaults,user,ttl=5,uid=root,gid=root,fmask=0133,dmask=0022 0 0" >> /etc/fstab
grep -q vmhgfs /etc/mtab || mount $vmhgfs_mnt &>/dev/null

# comes compiled in 4.x kernel
# Load vmmemctl
#load_module vmmemctl

# Load vmci
load_module vmci

# Load vsock
load_module vsock

# Load vmxnet
load_module vmxnet

# Load vmblock
vmblock_dev=/tmp/VMwareDnD
vmblockfusemntpt=/var/run/vmblock-fuse
[ -d $vmblock_dev ] || mkdir -m 1777 -p $vmblock_dev

if tce-status -i | grep -q fuse; then
  if grep -q "$vmblockfusemntpt" /etc/mtab; then
    true
  else
    mkdir -m 1777 -p $vmblockfusemntpt
    vmware-vmblock-fuse -o subtype=vmware-vmblock,default_permissions,allow_other $vmblockfusemntpt
  fi
else
  load_module vmblock
  mount -t vmblock none /proc/fs/vmblock/mountPoint
fi

# Load vmsync
load_module vmsync

# Start vmtoolsd
if pidof vmtoolsd &>/dev/null; then
echo vmtoolsd already running
else
rm -f /var/run/vmtoolsd.pid
/usr/local/bin/vmtoolsd --background=/var/run/vmtoolsd.pid
fi

# Use ethtool to optimize vmxnet
   if which ethtool &> /dev/null; then
      for e in $(grep eth /proc/net/dev|cut -d: -f1); do
         ethtool -K $e gso on &> /dev/null
         ethtool -K $e tso on &> /dev/null
      done
   fi

# Start DHCP client for new interfaces
if ! grep -q nodhcp /proc/cmdline; then
NIF2=$(wc -l < /proc/net/dev)
if [ $NIF2 -gt $NIF1 ]; then
/etc/init.d/dhcp.sh
fi
fi
;;
stop)
   if pidof vmtoolsd &>/dev/null; then
      killall vmtoolsd
      echo stopped vmtoolsd
   else
      echo vmtoolsd is not running
   fi
;;
restart)
   $0 stop
   $0 start
;;
*)
   echo "Usage: $0 (start|stop|restart)"
   exit 1
;;
esac
EOF
chmod a+x open-vm-tools

Create TCZ Extension

At this point the directory should be fully populated with all the files needed for the extension. Use mksquashfs to create the actual extension:

cd $TCZROOT/..
mksquashfs TCZ ~/open-vm-tools.tcz

The new extension has dependencies, so a DEP file needs to be created:

cat > ~/open-vm-tools.tcz.dep <<EOF
Xorg-7.6.tcz
xf86-video-vmware.tcz
Xlibs.tcz
gtk2.tcz
glib2.tcz
procps.tcz
gtkmm.tcz
EOF

These extensions and their dependencies should be copied to the system that will be using the open-vm-tools extension before it's loaded. Then add blacklist=pcnet32 to the APPEND line of the boot configuration file. There is a conflict between the vmxnet and pcnet32 modules, so networking will not work unless the extension is loaded. Copy the open-vm-tools.tcz and open-vm-tools.tcz.dep files to the tce/optional directory of the virtual machine, and update onboot.lst by adding open-vm-tools.tcz.

not done: programs to add to .profile / .xsession

Print/export
QR Code
QR Code wiki:open_vm_tools (generated for current page)