Many servers don’t have DVD drives nor CD drives, so installing ESXi 4.1 with a CD is not optimal.  Sure you could always buy a USB DVD drive, but why not try to be cool and do it with a USB stick instead?  I’m actually a bigger fan of doing things through PXE.  Network installs are the ideal way to manage datacenters.  However, sometimes, if you’re a rovering IT guy like me going from site to site, you can’t always do network installs.  There are an amazing amount of IT shops that I have run into that shun the idea of network installs.  So, for those still in the dark ages, or for those who are on the road a lot, here is how we do it with a USB stick in 10 easy steps.

1.  Get the VMware ESXi 4.1 ISO image from VMware.com.

2.  Open the image.  On my mac, I just click on the image and it opens it for me.  On Linux you could do a loop back mount:

mkdir /media/ISO
mount -o loop VMware-VMvisor-Installer-4.1.0-260247.x86_64.iso /media/ISO

If you have Windows, I’m sure you can use your favorite search engine to find a way to do it, but the rest of this tutorial is in Linux.

4.  Now get a USB stick.  You need to partition a large enough windows 95 image and make it bootable.  I do this through fdisk:

fdisk /dev/sdc (or whatever it shows up as)
d (delete all partitions)
n # new partition
p # primary partition
1 # 1 is the partition number.
1 # the first cylinder
+300M # the size
a # toggle bootable flag
1 # make partition 1 bootable
t # change the type
1 # of partition 1
b # partition type W95 FAT32
w # write it out

5.  Now you need to format it:

mkfs.vfat -n BOOT -F 32 /dev/sdc1

6.  Now we need to use syslinux and make it bootable.  I do this on Linux like this:

syslinux -s /dev/sdc1
dd if=/usr/lib/syslinux/mbr.bin of=/dev/sdc  # note that this is sdc not sdc1

7.  Mount the USB stick and copy all the files to it:

mkdir /media/USB
mount /dev/sdc1 /media/USB
cp -a /media/ISO /media/USB

8.  Now you have to get rid of the isolinux stuff:

rm -rf isolinux.bin
mv isolinux.cfg syslinux.cfg

9.  At this point you should be able to umount the USB drive and stick it in a server and boot from it and start the installer.  The problem is (in my opinion) is that the Installer is hard coded to look for the CDROM.  So you will error out saying that it can’t find the installation media.  This is pretty lame.  But that’s ok  because I want to automate this anyway.  So the answer is we make a kickstart file that can tell it where to go.  So let’s edit the syslinux.cfg and add a kickstart file.  We add these files to /media/USB where our USB is mounted.

The modified syslinux.cfg file:

Here we simply add the ks=usb argument.  This tells it to use kickstart and that the kickstart file is found on the USB drive.

default menu.c32
menu title VMware VMvisor Boot Menu
timeout 80

label ESXi Installer
menu label ^ESXi Installer
kernel mboot.c32
append vmkboot.gz ks=usb --- vmkernel.gz --- sys.vgz --- cim.vgz --- ienviron.vgz --- install.vgz

label ^Boot from local disk
menu label ^Boot from local disk
localboot 0x80

The Kickstart file (ks.cfg)

My simple kickstart file (ks.cfg) just looks like this:

vmaccepteula
rootpw cluster
autopart --firstdisk --overwritevmfs
install usb
network --bootproto=static --ip=192.168.70.76 --gateway=192.168.70.1 --hostname=sumavihv --device=vmnic0 --nameserver=192.168.70.1 --netmask=255.255.255.0

10.  There, now you’re done.  Unmount the USB key, Put it in the server and it will install ESXi4.1 from the USB key without any prompting.  Fun in 10 easy steps!