Setting up vSphere ESXi 4.1 Scripted Installation

Scripted installation is  a new feature for ESXi which is introduced with the release of vSphere 4.1. In this article I’m describing the setup of my home lab in which I use this new feature. Please be advised that this article assumes some basic understanding of Windows and ESX and gives you some guidelines which you can alter for your own specific needs.

There are a few ingredients we need to get this ESXi Scripted Installation to work:

  • ESXi Source Repository (HTTP in this article)
  • PXELinux
  • TFTP Server
  • DHCP Server

 

ESXi Source Repository

1. Install IIS on the Windows Server that will be serving the HTTP repository.
2. Create a ESXi directory in the wwwroot (for example d:\Inetpub\wwwroot\ESXi)
3. Copy all the files from the ESXi ISO to the \ESXi folder (do not copy the .ISO itself but only the files in the .ISO)
4. Start the IIS Manager (Start, All Programs, Administrative Tools, Internet Information Services IIS Manager

 

5. Right-click the “Default Website” and select “Properties”
6. Click on the “HTTP Headers”-tab and select “MIME Types”
7. Click “New” and Add:

  • Extension: *
  • MIME Type: All

 

 

8. Now Click OK, OK, OK and exit the IIS Manager

 

PXELinux

1. Create a PXEboot directory (e.g. d:\PXEboot)
2. Create a subdirectory called ESXi (e.g. d:\PXEboot\ESXi)
3. Download and place pxelinux.0 in the d:\PXEboot
4. Copy the 8 files listed below from the ESXi ISO to the d:\PXEboot directory

  • cim.vgz
  • ienviron.vgz
  • install.vgz
  • mboot.c32
  • menu.c32
  • sys.vgz
  • vmkboot.gz
  • vmkernel.gz

 

5. Create the directory d:\PXEboot\pxelinux.cfg
6. Copy the isolinux.cfg from the ESXi ISO to d:\PXEboot\pxelinux.cfg (please note that this is a directory)
7. Open the d:\PXEboot\pxelinux.cfg\isolinux.cfg with Notepad++ or VIM (or any other tool that doesn’t cause the line feed/carriage return problem with Linux files) and make the following adjustments:

  • Add the IIS directory name in front of all 8 file references (so in this case “ESXi/”)
  • Add “ks=http://x.x.x.x/ESXi/ks.cfg” (if you want an interactive installation, skip this line)
  • Additionally more bootstrap commands can be added as part of the “ks=…” line, see the ESXi Installable and vCenter Server Setup Guide (page 41)

 

 

8. Save the file
9. Rename the file to default (make sure it has got no file extension)

Alternately you can also use the following naming convention which is described in the ESXi Installable and vCenter Server Setup Guide (page 33)

Filename for the PXE Configuration File
For the filename of the PXE configuration file, choose one of the following:
– 01-mac_address_of_target_ESXi_host. For example, 01-23-45-67-89-0a-bc
– The target ESXi host IP address in hexadecimal notation.
– default

The initial boot file, pxelinux.0 (or gpxelinux.0) tries to load a PXE configuration file. It tries with the MAC address of the target ESXi host, prefixed with its ARP type code (01 for Ethernet). If that fails, it tries with the hexadecimal notation of target ESXi system IP address. Ultimately, it tries to load a file named default.

10. Create the d:\Inetpub\wwwroot\ESXi\ks.cfg file (this is the Kickstart Script which contains the installation details)
11. Open the ks.cfg with with Notepad++ or VIM and add the following lines to it (which need to be altered for your specific needs):

 

All the available options can be found in the  ESXi Installable and vCenter Server Setup Guide (page 41)

  

TFTP Server

Now it’s time to get the TFTP Server running. You can use your favorite TFTP program or follow the instructions on this site

DHCP Server

The last step is to get the DHCP server installed and configured. In my home environment I’ve got an Internet Router which acts as DHCP server for my internal network. Since I prefer to use this DHCP server which isn’t capable of DHCP Options I decided to create a secondary DHCP server based on a Windows 2003 Server which is capable of DHCP options.

Please see the overview below to get an understanding of my setup.

I connected this secondary DHCP server to an isolated network within VMware Workstation (vmnet2). Consequently this means that whenever I want to deploy an ESXi Host I first need to attach it to vmnet2 and after deployment I need to change it to the bridged network.

1. Install the DHCP Service.
2. Create a DHCP Scope and active it.
3. Right-click Scope Options and select “Configure Options”
4. Scroll down the Available Options and configure

  • 066 Boot Server Host Name with your DHCP Server IP address
  • 067 Bootfile Name with pxelinux.0 (we placed this file earlier on in the d:\PXEboot directory)

  

 

 

Test the Scripted Installation

It’s now time to test the scripted environment by starting your Target ESXi Host, if PXE works it will show the screen below where it will start downloading the source files.

 

 

Current Scripted Installation Limitations

Please note the current limitations of Scripted Installations:

  • Scripted Install is available only with the Installer version of ESXi and is not available in the Embedded version of ESXi
  • You cannot use Scripted Install to install ESXi Installable to a USB device
  • As outlined in this VMware KB article.

    Leave a comment

    33 Comments

    1. Very nice article! Will try this setup in my test lab 🙂

    2. Nice post Kenneth. If you wanted to you could use the same Virtual Appliance that I use to deploy ESXi, it has DHCP, TFTP and PXE all on the same app.

      Check it out here: http://www.simonlong.co.uk/blog/2010/02/23/a-simple-vmware-esxi-rapid-deployment-system-part-1/

      Simon

    3. Thanks for the link dude 🙂

    4. Great post, was going to be trying this myself soon.

    5. WAUW!!!! Excellent post – thank you very much!

    6. Excellent Post and very useful.

    7. great walkthrough and I almost have it working. I’m trying to do this all on Windows Server 2008 R2 and not server 2003.

      Windows Server 2008 R2 will not allow you to create the * All mime type. It asks for a / tag.

      “5. Create the directory d:\PXEboot\pxelinux.cfg”. I can create a new folder called pxelinux.cfg, but I don’t know how I can “7. Open the d:\PXEboot\pxelinux.cfg with Notepad++” because I can’t open a folder with Notepad++.

      As for the TFTP server setup, you should probably note that the TFTP server should be pointed at the directory D:\PXEboot\pxelinux.cfg

      At this moment, I’m failing. I’m getting “Trying to load: pxelinx.cfg/default and unable to locate configuration file.

      going to try and continue working on it to see what comes of it.

    8. ok nevermind. i got it all working. Here is where I messed up:

      4. Copy the 8 files listed below from the ESXi ISO to the d:\PXEboot directory
      All of these files should be placed in the ESXi folder inside the PXEboot directory.

      the TFTP server should be pointing to D:\PXEboot

      Also, if you’re on Windows Server 2008, in the features view of IIS, don’t forget to Enable the Directory Browsing service.

    9. Hi Kendrick,

      Does it work with Windows 2008 when you add a MIME type: ‘application/octet-stream’ (with the quotes)?
      Secondly, you are totally right, step 7 needs to be: 7. Open the d:\PXEboot\pxelinux.cfg\isolinux.cfg (I’ve corrected this in the post, thanks for pointing that out)

      Concerning the tftp, yeah this needs to be pointed to the tftp directory (in this example d:\pxeboot)

      Kenneth

    10. Please note Kendrick’s note: Also, if you’re on Windows Server 2008, in the features view of IIS, don’t forget to Enable the Directory Browsing service.
      Since this isn’t the case on Windows 2003

    11. ok last one i swear.
      i figured out the mime type for 2008 R2

      Click your ESXi site under default Web Site
      Under Feature View, right click MIME Types and Open Feature
      Add:
      File name extension: .cfg
      MIME Type: text/plain

    12. Eric van der Meer

       /  July 22, 2010

      Thanks for sharing this tutorial with us Kenneth!

    13. Dennis Agterberg

       /  July 22, 2010

      Nice article Kenneth. I can remove this one (no automatic deployment) from the list of ESXi disadvantages for the environment I’m currently working on.

    14. Eric

       /  July 22, 2010

      Nice article. Any chance you’ll be adding any examples for using the %pre, %post and %firstboot sections of the ks.cfg file? A lot of people leveraged %pre and %post pretty heavily for scripted ESX installations. I’m looking to port my ks.cfg into a new one for ESXi 4.1.

    15. Justin

       /  August 4, 2010

      No worky on ESXi 4.1
      Try to install to USB on my PowerEdge T710 and it gets around 50% and fails saying there must be bad sectors. Tried with a brand new USB stick and same thing. Downloading the Dell customized image and see if that changes anything.

    16. Nice Article. Do you have a tutorial (or can you create one) for Apache (on Linux), TFTP, DHCP on Linux?

    17. Hi,

      No I haven’t got a tutorial on the Linux stuff. Basically the most important message in this article is setting up the ESXi part and not specifically the TFTP and DHCP stuff.

      Kenneth

    18. here is a way to configure your PXE environment using linux for tftp…

      http://www.vmwareadmins.com/index.php/articles/92-automated-esx-host-builds-using-pxe.html

    19. Great work Kenneth! I believe the USB problem stated earlier might be a know issue: http://www.vmware.com/support/vsphere4/doc/vsp_41_new_feat.html (scripted install to USB is not supported).

      Also, is there a way to do this to a diskless “state-less” scripted installation? I could piece the 2 methods together (script install a host, then port over the binaries and boot to PXE stateless after the fact.. rinse & repeat) but it has a manual element to is. I am doing testing on both PXE script install and PXE boot diskless and wondered what your thoughts were on combining them. I will keep you updated to any useful results.

    20. Hi Rico,

      Thanks. First of all, yeah there is definitely a way to do a stateless install of ESX (in which ESX is only running from memory).
      Please take a look at this appliance that is capable of doing that and is capable of automatically add the deployed, stateless, ESXi host to the vCenter inventory
      http://labs.vmware.com/flings/vmware-auto-deploy

      Good luck!
      Kenneth

    21. For IIS6.1 (Windows Server 2008 R2), the mime extension above doesn’t work. Add * as application/octet-stream instead.

    22. Very good post. A sidenote, you have to use the same version of pxelinux as the isolinux-version of esxi4.1u1 is using. Currently ver 3.63. I started out with version 4.04 and that did not work.

    23. Ronan

       /  September 30, 2011

      Hi,

      is there a way I can include a 8mb block size for pre-presented SAN storage in the kickstart file? All the storage presentation are all ready in place on the enclosure so when the esx builds occur i want them to already have the mac block size set.

      Thanks

      Ro,

    24. Check out how you can do for ESXi 5.0 now at vcp5.wordpress.com. Thanks your article inspired me to do one for ESXi5.0. Comments welcomed

    1. Migrar ou não migrar para o vSphere 4.1, eis a questão ? | Coruja de TI
    2. get-admin :: ESXi: Kickstart installs using CD-ROM or USB media
    3. Automating ESXi Deployment with the UDA 2 appliance and bash script | VirtualKenneth's Blog
    4. Objective 9.2 – Plan and Execute Scripted Installations
    5. ESXi 4.1 Unattended Installation an Overview « Adventures in a Virtual World
    6. ESXi 4.1 PXE install « Jbotsford's Blog
    7. Automated Cisco UCS Server Provisioning part 2 (the meat!) @ IT is what IT is
    8. ESXi: Kickstart installs using CD-ROM or USB media - The Practical Administrator

    Leave a Reply

    %d bloggers like this: