When upgrading my ESX 4.1 to ESXi 4.1 cluster, I searched around for different methods to do an unattended / scripted installation on the hosts. I did not want to use Host Profiles, mostly because of the licensing requirement (Enterprise Plus), but also because I’m a big fan of scripting. Everywhere I looked I saw references to using a “Kickstart” script. What is this magical language, I thought, and how can I get in on the action!
Being a heavily vested Microsoft techy, I had to search for Kickstart to figure out what it was. Most of the Google searches point towards non-profit organizations who focus on helping people – nope, not what I was looking for. Luckily, Wikipedia had a nice entry:
Kickstart is normally used at sites with many Linux systems, to allow easy installation and consistent configuration of new computer systems.
Ok, a pretty generic description, but it’s a start. Now, how do I use this thing? Here are some resources I’ve visited to learn Kickstart with VMware:
- ESXi 4.1 Kickstart Install – WIP – This was a great resource on creating a script, provided by Kendrick Coleman.
- Kickstart (Linux) on Wikipedia
- Scripted install with ESXi – Duncan Epping provides a sample script and some explanation on how to setup the line command to call the script.
- esxcfg Command Help – A list of esxcfg commands on Eric Siebert’s blog. I found this useful for understanding more about the command structure and what other commands were available.
I make a few assumptions with this script:
- The host has 8 NICs
- The shared storage connections are handled by PowerShell (which I am more comfortable with) … might be worth a post in of itself.
- It’s a lab environment – this is why tech support mode is enabled and I’m pointing to the CD-ROM.
- I heavily commented the script, mostly because I did vSwitch0 first and then copied it to the other vSwitches, but also to reinforce what each command was doing as I wrote it.
### Accept the EULA vmaccepteula ### Root Password rootpw changeme ### Install on the first partition autopart --firstdisk --overwritevmfs ### Install ESXi from the CD-ROM install cdrom ### Configure vSwitch0 (initial settings) network --bootproto=static --device=vmnic3 --ip=10.10.1.100 --gateway=10.10.1.1 --nameserver="10.10.1.2,10.10.1.3" --netmask=255.255.0.0 --hostname=esxTEST.mylab.local --addvmportgroup=0 ### Firstboot %firstboot --unsupported --interpreter=busybox ### Enable Tech Support Mode (Remote) vim-cmd hostsvc/enable_remote_tsm vim-cmd hostsvc/start_remote_tsm ### Enable Tech Support Mode (Local) vim-cmd hostsvc/enable_local_tsm vim-cmd hostsvc/start_local_tsm ### vSwitch0 (Management) # Add vmnic esxcfg-vswitch -L vmnic3 vSwitch0 # Add vmnic esxcfg-vswitch -L vmnic7 vSwitch0 # Add a portgroup esxcfg-vswitch -A 'Management Network' vSwitch0 # Assign a VLAN to a port group esxcfg-vswitch -v 10 -p 'Management Network' vSwitch0 ### vSwitch1 (VM) # Create a virtual switch esxcfg-vswitch -a vSwitch1 # Add vmnic esxcfg-vswitch -L vmnic0 vSwitch1 # Add vmnic esxcfg-vswitch -L vmnic1 vSwitch1 # Add vmnic esxcfg-vswitch -L vmnic5 vSwitch1 # Add a portgroup esxcfg-vswitch -A 'VM' vSwitch1 ### vSwitch2 (DMZ) # Create a virtual switch esxcfg-vswitch -a vSwitch2 # Add vmnic esxcfg-vswitch -L vmnic2 vSwitch2 # Add a portgroup esxcfg-vswitch -A 'DMZ' vSwitch2 ### vSwitch3 (Customer) # Create a virtual switch esxcfg-vswitch -a vSwitch3 # Add vmnic esxcfg-vswitch -L vmnic4 vSwitch3 esxcfg-vswitch -A 'Customer' vSwitch3 ### vSwitch4 (VMotion) # Create a virtual switch esxcfg-vswitch -a vSwitch4 # Add vmnic esxcfg-vswitch -L vmnic6 vSwitch4 # Add a portgroup esxcfg-vswitch -A 'VMotion' vSwitch4 # Assign an IP esxcfg-vmknic -a -i 192.168.0.1 -n 255.255.255.0 VMotion ### vSwitch5 (Test) # Create a virtual switch esxcfg-vswitch -a vSwitch5 # Add a portgroup esxcfg-vswitch -A 'Test' vSwitch5 ### Refresh network and wait 10 seconds vim-cmd hostsvc/net/refresh sleep 10 ### Enable vMotion on vmkernel vmk1 vim-cmd hostsvc/vmotion/vnic_set vmk1 ### Refresh network and wait 10 seconds vim-cmd hostsvc/net/refresh sleep 10
I think this is a great place to store the script, since I can get access to it any time. Moving forward, I’d probably find a way to add NTP information to the script. It would also be nice to have a method to “roll through” IP addresses incrementally, until a new one is found, so that I could apply this script to multiple hosts without having to modify it each time. Such as to start with 192.168.0.1 for the VMotion IP, and then increment upwards if .1 is used and try .2.
Hopefully anyone who stumbles upon this entry can also get started with Kickstart’ing their ESXi installations.