When I was playing with ESXi 5.0 in my lab I noticed some changes during the installation process. Of course I had not bothered to read the documentation but when I watched the installer fail I figured it might make sense to start reading. I’ve documented the scripted installation procedure multiple times by now.
With ESXi 5.0 this has been simplified, this is what it looks like today:
I also want to point out that many of the standard installation commands have been replaced, removed or are not supported anymore. I created a simple script to automatically install an ESXi 5.0 host. It creates a second vSwitch and a second VMkernel for vMotion. It enables both the local and remote TSM and sets the default PSP for the EMC VMAX to Round Robin. As you can see there is a huge shift in this script towards esxcli. Although some of the old “esxcfg-*” commands might still be working they are deprecated and no longer supported. The new standard is esxcli, make sure you get familiarized with it and start using it today as over time this will be the only CLI tool available.
# Sample scripted installation file
# Accept the VMware End User License Agreement
vmaccepteula
# Set the root password for the DCUI and ESXi Shell
rootpw mypassword
# Install on the first local disk available on machine
install --firstdisk --overwritevmfs
# Set the network to DHCP on the first network adapater, use the specified hostname and do not create a portgroup for the VMs
network --bootproto=dhcp --device=vmnic0 --addvmportgroup=0
# reboots the host after the scripted installation is completed
reboot
%firstboot --interpreter=busybox
# Add an extra nic to vSwitch0 (vmnic2)
esxcli network vswitch standard uplink add --uplink-name=vmnic2 --vswitch-name=vSwitch0
#Assign an IP-Address to the first VMkernel, this will be used for management
esxcli network ip interface ipv4 set --interface-name=vmk0 --ipv4=192.168.1.41 --netmask=255.255.255.0 --type=static
# Add vMotion Portgroup to vSwitch0, assign it VLAN ID 5 and create a VMkernel interface
esxcli network vswitch standard portgroup add --portgroup-name=vMotion --vswitch-name=vSwitch0
esxcli network vswitch standard portgroup set --portgroup-name=vMotion --vlan-id=5
esxcli network ip interface add --interface-name=vmk1 --portgroup-name=vMotion
esxcli network ip interface ipv4 set --interface-name=vmk1 --ipv4=192.168.2.41 --netmask=255.255.255.0 --type=static
# Enable vMotion on the newly created VMkernel vmk1
vim-cmd hostsvc/vmotion/vnic_set vmk1
# Add new vSwitch for VM traffic, assign uplinks, create a portgroup and assign a VLAN ID
esxcli network vswitch standard add --vswitch-name=vSwitch1
esxcli network vswitch standard uplink add --uplink-name=vmnic1 --vswitch-name=vSwitch1
esxcli network vswitch standard uplink add --uplink-name=vmnic3 --vswitch-name=vSwitch1
esxcli network vswitch standard portgroup add --portgroup-name=Production --vswitch-name=vSwitch1
esxcli network vswitch standard portgroup set --portgroup-name=Production --vlan-id=10
# Set DNS and hostname
esxcli system hostname set --fqdn=esxi5.localdomain
esxcli network ip dns search add --domain=localdomain
esxcli network ip dns server add --server=192.168.1.11
esxcli network ip dns server add --server=192.168.1.12
# Set the default PSP for EMC V-MAX to Round Robin as that is our preferred load balancing mechanism
esxcli storage nmp satp set --default-psp VMW_PSP_RR --satp VMW_SATP_SYMM
# Enable SSH and the ESXi Shell
vim-cmd hostsvc/enable_ssh
vim-cmd hostsvc/start_ssh
vim-cmd hostsvc/enable_esx_shell
vim-cmd hostsvc/start_esx_shell
For more deepdive information read William’s post on ESXCLI and Scripted Installs.
Slym says
Hi, thank you for this useful post.
I just wanted to let you know that ESXi 4.1 and 5.0 are supported in my USB creator software.
It means you can create an USB flash drive containing ESXi setup very easily. The ks.cfg file will be autmatically created (see FAQ) and will be kept if it already exists.
The software is free, open-source and currently supports a lots of other things (Linux distributions, Windows ISO …).
You can download it @ http://www.linuxliveusb.com
I hope you will like it.
Please contact me through the software’s website if you encounter any problems.
brugh says
duncan, do you know if unattended installations to a Flash or USB disk will be supported in v5? it’s one of those things that we found odd in 4.x. what’d be the difference in a manual and unattended install anyway.
Patrick says
Scripted install to USB/Flash is definitely supported in 5.0.
The reason for the changes in the base scripted install commands stems from the “dd” raw image going away. With 5.0 whatever was booted on the ISO or across the network is what gets “cached” to the disk.
Duncan says
yes as far as I know it will be.
Chris says
Hi Duncan
Thanks for your post, it helped me a lot to tranfer my ols scripts. Could it be, that there is a small syntax error in the line:
esxcli storage nmp satp set –default-psp=VMW_PSP_RR –satp=VMW_SATP_SYMM
In my environment it’s only working without equal signs:
esxcli storage nmp satp set –default-psp VMW_PSP_RR –satp VMW_SATP_SYMM
Regards,
Chris
Jason Griffin says
Ok I had this working fine with ESXi4.1 and can’t get it to work with 5.
Any help appreciated.
I’m running Rhel4 (linux) as my pxeboot kickstart server.
I created the following folder layout in my /tftpboot directory.
/tftpboot/images/vsphere/esxi50
I dumped the contents of the ESXI5.0 iso into this directory.
I then coped the menu.c32 and mboot.c32 into my /tftpboot dir. I noticed that they are in capitals (MBOOT.C32 and MENU.C32 on the CD).
I then created my default file in pxelinux.cfg.
Something like this
default menu.c32
prompt 0
timeout 100
MENU TITLE ESXi 5 Kickstart
LABEL ESXi 5 Kickstart
menu label ESXi 5 Kickstart
kernel mboot.c32 -c images/vsphere/esxi50/BOOT.CFG ks=nfs://192.168.1.14/kickstart/ksfiles/ks.192.168.1.16.cfg
I created a standard ks.cfg.
I then tried a test kickstart. However I keep getting the message that the “Initial menu has no LABEL entries!”.
I then removed a lot of the lines from the default file but I get an error that it can’t find kernel image: linux.
Is there something obvious that I’m missing or any reason this wont work?
Many Thanks
J
Augusto says
Try like this.
DEFAULT ESX_5.0_install
LABEL ESX_5.0_install
KERNEL mboot.c32
APPEND -c boot.cfg pxebooting ks=http://192.168.0.3/kickstart/ks5.cfg
vRico says
Great KS! I noted that all of the NICs I added to the switches came up in standby. Do you know the switch to make them active when added. Also do you know how to set the load balancing for uplinks on a vswitch? In ESXi 4.1 I used something like:
vim-cmd hostsvc/net/portgroup_set –nicorderpolicy-active=vmnic0 –nicorderpolicy-standby=vmnic6 vSwitch0 ‘Management Network’
vim-cmd hostsvc/net/portgroup_set –nicorderpolicy-active=vmnic6 –nicorderpolicy-standby=vmnic0 vSwitch0 vMotion
OR
vimsh -n -e “hostsvc/net/vswitch_setpolicy –nicteaming-policy loadbalance_ip vSwitch0”
vimsh -n -e “hostsvc/net/vswitch_setpolicy –nicteaming-reverse-policy true vSwitch0”
Richard Garrow says
Hi I am trying to get this scripted install working with ESXi5 I pull the script off another site where he stated Duncan had helped. Now for some reason I can not get past the default. nothing else works any help would be greatly appreiated.
default menu.c32
prompt 0
menu title UNetbootin
timeout 100
label unetbootindefault
menu label Default
kernel /ubnkern
append initrd=/ubninit
label ESX01
menu label ESX0^1 Scripted Installation
kernel /MBOOT.C32
append initrd=/ubninit -c boot.cfg ks=USB:/ksscript/ks.cfg +++
label ESX02
menu label ESX0^2 Scripted Installation
kernel /MBOOT.C32
append initrd=/ubninit -c boot.cfg ks=USB:/ksscript/ks2.cfg +++
label ESX03
menu label ESX0^3 Scripted Installation
kernel /MBOOT.C32
append initrd=/ubninit -c boot.cfg ks=USB:/ksscript/ks3.cfg +++
label ESX04
menu label ESX0^4 Scripted Installation
kernel /MBOOT.C32
append initrd=/ubninit -c boot.cfg ks=USB:/ksscript/ks4.cfg +++
label ESX05
menu label ESX0^5 Scripted Installation
kernel /MBOOT.C32
append initrd=/ubninit -c boot.cfg ks=USB:/ksscript/ks5.cfg +++
label ESX06
menu label ESX0^6 Scripted Installation
kernel /MBOOT.C32
append initrd=/ubninit -c boot.cfg ks=USB:/ksscript/ks6.cfg +++
label ESX07
menu label ESX0^7 Scripted Installation
kernel /MBOOT.C32
append initrd=/ubninit -c boot.cfg ks=USB:/ksscript/ks7.cfg +++
label ESX08
menu label ESX0^8 Scripted Installation
kernel /MBOOT.C32
append initrd=/ubninit -c boot.cfg ks=USB:/ksscript/ks8.cfg +++
label ubnentry1
menu label ^Boot from local disk
LOCALBOOT 0x80
generious says
@Richard Garrow
Change it from
append initrd=/ubninit -c boot.cfg ks=USB:/ksscript/ks8.cfg +++
To
append initrd=/ubninit -c boot.cfg ks=USB:/ks8.cfg +++
So copy your KS8.CFG(again make sure they are in caps) to the root of the drive, I had the same problem and dropped them back to the root and it worked fine…
Ron says
Does anyone use the scripted install with static IP’s? Prior to ESXi 5, I edited the isolinux.cfg file with the boot parameters. When the host booted up to the Boot Menu, I hit tab, the boot options are prepopulated and all I have to do is edit the ks.cfg file name. Now with 5.0, I try this method, but keep getting checksum errors when trying to boot with the edited install ISO (new isolinux.cfg file injected). Anyone have any experience with this? Please let me know.
Ron says
I found the answer at http://www.virtuallyghetto.com/2012/03/how-to-create-bootable-esxi-5-iso.html
Matt says
Ron,
How did you get this to work? I can’t quite figure out how to do it with 5.0/5.1.
Ron says
Hi Matt,
I followed the steps in the link above. It assumes you have mkisofs installed on the vMA. I have a document that highlights the steps. Send me your email and I’ll forward it.
Thanks,
Ron
Chris McGrath says
Hi, I want to deploy around 50+ ESXi 5 servers but would like to be able to use one master kick start file and be prompted to add the hostname and IP addresses somewhere throughout the install. I don’t want to have 50+ ks.cfg files with each servers IP addresses. Any help would be greatly appreciated. These are all remote sites, so i can’t use PXE and i will be booting the ks.cfg from CD-ROM or USB.
Peter says
Fantastic. thanks. helped with converting my older esxcfg-* commands to the newer esxcli.
p
kALYAN dAKSHIT says
I would like to know incase I need to make a partition like vmimages how to do that thru the script.
Also what are the std partitions that we can have in esxi5.1.Do we need a swap partition ?
rajashekar says
Hi 0,I created ks.cg file for VMware Esxi 5.0 it is looking like
#
# Sample scripted installation file
#
# Accept the VMware End User License Agreement
vmaccepteula
# Set the root password for the DCUI and Tech Support Mode
rootpw password
# Set the keyboard
keyboard ‘United Kingdom’
# The install media is in the CD-ROM drive
install –firstdisk –overwritevmfs
#driver installation
# Set the network to static on the first network adapater
network –bootproto=static –device=vmnic0 –ip=10.0.0.172 –netmask=255.255.248.0 –gateway=10.0.0.14 –nameserver=10.0.0.4 –hostname=’amiindia’
# A sample post-install script
%post –interpreter=python –ignorefailure=true
import time
stampFile = open(‘/finished.stamp’, mode=’w’)
stampFile.write( time.asctime() )
I done unattended installation for VMware Esxi 5.0 .But i dont know how to add packages and OEM drivers in ks.cfg file . For manual installation it doesnt ask any packges and drivers during unattended installation we have to add drivers and packages so how can we add drivers and packages in ks.cfg file any one please help me….
rajashekar says
Hi,I used above scripted installation for unattended installation.but mainly I am getting problem with drivers installation in script file….
I used following commands for driver installation ..
Wget ftp://192.168.108.1/raj.vib -O /tmp/
Esxcli software vib install – v /tmp/raj.vib
But here wget comand is not working it is showing an error : ftp login:permission denied
Can any one help me
Thanks in advance….
Dave says
Hi Ron,
Do you still have the document availible ?
Thanks
Dave
Ron says
Hi Dave
I have since moved on to another role, but I usually keep all my documentation. I will check when I get to the office and let you know.
Thanks
Ron
Ron says
Here are the contents of the doc:
Creating a custom ISO for ESXi 5
Prerequisites: You must follow Steps 1,2 & 3 of this article:
http://www.virtuallyghetto.com/2012/03/how-to-create-bootable-esxi-5-iso.html
– Login to vMA appliance
– change directory to /home/vi-admin/esxi_cdrom
vi-admin@localhost:~> cd /home/vi-admin/esxi_cdrom
vi-admin@localhost:~/esxi_cdrom>
– edit the isolinux.cfg file using the vi editor.
o Type vi isolinux.cfg
o Press insert and make the appropriate changes to the isolinux.cfg file
o Press ESC and type :wq to write and quit
– Repackage the ISO with the edited isolinux.cfg file using the command:
o sudo mkisofs -relaxed-filenames -J -R -o iso name.iso -b isolinux.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table /home/vi-admin/esxi_cdrom
– Copy the ISO to the iso repository:
o cp /home/vi-admin/esxi_cdrom/iso name.iso /home/vi-admin/iso-repo/datacentre/
– Delete the iso from the /home/vi-admin/esxi_cdrom directory:
o sudo rm /home/vi-admin/esxi_cdrom/iso name.iso
– Use WinSCP to copy the iso file from the vMA to the appropriate NFS datastore
Thanks,
Ron
Dave says
Much Appreciated Ron,
Thanks
Dave