Creating a bootable ESXi USB key using Linux

I wrote this quick tutorial to show how to make a USB key which contains a bootable version of the ESXi Hypervisor using Linux. I decided to go down this route to save all of my local physical HDD storage to be purely dedicated to hosting and servicing requests bound for the VMware guests. As most newer servers have the option of setting the USB devices to be boot devices, this offers a really quick way to boot the Hypervisor without needing to use/waste internal storage.

The first thing to do is to grab the latest CD ISO of ESXi from www.vmware.com and mount it on my local linux boxes loopback device.

mount -o loop /Users/matt_palmer/Downloads/VMware-VMvisor-Installer-4.1.0-260247.x86_64.iso /mnt

Change directory to where the ISO image is mounted.

cd /mnt

Copy the Bunzip compressed image of the Hypervisor out of the ISO and into a writeable directory.

cp IMAGEDD.BZ2 /someotherdirectory

Decompress the Bunzip DD image file.

bunzip2 /someotherdirectory/IMAGEDD.BZ2

Move the decompressed Bunzip2 DD image out file to a friendlier filename.

mv IMAGEDD.BZ2.out  IMAGEDD

remove all partition tables from usbstick using fdisk using fdisk /dev/sd<devicename>

**MAKE SURE YOU HAVE THE RIGHT DEVICE, AS IF YOU PICK WRONG THERES NO TURNING BACK, AND YOU COULD POTENTIALLY OVERWRITE ANOTHER LEGITIMATE DEVICE**

fdisk /dev/sd<devicename>

Press ‘m’ for help and select the correct options for deleting any existing partitions on the usb device.

Next use dd to copy a raw version of the ‘IMAGEDD’ file to the usb device which you manipulated in the previous step

dd if=IMAGEDD of=/dev/sdb (don’t need to specify a partition number as there shouldn’t be any, this will make sure that the partitions that are in the image will get written raw to the USB stick.) This will take quite a while as there is alot of data to copy to the USBkey. If you want to keep a check on how things are progressing you can send a USR1 signal to dd to get it to dump out its current statistics as dd by default doesnt provide any progress information.

If your system isnt shared and you are the only person running dd, you can run the following: killall -USR1 dd

otherwise you will have to use ps to find the PID of your specific dd task as follows:ps -aef|grep dd, which should show you something similar to this:

root      1504  1035  0 15:51 pts/1    00:00:06 dd if=IMAGEDD of=/dev/sdb

Now you can use the PID displayed here to send the USR1 signal to your dd process:

kill -USR1 1504

this will show you how many MB /GB have been processed so far.

Once dd has finished you should be able to see serveral partitions on the USB key called HypervisorO,Hypervisor1 an so on.

This means you are ready to put the USBkey into your server and select it as the new boot device. If all has gone well you should see the Yellow/Grey ESXi Hypervisor ‘booting’ screen.

-Enjoy

Matthew Palmer