ESXi Deployment Solution - Part 4

So today we will deal with how to get the scripts into the an ESXi installation. On Part 3 we dealt with what the scripts were and how to to use them

So how do we get the script to run on startup?

The two things that need to be done are:

  1. Add the script to /sbin/client.py

    # TCP client example
    import time
    import socket

    s = socket.socket()

  2. Add a Startup script to /etc/rc.local.d/S99unattend


    export PYTHONHOME=/
    export PYTHONPATH=/lib/python2.5-visor:/lib/python2.5-visor/lib-dynload:/lib/pyt
    export PATH
    python /sbin/client.py

    The reason for all the exports are since the script is not really running under any specific user it will not load the path and the Python variables, hence the explicit declaration.

So in order for us to add this to an ESXi ISO we need to do the following:

  1. Add /etc/rc.local.d/S99unattend to the oem.tgz file
  2. Add /sbin/client.py to the oem.tgz file

Now why the oem.tgz. The oem.tgz file is a file that will be parsed for installation which allows for OEM's to add bits and pieces into the ESXi install if needed.

In a default ESXi ISO - these are the contents of the image:


What we will need to do is a bit of manipulation to add some files to the oem.tgz and also into the image.tgz. Why both files you may ask - in order to make the changes to the installation persistent they have also be updated into the install.tgz file.

The most comprehensive resource I have found on customizing the oem.tgz file is on
Dave Mischenko's site.

There is a project on http://code.google.com/p/mkesxiaio/ where the process is automated - I cannot say that I have tried this personally - but it is on my list of to-do things.

We are going to this manually to explain the process a bit more so you can understand it a bit better and change it to your needs if you would like

Tools for the job that are needed:

Copy the iso image from VMware-VMvisor-Installer-4.0.0.Update01-208167.x86_64.iso to your Linux machine - you can use WinSCP or pscp.

pscp VMware-VMvisor-Installer-4.0.0.Update01-208167.x86_64.iso root@

Create directories for the process

mkdir iso iso-mount oem image dd-image

Mount the CD

mount -o loop -t iso9660 VMware-VMvisor-Installer-4.0.0.Update01-208167.x86_64.iso iso-mount

Since this is read only copy files to iso directory

cp -r iso-mount/* iso/

Unmount and remove the folder

umount iso-mount/

rm -rf iso-mount/

Next we create the oem.tgz file

cd oem/

mkdir -p sbin etc/rc.local.d/

And now we create the script files.

The client

cat >> sbin/client.py <<EOF
# TCP client example
import time
import socket

s = socket.socket()

And the Startup Script

cat >> etc/rc.local.d/S99unattend <<EOF

export PYTHONPATH=/lib/python2.5-visor:/lib/python2.5-visor/lib-dynload:/lib/python2.5-visor/site-packages
export PATH
python /sbin/client.py

Next we add the execute permissions

chmod -R 755 etc/ sbin/

Tar the file back up

tar czvf ../oem.tgz etc/ sbin/

The oem.tgz needs to be copied to two different locations

Copy to the first location

cd ..

cp oem.tgz iso/

Extract the installer image from the ISO

tar zxvf iso/image.tgz -C image/

We now extract the disk file

cd image/usr/lib/vmware/installer/

bunzip2 VMware-VMvisor-big-208167-x86_64.dd.bz2

Mount the image

mount -o loop,offset=$((512*8224)) VMware-VMvisor-big-208167-x86_64.dd ../../../../../dd-image/

2nd location – copy the oem.tgz file into the dd-image

cp ../../../../../oem.tgz ../../../../../dd-image/

Unmount the image

umount ../../../../../dd-image/

Compress the file

bzip2 VMware-VMvisor-big-208167-x86_64.dd

Go back to the install directory

cd ../../../../

Re-create the install.tgz file

tar zvcf ../iso/image.tgz usr/

cd ../iso

Create ISO

mkisofs -o ../My_VMware-VMvisor-Installer-4.0.0.Update01-208167.x86_64.iso -b isolinux.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table .

cd ..

if you would there after you can remove everything

rm -rf dd-image/ image/ iso/ oem*

And as you can there is my newly created ESXi iso with my customizations inside


I have created a file with all the commands that you can copy and paste into a shell session for your convenience.

The whole process took less than 8 minutes.

Next up will be how deploy this to an through PXE to a server.