I received a couple of questions around doing a scripted install with ESXi and decided to write up a script and show you the steps required. Doing a scripted install with ESXi though is fairly simple:
- Boot from the ESXi CD-Rom
- Press "Tab" when the "VMware VMvisor Boot Menu" is displayed
- Edit the string so that it includes the location of your script.
When including the location of your script make sure you append it after "vmkboot.gz" and before "— vmkernel.gz" as William Lam pointed out in his blog post. It should resemble the following screenshot.
Now you can kick off the automated install of your ESXi server. But wait, you probably want to see what script I used? That is what I figured, here is the script I wrote to automatically install and configure the ESXi host, it is just a simple script that I used and tested in my lab with the main purpose of showing what is possible with ESXi today. The configuration of the server will run after the first boot. I have added several "comment lines" to explain what I am doing and why. Hope this helps, if not leave a comment!
# Standard install arguments
vmaccepteula
rootpw mypassword
autopart –firstdisk –overwritevmfs
install cdrom
network –bootproto=static –device=vmnic0 –ip=192.168.1.41 –gateway=192.168.1.1 –nameserver=192.168.1.20 –netmask=255.255.255.0 –hostname=esxi001.vmware.com –addvmportgroup=0
# We will configure some basic things during the first boot from the commandline before we add the host to vCenter
%firstboot –unsupported –interpreter=busybox
# Add an extra nic to vSwitch0 (vmnic0 and vmnic2) and a VLAN ID
esxcfg-vswitch -L vmnic2 vSwitch0
esxcfg-vswitch -v 10 -p 'Management Network' vSwitch0
# Add vMotion Portgroup to vSwitch0
esxcfg-vswitch -A vMotion vSwitch0
# Assign an ip-adress to the vMotion VMkernel and a VLAN ID to the Portgroup
esxcfg-vswitch -v 20 -p vMotion vSwitch0
esxcfg-vmknic -a -i 192.168.2.41 -n 255.255.255.0 vMotion
# Wait to ensure everything has been created and refresh the network stack
sleep 5
vim-cmd hostsvc/net/refresh
# Enable vMotion on the newly created VMkernel vmk1
vim-cmd hostsvc/vmotion/vnic_set vmk1
# Add new vSwitch for VM traffic (vmnic1 and vmnic3)
esxcfg-vswitch -a vSwitch1
#Create a standard portgroup for VMs to vSwitch1 and set a VLAN ID
esxcfg-vswitch -A Production_VLAN5 vSwitch1
esxcfg-vswitch -v 30 -p Production_VLAN5 vSwitch1
# Add NICs to the new vSwitch
esxcfg-vswitch -L vmnic1 vSwitch1
esxcfg-vswitch -L vmnic5 vSwitch1
# Wait to ensure everything has been created and refresh the network stack
sleep 5
vim-cmd hostsvc/net/refresh
# Set the default PSP for EMC V-MAX to Round Robin as that is our preferred load balancing mechanism
esxcli nmp satp setdefaultpsp –psp VMW_PSP_RR –satp VMW_SATP_SYMM