Scripted ESXi Installation

I know there are many blog articles out there that deal with this subject. But this is basically for my reference, hence documenting it here.

I wanted to have a an automated way of installing ESXi quickly, as I end with unclean ESXi installs after testing some customer environments or setups. So I decided to leverage vSphere kickstart installation to make the process easy.

My kickstart file looks like the following:

vmaccepteula
# Following clear all partitions on the local disks
clearpart --alldrives --overwritevmfs
install --firstdisk --overwritevmfs
# Following will create a VMFS on the second local drive
partition esx1:local --ondisk=mpx.vmhba1:C0:T1:L0
network --bootproto=static --device=vmnic0 --addvmportgroup=1 --ip=192.168.1.1 --netmask=255.255.255.0 --hostname=esx1.foobirds.local --gateway=192.168.1.254 --nameserver=192.168.1.253
rootpw vmware
paranoid
reboot

# following code gets executed only on firstboot after the install
%firstboot --interpreter=busybox
# Now if your kickstart file is located on a NFS share, the NFS mount
# remains on the freshly installed ESXi, the nfs mount name that remains
# is "remote-install-location"
# Following code removes (stale) nfs mount after install
dsName=`esxcli storage nfs list | awk 'END{print $1}'`
esxcli storage nfs remove -v=${dsName}

If you want to do a scripted  install where kickstart file resides on a NFS share, then:

Boot with the ESXi installer CD and use the following command at the boot prompt after pressing ‘Shift +O’:

instead of:

runweasal

use the following command line:

mboot.c32 -c boot.cfg ks=nfs://192.168.1.3/nfs/ks/ks.cfg

If you want to create a custom ISO image of ESXi installer along with embedded kickstart file, follow instructions as mentioned in vSphere documention.

Copy your kickstart file to the root of the ESXi installer and recreate the ISO as documented in the vSphere documentation. Once done, to ensure that ESXi install happens as per the specified kickstart file, edit the following:

boot.cfg

And then modify the

kernelopt

To read as

kernelopt=runweasel ks=cdrom:/ESX_KS.CFG

Important: One gotcha that you should be aware of is that, although you may have entered the kickstart file name correctly, but still the installer may fail to find the kickstart file. This is a known issue and is documented in this KB#1026373 article along with a work around.

For a detailed information about kickstart file options and commands, read this KB#2004582 article.

That’s it.

Advertisements

2 thoughts on “Scripted ESXi Installation

  1. How come when I’ve created a custom boot.cfg, a clean one is used in it’s place. I know it’s clean because it reverts back to only using “runweasel” with no mention of my ks location. I’ve also modified the title to use a capital “I” in “Loading ESXi Installer” (it was installer with lower case “i”). Any suggestions?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s