Automated ESXi Network Based Build

In my earlier post I outlined how to enable an ESXi server build from the network, now I want to look at the steps required to make the ESXi automatically rebuild when it is network booted. 

First you need the infrastructure in the earlier post, which is made up of:

  • A PXE environment, DHCP, TFTP and the PXELinux boot loader.
  • A build repository containing the contents of the ESXi install CDROM

    Then you need to provide an KickStart file for the ESXi installer and a way to tell the PXELinux environment to use that to build the ESXi server.

    The KickStart file will be ESXi host specific, it’s content and syntax is documented in the ESXi install guide, below is a very simple one that I am using for one of my hosts:

    install url
    rootpw vmware
    autopart –firstdisk –overwritevmfs
    network –bootproto=static –ip= –hostname=esx1.lab.local –netmask= –gateway= –nameserver= –addvmportgroup=0 –device=vmnic0

    The “install url” line should point to your build repository and the “network” line should contain the required settings for your ESXi server’s management network.  Note that at install time only one physical NIC will be used, we’ll add some commands to fix that later in the process.  It would also be better to use an encrypted password in the “rootpw” line rather than manually change the password to a complex one later however I haven’t found a good method to generate the password crypt on windows.

    Once the file is created save it in a location on your build repository using a naming standard that makes sense to you.  In my lab I place the KickStart file in the ESXi version repository folder, the same location that the “install url” line points to and I save it as the ESXi server’s hostname with a .cfg extension, in this case “C:\Inetpub\wwwroot\ESXi_4_1u1\esx1.cfg”

    Now that we have a KickStart file we need to tell the installer to use this file, that is a simple matter of a “ks=” directive in the PXE config file.  The directive must go immediately after the “vmkboot.gz” directive, as shown below.


    Now any computer that PXE boots will be immediately rebuilt as ESXi server esx1.  That may not be quite what we want, especially if we have a number of ESXi servers on this network, so we’d better make the automated build physical server specific.  Luckily PXELinux doesn’t just use the “default” configuration and will first look for a variety of other file names.  The simplest method is to have a host specific configuration file that is named for the MAC address of the physical server which uses the ESXi host specific KickStart files.  This allows a series of ESX server specific PXE config files each of which builds a specific ESXi server automatically when the ESXi PXE boots.  In my lab the host “esx1” has a MAC address of “01:00:0c:29:9b:69:54”on it’s first NIC so it’s PXE config file is named “01-00-0c-29-9b-69-54” and lives in the  “C:\TFTPRoot\pxelinux.cfg” folder.  I have also changed the “default” file so that it causes any unknown PXE client to boot from it’s local drive rather than rebuild as an ESXi host, the new default  file is shown below:


    I haven’t cleaned up the boot screen as it’s not displayed for long enough, it will still show a menu of one item for a second.

    The build process is:

    Reboot server, press <F12> for PXE Boot

    DHCP server returns boot server and pxelinux.0

    pxelinux.0 loads via TFTP and looks for a config file via TFTP

    MAC address named config file points to ESXi installer and ks file

    ESXi installer loads from TFTP

    ESXi installer reads ks file from web server

    ks file directs installer to web server for install image

    ESXi installer loads install image from web server and completes install


    For each ESXi host you will be building you will require a separate KickStart file and PXELinux file.  In the PXELinux file the “ks=” directive needs to point to a different kickstart file, which in turn has  a different IP address and hostname.  

    We now have an environment where a series of ESXi hosts can be automatically rebuilt by rebooting them and pressing <F12> to trigger network boot.  Two files are created for each ESXi host, a new host is accommodated by copying and a minimal amount of changes to those two files.  Of course at present we need to choose to PXE boot the host when we want to rebuild it, normally it will boot from it’s local hard disk.

  • © 2011, Alastair. All rights reserved.

    About Alastair

    I am a professional geek, working in IT Infrastructure. Mostly I help to communicate and educate around the use of current technology and the direction of future technologies.
    This entry was posted in General. Bookmark the permalink.

    2 Responses to Automated ESXi Network Based Build

    1. Anatoly Kern says:

      Did you try using

      It allows to start esxi deployment from scratch within 15 min together with other OS’s – very useful for lab environment.

    2. Alastair says:

      The UDA is very cool and does a lot of good things.

      My aim is to use only my existing windows environment and in part three I’m going to need to manipulate the PXE boot environment using PowerShell which is possibly less easy with the UDA than Windows servers.

      Anatoly, I hope last months earthquake didn’t affected you too badly.

    Comments are closed.