This week I helped to answer a few questions about creating your own ESXi 5 bootable ISO along with automatically using a static IP Address when the custom ISO first boots up. Although all this information is available via the vSphere documentation, it may not always be easy to put all the pieces together and thought I share the steps for others to also benefit.

You will need access to a UNIX/Linux system and a copy of the base ESXi 5 ISO image. In this example I will be using VMware vMA and VMware-VMvisor-Installer-5.0.0.update01-623860.x86_64.iso and walk you through two different configurations. We will also be referencing the vSphere documentation Create an Installer ISO Image with a Custom Installation or Upgrade Script and Kernel Boot Options.

Create ESXi 5 Bootable ISO w/Remote ks.cfg:

In this configuration, we will create a custom ESXi ISO that will boot with a static IP Address and use a remote ks.cfg (kickstart) configuration file.

Step 1 - Mount base ESXi ISO using the "mount" utility:

$ mkdir esxi_cdrom_mount
$ sudo mount -o loop VMware-VMvisor-Installer-5.0.0.update01-623860.x86_64.iso esxi_cdrom_mount

Step 2 - Copy the contents of the mounted image to a local directory called "esxi_cdrom":

$  cp -r esxi_cdrom_mount esxi_cdrom

Step 3 - Unmount the ISO after you have successfully copied it and change into the esxi_cdrom directory

$ sudo umount esxi_cdrom_mount
$ cd esxi_cdrom

Step 4 - Edit the boot.cfg and specifically the "kernelopt" line to not use the weasel installer but kickstart and also specifying the remote location of your ks.cfg. To get more details on the various kernel boot options, please take a look at the vSphere Boot Options documentation above.

You will also need to specify the static IP Address you wish to have the host automatically use when the ISO first boots up on the same line.

Step 5 - Once you have finished your edits and saved the boot.cfg, you will now change back to the parent directory and use the "mkisofs" to create your new bootable ISO. In this example, we will name the new ISO "custom_esxi.iso":

$ sudo mkisofs -relaxed-filenames -J -R -o custom_esxi.iso -b isolinux.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table esxi_cdrom/

You now have a new bootable ESXi 5 ISO called "custom_esxi.iso" which will now automatically boot up with the specified static IP Address and install based on the ks.cfg that was specified.

Create ESXi 5 Bootable ISO w/Local ks.cfg:

Similar to the above configuration, we will create a custom ESXi ISO that will boot with a static IP Address but use a local ks.cfg (kickstart) configuration file that will be included within the custom ISO.

Step 1 through 3 is exactly the same as above

Step 4 - By default, a basic ks.cfg is included in the ESXi 5 ISO in /etc/vmware/weasel/ks.cfg and we will create a custom *.tgz file that will include our ks.cfg within the ISO. First off by creating a temporary directory which will be used to store our ks.cfg:

$ mkdir -p temp/etc/vmware/weasel

Step 5 - Copy your ks.cfg file into the temp/etc/vmware/weasel:

$ cp ks_custom.cfg temp/etc/vmware/weasel

Step 6 - Create a *.tgz file containing the path to our ks.cfg using the "tar" utility. In this example, we will called it customks.tgz:

$ cd temp
$ tar cvf customks.tgz *

Step 7 -  Copy the customks.tgz from temp directory to your esxi_cdrom directory:

$ cp temp/customks.tgz esxi_cdrom

Step 8 Change into the "esxi_cdrom" directory and edit the boot.cfg just like the above, but we will be using the "file://" stanza to specify the path to our ks.cfg, static IP Address as well as adding our customks.tgz to the module list to ensure that it loads up which contains the actual ks.cfg file that is called in the boot.cfg.

Step 9 - Same as Step 5 above, you now just need to run the "mkisofs" utility to create your bootable ISO.

You now have a new bootable ESXi 5 ISO called "custom_esxi.iso" which will now automatically boot up with the specified static IP Address and install based on the ks.cfg that is included within the ISO.

13 thoughts on “How to Create Bootable ESXi 5 ISO & Specifying Kernel Boot Options

  1. Hi William. I am one of your unknown apprentices, and have been following your excellent guidance for a while now…Great Work! I have a side issue with a Esxi 5.0.0 Update1 CD ISO install with a ks.cfg. I am trying to import files from the CD/DVD (a zipped Vm) in the install and boot the VM automatically…I just cant get it to work> Not even sure where to find the errors? the follow is from my ks.cfg file in the %firstboot section?

    # +—————————————————————————+
    # | Import the SED form the DVD-ROM, unzip the .tar file and register the VM
    # +—————————————————————————+
    vmkload_mod iso9660
    vsish -e set /vmkModules/iso9660/mount $(esxcfg-mpath -b | grep “CD-ROM” | awk ‘{print $1}’)
    source_dir=/vmfs/volumes/VMWARE_ESXI5_CUSTOM/VM
    post_dir=/vmfs/volumes/$(hostname -s)-datastore1/Staging_Folder
    mkdir -p ${post_dir}
    cp -r ${source_dir}/* ${post_dir}
    sleep 5
    #unzip the vm into its named folder>
    tar -xvf /vmfs/volumes/$(hostname -s)-datastore1/2012.tar -C /vmfs/volumes/$(hostname -s)-datastore1
    sleep 5

    # +—————————————————————————+
    # | Register the SED with ESXi
    # +—————————————————————————+
    vim-cmd solo/registervm /vmfs/volumes/$(hostname -s)-datastore1//.vmx

    Thanks

    Luca..London UK

    • @Luca,

      Thanks for the kind comments. The only thing that stands outs to me in your code is the source_dir variable, as you point it to “VMWARE_ESX5_CUSTOM”, can you confirm that is what actually shows up? I would also recommend looking esxi_install.log as well as vmkernel/hostd logs. As part of your %post, recommend you copy them onto a persisted datastore and go through the logs to see what’s going on.

      BTW – Please try not to post your questions in multiple locations.

      Thanks

  2. Hi william

    Apols for the double submission.

    I got it to work eventually :-). Copy below

    vmkload_mod iso9660
    vsish -e set /vmkModules/iso9660/mount $(esxcfg-mpath -b | grep “CD-ROM” | awk ‘{print $1}’)
    #source_dir=/vmfs/volumes/VMWARE_ESXI5_CUSTOM/VM
    #post_dir=/vmfs/volumes/$(hostname -s)-datastore1/Staging_Folder
    mkdir -p /vmfs/volumes/$(hostname -s)-datastore1/Staging_Folder
    #cp -r ${source_dir}/* ${post_dir}
    cp -r /vmfs/volumes/VMWARE_ESXI5_CUSTOM/VM/* /vmfs/volumes/$(hostname -s)-datastore1/Staging_Folder
    sleep 5
    tar -zxvf /vmfs/volumes/$(hostname -s)-datastore1/Staging_Folder/VM.TGZ -C /vmfs/volumes/$(hostname -s)-datastore1
    sleep 5

    I was attempting to import and power on a vm from the cd/dvd. I couldnt find a way to import it as a OVF/OVA (unless you know a way)so I zipped up the whole VM folder which worked great (as long as yuo keep an eye on the MD5’s)

    I imported it into a resouce pool and did an auto power on:
    vim-cmd solo/registervm /vmfs/volumes/$(hostname -s)-datastore1/VM-Folder/VM.vmx 2012alpha-SED-A pool0

    sed -i ‘$ a\for i in $(vim-cmd vmsvc/getallvms|cut -f1 -d” “|grep -v Vmid); do vim-cmd vmsvc/power.on $i; sleep 10; done’ /etc/rc.local

    Once last thing…I really want to do the same with a USB..is there any way around the 2GB FAt16 USB boundary limit for ESXi5?

    Many Thanks

    Luca (London)

  3. HELP!!!

    Wow I must be dumb because I can not get the file option working. I have distribution VMware-VMvisor-Installer-5.1.0-799733.x86_64.iso from the VMware site. There is no /etc in the iso. I’ve tried everything from creating the etc/vmware/weasel directory and placing the ks.cfg file there to addind the z option to the tar statment so it is a TRUE tgz file.

    Basically I am down to creating a ks.cfg file that ONLY sets the root password so I can see if it will work. I am not even attempting to set up any networking yet. Here are my boot.cfg files and ks.cfg file:

    boot.cfg
    bootstate=0
    title=Loading ESXi installer
    kernel=/tboot.b00
    kernelopt=ks=file://etc/vmware/weasel/ks.cfg
    modules=/b.b00 — /useropts.gz — /k.b00 — /chardevs.b00 — /a.b00 — /user.b00 — /s.v00 — /ata_pata.v00 — /ata_pata.v01 — /ata_pata.v02 — /ata_pata.v03 — /ata_pata.v04 — /ata_pata.v05 — /ata_pata.v06 — /ata_pata.v07 — /block_cc.v00 — /ehci_ehc.v00 — /weaselin.t00 — /esx_dvfi.v00 — /xlibs.v00 — /ima_qla4.v00 — /ipmi_ipm.v00 — /ipmi_ipm.v01 — /ipmi_ipm.v02 — /misc_cni.v00 — /misc_dri.v00 — /net_be2n.v00 — /net_bnx2.v00 — /net_bnx2.v01 — /net_cnic.v00 — /net_e100.v00 — /net_e100.v01 — /net_enic.v00 — /net_forc.v00 — /net_igb.v00 — /net_ixgb.v00 — /net_nx_n.v00 — /net_r816.v00 — /net_r816.v01 — /net_s2io.v00 — /net_sky2.v00 — /net_tg3.v00 — /net_vmxn.v00 — /ohci_usb.v00 — /sata_ahc.v00 — /sata_ata.v00 — /sata_sat.v00 — /sata_sat.v01 — /sata_sat.v02 — /sata_sat.v03 — /sata_sat.v04 — /scsi_aac.v00 — /scsi_adp.v00 — /scsi_aic.v00 — /scsi_bnx.v00 — /scsi_fni.v00 — /scsi_hps.v00 — /scsi_ips.v00 — /scsi_lpf.v00 — /scsi_meg.v00 — /scsi_meg.v01 — /scsi_meg.v02 — /scsi_mpt.v00 — /scsi_mpt.v01 — /scsi_mpt.v02 — /scsi_qla.v00 — /scsi_qla.v01 — /scsi_rst.v00 — /uhci_usb.v00 — /tools.t00 — /xorg.v00 — /imgdb.tgz — /imgpayld.tgz — /customks.tgz
    build=
    updated=0

    ks.cfg
    #
    # Sample scripted installation file
    #
    # Accept the VMware End User License Agreement
    vmaccepteula
    # Set the root password for the DCUI and Tech Support Mode
    rootpw Password1
    # The install media is in the CD-ROM drive
    install –firstdisk –overwritevmfs
    # Set the network to DHCP on the first network adapater
    network –bootproto=dhcp –device=vmnic0
    # A sample post-install script
    %post –interpreter=python –ignorefailure=true
    import time
    stampFile = open(‘/finished.stamp’, mode=’w’)
    stampFile.write( time.asctime() )

  4. I found a way to fix the issue I experienced with the “file” method. You don’t have to go through all the TGZ stuff. Basically in the first part on Step 4 when you edit the boot.cfg file and change the “kernelopt” variable you make the line look like this:

    kernelopt=ks=cdrom:/KS.CFG

    Then place the KS.CFG file in the root of the ISO folder and repack the ISO as you would in Step 5. Now there is a HUGE gottcha here. Notice the KS.CFG file is ALL CAPS! This is a requirement to work. The KS file must be referenced in all caps and it must be named under the root of the ISO in all caps. Without this it will not work.

    As a side note you will notice I did not add any networking information after this entry as in the examples above. Again as I am not grabbing anything from the network at build this is not required. I add my networking in the KS.CFG file and all is well.

    DanTMan63

  5. Quick question on this guys. We don’t have DHCP so we would need to specify the IP at the boot options. IN redhat’s kickstart it will actually take these options and use them to set the IP of the host.

    Do you know if this behavior would work in ESXi?

  6. Maybe its good to know that the ESX must have also a network connection otherwise youll always get the “cannot find ks.cfg” error message.

    As already mentioned, the KS.CFG must be written in capital letters.
    APPEND -c boot.cfg ks=cdrom:/KS.CFG

  7. William. Is there a size limitation of how big your customks.tgz file can be. I’ve adapted this document to include a different .tgz file to copy over. If the .tgz file is 130MB, it works. If the .tgz file is 500MB it doesn’t.

Thanks for the comment!