One of the new features of the new ESXi environment is super cool... and super useful. Specifically, the ability to deploy an ESXi host using a kickstart file and PXE!

 

"But Bill... I do not have any of the infrastructure to support this! How would I set it up!?"

 

Great question, Anonymous user, I am glad you asked. Please check out the following instructions on how to setup the environment to support this!

 

NOTE! WARNING! DISCLAIMER! ALERT! CAUTION! CUIDADO! ANMERKUNG! NOTA! 笔记! 警告!
     I know nothing about your environment. You are following these instructions at your own risk. This setup will impact DHCP! Follow these instructions at your own risk and make the appropriate adjustments. Additionally, I do not know everything about everything. So, you are going to need to rely upon your sleuthing abilities to help resolve issues. Finally, this is an official VMware document. I am posting this independantly of VMware. So, again, you are on your own. All I can verify is that the procedure, as defined in this document, worked in my specific environment.

Phew... now that the unpleasantries are overwith, please enjoy "ESXi Scripted Installation via PXE and Kickstart"

 

Overview

Deploying ESXi via PXE using a Kickstart file requires the following resources in your environment:

 

  • DHCP server

  • TFTP server

  • Web Server

  • SYSLINUX/pxeboot.0

  • Access to the ESXi installed .iso (mounted and available to allow copies of the files)

NOTE: VMware has only tested this setup using a Linux environment using SYSLINUX to provide the PXE boot functions. Using another solution may work, but is not officially supported.

 

The following environment, then, was setup to deploy the PXE functions:

 

 

  • DHCP Server and TFTP server

  • Ubuntu 8.10 server (20G HD and 1G RAM)

  • IP Address: 192.168.163.48

  • Note: if you already have DHCP running on another server, you will need to make the appropriate adjustments to your existing DHCP server. Otherwise, you will run into issues with multiple DHCP servers on your network... not a good thing.

 

The details of the Ubuntu installation are a little on the boring side, so I will assume you can get it installed on your own. The instructions will pick up after you have a properly functioning Ubuntu server on your network.

 

Installation

1 - Install required software

sudo apt-get update

sudo apt-get install inetutils-inetd syslinux tftpd-hpa dhcp3-server apache2

 

2 - Configure DHCP server

 

cd /etc/dhcp3

sudo mv dhcpd.conf dhcpd.conf.ORIG

sudo vi dhcpd.conf

 

Once inside of the file, enter the following configuration:

 

option domain-name-servers 192.168.11.130;

 

default-lease-time 86400;

max-lease-time 604800;

 

authoritative;

 

subnet 192.168.163.0 netmask 255.255.255.0 {

range 192.168.163.10 192.168.163.49;

filename "pxelinux.0";

option subnet-mask 255.255.255.0;

option broadcast-address 192.168.163.255;

option routers 192.168.163.2;

}

 

 

This will assign the machines on the network an IP address between 192.168.163.10 - 49. Additionally, the default gateway will be 192.168.163.2. The "pxelinux.0" line is very important because it instructs the PXE booting client on which file to download to begin the PXE boot process. Other PXE servers exist, so if you are using one of those, you should make the appropriate adjustments.

 

Once this configuration has been loaded, it is time to start the DHCP server:

 

/etc/init.d/dhcp3-server restart

 

 

3 - Configure the TFTP server environment

The TFTP server is what is going to be serving up the files for the client. So, the environment needs to be seeded properly.

The default location for the TFTP home is: /var/lib/tftpboot

SYSLINUX package provides a number of utilities for creating bootable Linux environments. The SYSLINUX package was installed so we can harvest one of these utilities... specifically, pxelinux.0.

pxelinux.0 is expecting some files in specific locations in the TFTP home. So:

 

  • cd /var/lib/tftpboot

  • sudo mkdir pxelinux.cfg

  • cd pxelinux.cfg

 

 

Now, it is time to actually create the pxelinux configuration file. This configuration file is read by pxelinux.0 to display options to the end user. This is massively useful if you have multiple PXE boot options. In this scenario, though, we are only concerned with providing a single option: ESXi 4.1

 

  • sudo vi default

 

 

Inside of the file, add the following:

 

DISPLAY boot.txt

 

DEFAULT ESX_4.1_install

 

LABEL ESX_4.1_install

kernel vmware/esx4.1/mboot.c32

append vmware/esx4.1/vmkboot.gz ks=http://192.168.163.48/ks.cfg --- vmware/esx4.1/vmkernel.gz --- vmware/esx4.1/sys.vgz --- vmware/esx4.1/cim.vgz --- vmware/esx4.1/ienviron.vgz --- vmware/esx4.1/install.vgz

 

DISPLAY = a text file to display to the end user. In this example, the contents of the file may not be seen.

DEFAULT = the default selection

LABEL ESX_4.1_install = This section defines which files to load to begin the installation process.

 

  • Note: the 'ks' value after 'vmkboot.gz' defines which Kickstart file to use. This will come in handy later on. You can remove this to perform the installation manually.

Now that you have defined the PXE configuration, it is time to put the pxelinux.0 file in place:

 

  • cd ..

  • sudo cp /usr/lib/syslinux/pxelinux.0 .

 

The final piece needed to setup the TFTP environment is the installation files. Recall the "LABEL ESX_4.1_install" section from above. Each file was specified using "vmware/esx4.1/vmkernel.gz" (for example). In reality, the files live on the OS at: /var/lib/tftpboot/vmware/esx4.1/vmkernel.gz. The structure needs to be created and the files put into place:

 

  • sudo mkdir -p vmware/esx4.1

 

The files are located on the ESXi installer CD/.iso. You need to get all of these files onto the server in order for them to be served up properly. If you are using a Windows desktop, you can load the ESXi installer into your CD drive and open it using Explorer. Using an SCP program (like WinSCP), copy the files to the server and then move them to the proper location:

 

  • mkdir /tmp/esxi4.1files

  • Copy the files to /tmp/esxi4.1files

  • cd /vmware/esx4.1

  • sudo cp /tmp/esxi4.1files/* .

 

 

So, now we have the files in a location where a PXE booting client can find them!

The final step is enabling the TFTP daemon to run and turning it on!

 

  • sudo vi /etc/default/tftp-hpa

  • Change "RUN_DAEMON=no" to "RUN_DAEMON=yes"

  • sudo /etc/init.d/tftp-hpa restart

 

 

4 - Configure the Kickstart file

The Kickstart file needs to be available to the PXE booting host in order to load the installation script. Common methods include NFS, FTP, HTTP/HTTPS. In this environment, we are going to be using Apache to provide that. If you already have another server, the adjustment is minimal to get the script loaded from somewhere else.

In a Ubuntu/Debian environment, the default web root is at: /var/www. So, we are going to place our Kickstart script here.

 

  • cd /var/www

 

The Kickstart script can contain a large number of configuration items. The file should be able to address any of the questions/options you may run into during the installation. The following is the Kickstart file in use for this example:

 

  1. Accept the VMware EULA

accepteula

 

  1. Set the 'root' password

rootpw supersecretpassword

 

  1. Select the partition to install ESX on

autopart --firstdisk --overwritevmfs

 

  1. Identify the location of the installation files

install url http://192.168.163.48/vmware

 

  1. Configure the initial network settings

network --bootproto=static --ip=192.168.163.200 --gateway=192.168.163.2 --nameserver=192.168.11.130 --netmask=255.255.255.0 --hostname= --addvmportgroup=0

 

You can copy the contents of the ks.cfg file and place into ks.cfg at /var/www/ks.cfg

"rootpw" = specifies the password for the 'root' user on the host. Note that this is in plaintext on the web server. So, if you are concerned about this:

  1. Use a temporary password that will be changed later

  2. Place the ks.cfg file in place right before the installation and remove when complete

  3. Configure HTTPS to ensure the password is encrypted during transmission to the server

  4. Anything else you can think of

 

  • "autopart" - specifies which partition to install ESXi onto. NOTE!!! THIS WILL DESTROY ANY DATA ON THE PARTITION. Be very careful in selecting which partition you want to use. If you are unsure, do not use this option. In the example ks.cfg file, this will take the first disk and install to it.

  • "install" - defines where you would like to pull the installation files from. In the ks.cfg example, we will be pulling them from the webserver at 192.168.163.48 (the Ubuntu host).

  • "network" - defines the initial network settings for the host.

Additionally, pre-install, post-install, and first-boot scripts can be created and added to the ks.cfg script. These allow you to use PYTHON or BusyBox (slimmed down BASH shell) to run scripts on the host (ex: esxcfg-vmnics).

 

The final piece is ensuring that the ESXi files are available to download via HTTP (per the ks.cfg file). Recall that ks.cfg states:

install url http://192.168.163.48/vmware

. In order for this to work, we need to have the ESXi install files in a folder called 'vmware' off of the root of the web server (aka: /var/www/vmware).

  • Yes, I know Apache can do some cool directory things. You can make this happen however you would like.

 

Earlier, when we were setting up the TFTP area, the contents of the ESXi installer was placed into the TFTP root. There is not too much reason to copy the same files over again. Instead, just create a symlink to the files:

 

sudo ln -s /var/lib/tftpboot/vmware/esx4.1 vmware

 

 

5 - Time to test it out!

VMware Workstation is a great tool for testing this out! Otherwise, find another host with a PXE enabled NIC. Join whatever machine you are going to use onto the network and boot to the network. The following is a couple screenshots of what the process looks like for me:

 

 

Notice the error message! purposely left a value in ks.cfg undefined. The installation process notified me of the error but that it had a resolution and would move on automagically. 

 

 

 

Note: the utility I used to create the screenshots includes a timer. The installation took 4 minutes and 2 seconds to complete! Very useful utility!

 

Closing

Ultimately, this worked out GREAT! 4:02 to install ESXi is great! With a little creativity, many of the utilities can be expanded on (PXE, ks.cfg, pre-/post-/first, etc...) and this can become a massively useful utility to handle the addition of new installs in your environment... or moving from ESX (classic) to ESXi.

 

VMware has come up with a way using fairly comodity and freely available utilities to create a very efficient and utility approach to installing ESXi.