Recently I came across the need to install hundreds of ESXi hosts on USB sticks and wanted to accomplish this in the easiest way possible. While installing ESXi isn’t complicated, it can be time-consuming and would require the need to be swapping the monitor and keyboard continually or having multiple monitors and keyboards. I wanted an unattended install method where I wouldn’t need to continue to touch each machine and have to go back configure it. I was not only able to accomplish this task, but also have the installer install ESXi on itself to minimize the number of USB drives needed. The plan was to start the install, walk away, and then come back to it after the installation was complete. Below are the steps I used on MacOS to be able to accomplish this task. Look for my next post where I script the USB creation process to make it even easier and faster.
Below are the manual steps to accomplish this using MacOS broken down into two different parts:
Creating bootable USB ESXi Installer on Mac to install on itself
Mount the required ESXi installer ISO by double-clicking it or running the command in Terminal:
hdiutil mount /path/to/ESXi.iso
Insert the USB flash drive where you want ESXi installed and start up Disk Utility.
Select the USB flash drive so that we can erase it and format it with the following options:
- Format: MS-DOS (FAT)
- Scheme: Master Boot Record
- Name: (example) ESXI-6-7-U2
After erasing the drive, we need to mark the partition as active. Disk Utility does not support marking partitions as active so we need to use Terminal.
List all the mounted volumes to determine the identifier for the USB flash drive you inserted.
diskutil list
Locate the disk identifier which should be something similar to /dev/disk3s1.
Now to unmount the USB flash drive, note this is not the same as eject. Make sure to replace X and Y with the proper numbers obtained from the previous command:
diskutil unmount /dev/diskXsY
Start up the command-line partitioner fdisk in interactive mode which will require administrator privileges on the drive you identified in the previous commands:
sudo fdisk -e /dev/diskXsY
Once in fdisk, you flag the first partition on the volume as active and bootable:
f 1
Next, you write the changes:
write
Finally, you exit fdisk interactive mode:
quit
Now to remount the USB flash drive using the diskutil command:
disktuil mount /dev/diskXsY
Now you will list the volumes of the mounted ESXi installer ISO and the USB flash drive you just formatted:
ls /Volumes/
Copy the entire contents of the ESXi ISO to the root of the USB flash drive either through Finder or terminal using the the command below:
cp -R /Volumes/ESXI-6.7.0-20190504001-STANDARD/* /ESXI-6-7-U2/
On the USB flash drive rename the file ISOLINUX.CFG to SYSLINUX.CFG:
mv /Volumes/ESXI-6-7-U2/ISOLINUX.CFG /Volumes/ESXI-6-7-U2/SYSLINUX.CFG
Now in order to have the flash drive boot automatically to the kickstart file that will be placed on the root of the install USB flash drive we need to edit the two BOOT.CFG files in the following locations using vi or nano:
vi /Volumes/ESXI-6-7-U2/BOOT.CFG
nano /Volumes/ESXI-6-7-U2/EFI/BOOT/BOOT.CFG
Find the line that starts with kernelopt and delete everything after the equal sign. Then we will add the information in bold below to state that we want to load a kickstart script and list the location and name of the file:
- kernelopt=ks=usb:/ks.cfg
Editing the kickstart file to configure the ESXi host:
- Download the attached ks.cfg file from my GitHub account to use and edit: ks.cfg
- Using a text editor (not Word) you will need to edit lines 12, 21, 30, 31, 40, and 43
- Line 12 you will set the ‘root’ password by replacing {PASSWD}.
- Line 21 you will change the information after the equal sign of the following device={NIC1}, hostname={HOSTNAME}, vlanid={VLANID}, ip={IPADDR}, netmask={SUBNET}, gateway={GATEWAY}, and nameserver={DNS1},{DNS2} as needed.
- Line 30 you will set IP or hostname of the NTP server replacing {NTP1}.
- Line 31 if you have a second NTP IP or hostname you will replace {NTP2}. If you don’t have or want to use a second NTP server then you can comment out the line by placing a “#” at the beginning of the line.
- Line 40 you will again replace {HOSTNAME} with the same name you used in line 21.
- Line 43 you will replace the information after the equal sign uplink-name={NIC2} if you want to set a second management nic. If you only have one nic or don’t want assign a second network adater then you can comment out the line by placing a “#” at the beginning of the line.
- Save the file and then copy to the root of the USB flash drive you created as the install drive
You now have a fully configured unattended USB ESXi installation drive. All that is left to do is plug in the USB drive to the hardware you want to configure and power it on. I hope this helps you and ultimately saves you time when having to install ESXi on multiple hosts.