How to install vmware tools on IPCop virtual machine

IPCop is a small linux distribution providing simple firewall / router / NAT solution. When running as a virtual machine, it is advisable to have VMware Tools installed (at least to allow graceful restart/shutdown of the OS and reporting guest IPs in vSphere). However IPCop is a very limited distribution, lacking many needed tools like insmod / rmmod, PAM, init.d system (IPCop uses sysinit). Plus it is using kernel version 3.4, which is not supported by vmtools. See Enabling NAT on VMware ESX with help of IPCop for detailed insructions on how to install IPCop on ESX.

But there is still an option to install vmtools under IPCop, although without any kernel modules – but the graceful shutdown still works.

First initiate the vmtools installation from vSphere / vCenter via menu Guest –> Install/Upgrade VMware Tools (I am running under ESX 6.0 host in this example). Then mount the virtual CD and extract the package to a temp directory (we use /var/log filesystem because of how IPCop partitions its limited disk space). We remove all binary modules as none are for our kernel. IPCop itself needs less than 500 MB of disk space, so if you allocated only so much to the VM, take care you have at least 120 MB free in root filesystem (and about 250 MB in /var/log during the install process).

root@ipcop:~ # mount /dev/sr0 /mnt/ -o ro
root@ipcop:~ # mkdir /var/log/VM-tools
root@ipcop:~ # ll /mnt/
total 71888
-r-xr-xr-x 1 root root     2012 Feb 17  2016 manifest.txt
-r-xr-xr-x 1 root root     1850 Feb 17  2016 run_upgrader.sh
-r--r--r-- 1 root root 72162730 Feb 17  2016 VMwareTools-10.0.6-3560309.tar.gz
-r-xr-xr-x 1 root root   687524 Feb 17  2016 vmware-tools-upgrader-32
-r-xr-xr-x 1 root root   757944 Feb 17  2016 vmware-tools-upgrader-64
root@ipcop:~ # cd /var/log/VM-tools
root@ipcop:/var/log/VM-tools # tar xzf /mnt/VMwareTools-10.0.6-3560309.tar.gz
root@ipcop:/var/log/VM-tools # du -ks
222276  .
root@ipcop:/var/log/VM-tools # cd vmware-tools-distrib/
root@ipcop:/var/log/VM-tools/vmware-tools-distrib # ll
total 524
drwxr-xr-x  2 root root   4096 Feb 17  2016 bin
drwxr-xr-x  5 root root   4096 Feb 17  2016 caf
drwxr-xr-x  2 root root   4096 Feb 17  2016 doc
drwxr-xr-x  5 root root   4096 Feb 17  2016 etc
-rw-r--r--  1 root root 282475 Feb 17  2016 FILES
-rw-r--r--  1 root root   2538 Feb 17  2016 INSTALL
drwxr-xr-x  2 root root   4096 Feb 17  2016 installer
drwxr-xr-x 14 root root   4096 Feb 17  2016 lib
drwxr-xr-x  3 root root   4096 Feb 17  2016 vgauth
-rwxr-xr-x  1 root root    243 Feb 17  2016 vmware-install.pl
-rwxr-xr-x  1 root root 205571 Feb 17  2016 vmware-install.real.pl
root@ipcop:/var/log/VM-tools/vmware-tools-distrib # rm -r lib/modules/binary/*
root@ipcop:/var/log/VM-tools/vmware-tools-distrib # du -ks
110328  .

Then we need to create some dirs, which vmtools installation expects, but are not part of IPCop’s system.

root@ipcop:/var/log/VM-tools/vmware-tools-distrib # for i in 0 1 2 3 4 5 6; do mkdir -p /usr/local/rc.d/rc$i.d; done
root@ipcop:/var/log/VM-tools/vmware-tools-distrib # mkdir /etc/pam.d

Now we can start the installation script. It will complain about some tools not found, just reply with /bin/true for all of them. Also reply with our created directories when asked.

root@ipcop:/var/log/VM-tools/vmware-tools-distrib # ./vmware-install.pl
Setup is unable to find the "rmmod" program on your machine. Please make sure
it is installed. Do you want to specify the location of this program by hand?
[yes]

What is the location of the "rmmod" program on your
machine? /bin/true

Creating a new VMware Tools installer database using the tar4 format.

Installing VMware Tools.

In which directory do you want to install the binary files?
[/usr/bin] /usr/local/bin

What is the directory that contains the init directories (rc0.d/ to
rc6.d/)? /usr/local/rc.d

What is the directory that contains the init scripts?
[/usr/local/rc.d]

In which directory do you want to install the daemon files?
[/usr/local/sbin]

In which directory do you want to install the library files?
[/usr/local/lib/vmware-tools]

The path "/usr/local/lib/vmware-tools" does not exist currently. This program
is going to create it, including needed parent directories. Is this what you
want? [yes]

In which directory do you want to install the common agent library files?
[/usr/local/lib]

In which directory do you want to install the common agent transient files?
[/var/lib]

In which directory do you want to install the documentation files?
[/usr/local/doc/vmware-tools]

The path "/usr/local/doc/vmware-tools" does not exist currently. This program
is going to create it, including needed parent directories. Is this what you
want? [yes]

The installation of VMware Tools 10.0.6 build-3560309 for Linux completed
successfully. You can decide to remove this software from your system at any
time by invoking the following command:
"/usr/local/bin/vmware-uninstall-tools.pl".

Before running VMware Tools for the first time, you need to configure it by
invoking the following command: "/usr/local/bin/vmware-config-tools.pl". Do you
want this program to invoke the command for you now? [yes]

Setup is unable to find the "ldd" program on your machine.  Please make sure it
is installed.  Do you want to specify the location of this program by hand?
[yes]

What is the location of the "ldd" program on your machine? /bin/true

Setup is unable to find the "insmod" program on your machine.  Please make sure
it is installed.  Do you want to specify the location of this program by hand?
[yes]

What is the location of the "insmod" program on your
machine? /bin/true

Setup is unable to find the "rmmod" program on your machine.  Please make sure
it is installed.  Do you want to specify the location of this program by hand?
[yes]

What is the location of the "rmmod" program on your
machine? /bin/true

Searching for GCC...
The path "" is not valid path to the gcc binary.
Would you like to change it? [yes] no

Searching for a valid kernel header path...
The path "" is not a valid path to the 3.4-3 kernel headers.
Would you like to change it? [yes] no


WARNING: This program cannot compile any modules for the following reason(s)...

The communication service is used in addition to the standard communication
between the guest and the host.  The rest of the software provided by VMware
Tools is designed to work independently of this feature.
If you wish to have the VMCI feature, you can install the driver by running
vmware-config-tools.pl again after making sure that gcc, binutils, make and the
kernel sources for your running kernel are installed on your machine. These
packages are available on your distribution's installation CD.
[ Press Enter key to continue ]

{the same for other kernel modules...}

Warning: This script could not find mkinitrd or update-initramfs and cannot
remake the initrd file!

Generating the key and certificate files.
Successfully generated the key and certificate files.
   Checking acpi hot plug                                              done
Starting VMware Tools services in the virtual machine:
   Switching to guest configuration:                                   done
   Guest operating system daemon:                                      done
The configuration of VMware Tools 10.0.6 build-3560309 for Linux for this
running kernel completed successfully.

root@ipcop:/var/log/VM-tools/vmware-tools-distrib # ps -ef|grep vm
root     29659     1  0 21:48 ?        00:00:00 /usr/local/sbin/vmtoolsd
root@ipcop:/var/log/VM-tools/vmware-tools-distrib # cd
root@ipcop:~ # rm -r /var/log/VM-tools
root@ipcop:~ # du -ks /usr/local/
110404  /usr/local/

The configuration will output message about each kernel module not being able to compile, just acknowledge it with Enter. At the end, you should have the vmtoolsd daemon running, but we still need to adjust the IPCop startup sysinit script to run vmtools start script at boot.

root@ipcop:~ # cat >>/etc/rc.d/rc.event.local
EVENT=${1}
VALUE=${2}
if [ "$EVENT" = "system" -a "$VALUE" = "up" ]; then
  /usr/bin/logger -t ipcop "Starting vmware tools"
  rm -f /var/lock/subsys/vmware-tools
  /usr/local/rc.d/vmware-tools start
fi

File rc.event.local is run from rc.event, which is run at the end of rc.sysinit with parameters system and up. We need to remove the stale lock file first as we are not properly stopping the vmtools during shutdown. Now you can reboot IPCop to check if vmtools will be started during boot.