Scripted install of ESX 3.0

Automated install of ESX 3.0

For the customer I work, I’ve written an automatic installation script to deploy ESX hosts within minutes.The UDA is an appliance that I use for pxe boot and choosing which script to run. You can find the UDA here: When booting a new server (or one that needs to be reinstalled), you press F12 and the UDA will offer a PXE boot environment. The server is presented a menu from which the installation can be chosen. After selecting the installation desired, almost everything is done automatically. During the first run, all necessary files are installed and the server is rebooted. After this reboot some extra configurations are made using a second script I call after boot time. The only thing left after this is, connecting the server to virtual center, activating the licenses and enabling the (already configured) vmotion interfac. I’m aware that enabling the vmotion interface can be done using the vmish command but I was too lazy at this point to add it in :-) One should always leave room for improvement :-)

(Not tested on 3.5 yet !!!)

Detailed layout

You can skip this section and go to the code section if you just want to use the script. I’ll first explain how the script has evolved and how the different sections follow each other. The first script I had functioned quite well, but the downside of it was that when adding a new server, you’d have to edit the IP address and host name manually in the script. Because this is quite error prone, I searched for a way to make as few changes as possible when adding a new host. I started using variables, but it turned out that they get lost between the various sections in the kickstart script. There is a %PRE, %POST and an install section. I needed to find a way to past these vars from one section to another. I used a dummy file to save the vars to disk, but (ofcourse) during install the disk is repartitioned and reformatted which made me lose the dummy file. Thanks to the help of the kickstart mailing list I learned about the special –nochroot section you can use during %POST. At that point there are two filesystems available, the temp file system that is used during install and the new file system not yet mounted at the proper location. It enables me to copy my dummy file from the temp system to the new file system and then continue. In the %POST section the new file system is then mounted and my dummy file is ready for use.

The next image shows which sections are used and which scripts are called.

When the server is booted and F12 is pressed, the PXE boot is started on the nic. The UDA will assign an ip-address and then display the installation menu. Here you chose which installation to start.The installation menu in my case is a list of host names. Each menu item has a boot command line like this : append ip=dhcp ksdevice=eth0 load_ramdisk=1 initrd=initrd.esx301 network ks=http://x.x.x.249/kickstart/es031.cfg ESXIP=31. For a detailed explanation of this command line, please refer to the UDA manual.

Important is the extra piece I’ve added: “ESXIP=31” to the command line. In my situation all hosts are in the same subnet and only the last digit of the IP will change. In this case the IP will end with 31. Also all host names are like this: vmesx001, vmesx002, in this case vmesx031. ( I admit there will be a problem in the hostname when we reach IP=100 because of the leading zero, but that is for later concern). After choosing the installation, the UDA will load the kickstart script from http://x.x.x.249/kickstart/es031.cfg. (249 is the IP of the UDA).The kickstart script has 4 sections, %PRE, command-section, %POST –nochroot and %POSTsection. Not sure if command-section is the correct name, but this contains the normal installation options.


The %PRE section I use to read the boot command line and search for the ESXIP= variable. Most scripting tricks I explain in the code itself. This is just to show you how to go with the flow :-) So, after I find the ESXIP var, I know the IP address the host should get and write this to a temp file: /tmp/networkconfig. This will also contain gateway address, name servers and hostname. In the command section, this file is read and included again. Because I need the vars later on for other things, I write them to The will only contain a call to another script called /tmp/ and the IP address and VMotion IP address are passed. (I use the x.x.26.x subnet of esx hosts and the x.x.28.x subnet for vmotion).


Now the installation starts and standard things like regional settings, disk layout, etc are loaded. The network section is included through this command: %include /tmp/networkconfig. Nothing special here :-) After this the %POST –nochroot section is started.

%POST –nochroot

Very short section, only used to copy the “” script from the temporary file system to the new file system. This enables me to use it later on again.


The post section will download the esx-post-script .sh which contains extra configuration settings. After download is started which then calls the and pastes the IP and VMotion IP.

When the esx-post-script is ran, the host is still running the installation and the vmkernel is not yet loaded. But a number of configurations have to be done with a loaded VMkernel. The work around is to again create a script file, which then can be run after VMkernel is loaded. Looking at the esx-post-script you’ll see that most of it is pasted to /tmp/ The last piece is to make /tmp/ executable and edit rc.local to run /tmp/ after reboot.

I think that the comments I put inside the scripts are helpful enough to figure out what is done by each command. Should you have more questions, feel free to mail me. The scripts don’t display very well on this blog so I offer them as download here: Scripting ESX 3.0

11 thoughts on “Scripted install of ESX 3.0

  1. This topic just came up in discussions at work today. Great stuff – can’t wait to try it out.

    Have you tried it with 3.5, yet?

  2. Hi
    Not tried it on 3.5 yet. I’m sure most of it will run fine. I did read about a problem in ESX 3.5 with people who had scripted their network config, that ESX does something funny with putting NICs in standby mode. It can be easily reconfigured.

  3. Hi
    I’ve tried the scripts with ESX 3.5 and it works fine. NTP settings, vSwitch config etc, goes fine. Just noticed that sometimes the nics are in standby mode. There is a discussion on the vmware forum about this with a number of solutions.


  4. Is it possible to make a scripted install without using a network connection, but a floppy? And if so, how would I make that work?

  5. I have successfully created a scripted kickstart install using a all-in-one bootable CDRom. The only changes made to the .iso supplied by VMWare are a kickstart .cfg file at the root of the CD and a modified isolinux.cfg in the /isolinux directory. No Network needed and %post of kickstart used to further config server to office standard….

  6. Hi,

    I am trying out to install virtual host on ESX 3x
    And this has to be carried out from ILO port

    Is that feasible through script installation

    Pls note ESX is already installed.

  7. Tally – can I get a look at the script? I don't have network available at the time of installation – this is for recovery at DR site and VMware ESX will be up before any other server with an accessible network share. I have been trying to script – in the %post section of ks.cfg – copying files from the floppy to /mnt/sysimage/xxxxx but it hasn't been working… any help is good help…

  8. Tally – can I get a look at the script? I don't have network available at the time of installation – this is for recovery at DR site and VMware ESX will be up before any other server with an accessible network share. I have been trying to script – in the %post section of ks.cfg – copying files from the floppy to /mnt/sysimage/xxxxx but it hasn't been working… any help is good help…

Comments are closed.