ESX Scripted Installation
A few days ago I wrote an article about ESXi 4.1 scripted installation, I know there are many organizations that are still using the full ESX version (with the service console). While I do want to encourage everybody to move to the ESXi version, I will describe how you can easily integrate the deployment of ESX 4.x to achieve exactly the same (I will only described the differences/additions so use the ESXi 4.1 scripted installation as a companion guide.
Configuration
Follow the following instructions to enable a scripted installation of ESX 4.0 Update 2:
-
Create the following folder structure within the “esx_deployment” FTP folder

-
Create the following folders into the “RemoteInstall/Boot/x86″ folder:

- Copy the entire contents of the ESX 4.0 Update2 CD to the “esx_deployment/esx40u2″ folder
- Copy/rename the following files to the following folder as shown by the table:
| Source | Target |
| <esx 4.0 Update 2 cd-rom>\initrd.img | <remoteinstall>\Boot\x86\esx40u2 |
| <esx 4.0 Update 2 cd-rom>\vmlinuz | <remoteinstall>\Boot\x86\esx40u2 |
- Modify the PXE default file by adding the following contents into the “<remoteinstall>\Boot\x86\pxelinux.cfg\default” file:
| DEFAULT menu.c32 TIMEOUT 200 PROMPT 0 MENU WIDTH 60 MENU MARGIN 10 MENU ROWS 10 MENU TABMSGROW 18 MENU CMDLINEROW 18 MENU ENDROW 24 MENU TIMEOUTROW 20 MENU TITLE ESX Installation Menu LABEL local MENU LABEL Boot From Local Disk KERNEL linux/chain.c32 APPEND hd0 0 LABEL esx41i_s MENU LABEL ESXi4.1 (Scripted) KERNEL esxi41/mboot.c32 APPEND esxi41/vmkboot.gz ks=ftp://<ip address of ftp server>/esxi41/ks.cfg vlanid=<vlanid> — esxi41/vmkernel.gz — esxi41/sys.vgz — esxi41/cim.vgz — esxi41/ienviron.vgz — esxi41/install.vgz LABEL esx40u2_s MENU LABEL ESX 4.0 Update 2 (Scripted) KERNEL esx40u2/vmlinuz APPEND initrd=esx40u2/initrd.img text netdevice=vmnic0 ks=ftp://<ip address of ftp server>/esx40u2/ks.cfg vlanid=<vlanid> mem=512M url=ftp://<ip address of ftp server>/esx40u2 IPAPPEND 1 |
- Change the default ks.cfg file in the folder “esx_deployment\esx40u2″ to match the following contents:
| accepteula authconfig –enableshadow –enablemd5 bootloader –location=mbr –md5pass= firewall –allowIncoming firewall –allowOutgoing install url ftp://<ip address of ftp server>/esx40u2 keyboard fr-CH_latin1 timezone –utc Europe/Brussel auth –enablead –addomain=<domain name> –addc=<domain name> reboot rootpw password # Now call the custom scripts %include /tmp/host.cfg %include /tmp/vmotion.cfg %include /tmp/done-msg.cfg # PRE AND POST SECTIONS START HERE %pre –interpreter=bash sleep 5 wget -q ftp://<ip address of ftp server>/esx40u2/hostconfigs/server.ref -O /tmp/server.ref echo “[ retrieving MAC address ]” mymac=$(esxcfg-nics -l | grep vmnic0 | awk ‘{print $7}’ | sed ‘s/://g’) echo “[ retrieving server name ]” myserver=$(cat /tmp/server.ref | grep $mymac | awk ‘{print $1}’) echo “[ Downloading host files from FTP repository ]” wget -q ftp://<ip address of ftp server>/esx40u2/hostconfigs/$myserver-$mymac.cfg -O /tmp/host.cfg wget -q ftp://<ip address of ftp server>/esx40u2/hostconfigs/$myserver-vmotion-$mymac.cfg -O /tmp/vmotion.cfg wget -q ftp://<ip address of ftp server>/esx40u2/postconfigs/done-msg.cfg -O /tmp/done-msg.cfg |
-
Create a server.ref file into the following folder “esx_deployment\esx40u2\hostconfigs” and add one line per ESX host as following:
| <esx host 01> <space> <mac address>
<esx host 02> <space> <mac address> <esx host 03> <space> <mac address> |
Note: Make sure that the format of the file is in a UNIX format ! If you are using Notepad++, then this can be done via “Edit/EOL Conversion/Unix Format”.
-
Create for every ESX host the following files in the “esx_deployment\esx40u2\hostconfigs” folder:
| File: <esx hostname>-<mac address>.cfg
Contents:
clearpart –firstdisk –overwritevmfs part /boot –fstype=ext3 –size=1100 –onfirstdisk –asprimary part <esxhostname>_local –fstype=vmfs3 –size=25600 –grow –onfirstdisk part None –fstype=vmkcore –size=110 –onfirstdisk
virtualdisk cos –size=20480 –onvmfs=<esxhostname>_local part / –fstype=ext3 –size=5120 –onvirtualdisk=cos part /var/log –fstype=ext3 –size=4096 –onvirtualdisk=cos part /tmp –fstype=ext3 –size=4096 –onvirtualdisk=cos part /home –fstype=ext3 –size=2048 –onvirtualdisk=cos part /opt –fstype=ext3 –size=248 –onvirtualdisk=cos part swap –fstype=swap –size=1600 –onvirtualdisk=cos
network –bootproto=static –device=vmnic0 –ip=<ip address> –netmask=<Subnet Mask> –gateway=<gateway> –nameserver=”<dns server1, dns server2>” –hostname=<esxhostname> –vlanid=<vlanid> –addvmportgroup=0 |
| File: <esx hostname>-vmotion-<mac address>.cfg
Contents:
%post –interpreter=bash
echo “[ Configuring vMotion ]” echo “[ -- Add vMotion VMKernel port to vSwitch0 ]” /usr/sbin/esxcfg-vswitch -A vmotion vSwitch0 /usr/sbin/esxcfg-vswitch –vlan=<vlanid> –pg=vmotion vSwitch0
echo “[ -- Configure IP address for vMotion ]” /usr/sbin/esxcfg-vmknic -a -i <vMotion IP> -n <Subnet Mask> vmotion |
-
Create the following file in the “esx_deployment\esx40u2\postconfigs” folder:
| File: done-msg.cfg
Contents:
%post –interpreter=bash
cat << \EOF > /etc/rc3.d/s99postconf
#!/bin/bash sleep 60 /usr/sbin/esxcfg-firewall –allowOutgoing name=$(sed -e ‘/localhost/d’ /etc/hosts | sed -e ‘/#/d’ | awk ‘{print $2}’) now=$(date ‘+%Y%m%d%H%M’) echo > /tmp/$name,$now.pro busybox ftpput <ip ftp server>/esx40u2/progress/$name,$now.pro /tmp/$name,$now.pro
/usr/sbin/esxcfg-firewall –blockOutgoing
rm -f /etc/rc3.d/s99postconf EOF
chmod +x /etc/rc3.d/s99postconf |


