VMware ESXi 4.1 Kickstart Scripted Deployment with UDA (PXE BOOT)

Posted on 18 Mar 2011 by Ray Heffer

If you are looking to deploy multiple ESX/ESXi servers then there are plenty of methods and tools out there, some more complex than others. There are vendor specific deployment products available such as HP Rapid Depuployment Pack (RDP) which uses Altiris, or alternatively there are free deployment tools such as ESX Deployment Appliance (EsleeDA) and Ultimate Deployment Appliance (UDA). UDA is my favorite tool for the job as it offers great flexibility such as the use of subtemplates (discussed later), and therefore this will be the basis of this article. It was created by Carl Thijssen and thanks to Mike Laverick of RTFM, it also supports ESX/ESXi deployments, and the latest build supports ESX/ESXi 4.1.

I aim to share the basics of getting the UDA configured for your environment and not delve into anything too complicated here. The best way of learning to perform some of the more complex deployments are to grasp the basics first then experiment with other functionality in your own environment for yourself.

For the purposes of this guide a number of assumptions have been made. You will have already deployed vCenter and at least one ESX/ESXi host running with some storage. If you are going to be testing this in a home lab then bear in mind that we’ll need to configure DHCP options 66 and 67, see the end of this article for details. You can do this with an existing DHCP server or use UDA as a DHCP server. Most deployments will be using an existing DHCP server.

Let’s get started…

Step 1: Download & Deploy the Ultimate Deployment Appliance

  1. Download UDA from: http://www.rtfm-ed.co.uk/vmware-content/ultimate-da/ then extract it to your hard disk.
  2. Import the appliance using your vSphere client (File > Deploy OVF Template…)
  3. Prior to powering on the appliance, add a second disk that we’ll use to store your ISO images. I’d recommend at least a 20GB disk, and use thin to conserve disk space.
  4. Power on and proceed to the next step.

Step 2: Installation and Setup

  1. Click OK at the welcome screen
  2. Enter the hostname (I recommend that you also add the hostname into your DNS server)
  3. Enter the IP address configuration
  4. Select the services you require (as a minimum I would just leave TFTP, HTTP and SSH selected)
  5. Enter the root password.
  6. Select Yes to apply the changes.

Once it has finished you will then be able to access your UDA from a web browser. Log in with admin and the password you set during the setup.

Step 3: UDA Configuration

When you first log into the appliance you will be presented with a welcome page. The first thing to configure is the additional disk space we need to store our ISO images. If you haven’t added a second hard disk, then shutdown the UDA (System > Shutdown), then add the additional disk and power on.

UDA has two partitions; systemlv and localv. ISO images are stored on the localv partition, so we’ll extend that.

  1. Go to System and click Diskspace.
  2. Select localv and then click Extend.
  3. Select the device and then click Apply.

It may take a little while depending on how large the new disk is, but once that is complete we’ll load the ISO image for ESXi 4.1 Update 1 on to the UDA.

  1. Go to System and click Upload.
  2. Click Choose File, select your ISO then click Upload.

It will store the ISO on the localv partition in /local.

Step 4: Add an OS & Deployment Template for ESXi 4.1

Now for the exciting bit. We’ll add our OS (ESXi) and template for deployment which will also create the basics of our Kickstart script which we’ll add to later. The OS section allows us to tie an ISO image to a Flava name, in this case we’ll call it ESXi41. I’d recommend using a better naming convention for your environment though.

  1. Go to OS and click New.
  2. Enter ESXi41 for the Flava Name.
  3. From the dropdown, choose VMware ESXi 4.1 Installable and click Next.
  4. Select the ESXi 4.1 ISO you uploaded and then click Finish.

Next, the template which contains our Kickstart script. The template also contains a subtemplate which allows us to define our own variables, such as IP address and hostnames for each ESXi host we are deploying. This is why I like using UDA so much, because it avoids having to create a separate Kickstart script for each ESXi host.

  1. Go to Templates and click New.
  2. Enter a Template Name. For example: esxi-build and give it a meaninful description.
  3. From the Operating System dropdown choose VMware ESXi 4.1 Installable and click Next.
  4. From the Flava dropdown choose your OS (Flava), ESXi41 and click Next then Finish.

The next stage is to perform the configuration of our Kickstart script and subtemplate. Go to Templates, select your template (esxi-build) and click Configure. You’ll see three tabs here; General, Subtemplates and Advanced. Click on Advanced. This is where our Kickstart script lives, and you’ll see it contains a basic configuration.

Here is a breakdown with explanations for each line:

Accept the VMware EULA - The script will fail without this. accepteula

Set the root password using MD5 crypt rootpw secret

Auto partition the disk autopart --firstdisk --overwritevmfs

Location of the install media install url http://[UDA_IPADDR]/[OS]/[FLAVOR]

Configure IP address and hostname --addvmportgroup=0 will disable creation of the VM Network portgroup network --bootproto=static --ip= --gateway= --nameserver= --netmask= --hostname=esx41i --addvmportgroup=0

Reboot the host when the installation is complete reboot

The first thing we need to change is the root password which by default is set to secret and is in plain text. We can use a crypted MD5 password here using rootpw –iscrypted followed by the crypt.

  1. Log into your UDA with PuTTY (SSH) and log in as root (same password you set during the initial setup).
  2. Type grub-md5-crypt
  3. Enter your password and it’ll generate an MD5 string for you.
  4. Go back to the Advanced view in the web interface and change the rootpw line to (replacing the crypt with the one you generated):

rootpw --iscrypted $1$3vkd233f/wksSo$fhniM3fdcV6hr0

Now we need to change the network configuration to use the appropriate IP address, gateway, subnet mask and hostname. We could just replace the default IP address configuration here, but a better method is to use variables which we can set in subtemplates. Variables are set inside square brackets, such as [IPADDR], [FQDN] and so on. The variable names are up to you. Change the network configuration, replacing the IP address and hostname with variables as follows:

network --bootproto=static --ip=[IPADDR] --gateway= --nameserver= --netmask= --hostname=[FQDN] --addvmportgroup=0

Select Subtemplates and click on Edit. The first line we will create contains the word SUBTEMPLATE then the variable names that we want to use (separated by semi-colons). Subsequent lines contain the values for each host. See my example below:


You’ll notice in my example I’ve added a VMkernel IP address that in the case of our ESXi deployment we will use for VMotion.

Click on the Advanced tab. After the network configuration line we need to add the following command which allows us to run our esxcfg commands on first boot:

%firstboot --unsupported --interpreter=busybox

Now add the following commands to the Kickstart script (Advanced), which will add a VMotion portgroup and IP address. You can leave the # comments in if you wish:

Setup VMotion portgroup on vSwitch0 esxcfg-vswitch -A VMotion vSwitch0

Setup VMotion IP address esxcfg-vmknic -a VMotion -i [VMKIPADDR] -n

Wait for previous command to finish before enabling VMotion sleep 10

Enable VMotion (ESX uses vmware-vim-cmd and ESXi is vim-cmd) vim-cmd hostsvc/vmotion/vnic_set vmk1 vim-cmd hostsvc/net/refresh

Notice in the vim-cmd command above that it sets VMotion on vmk1. vmk0 will be the management IP address used in the network command at the top of our script. This is fairly straightforward to work out, but if anyone knows of a better method then feel free to comment!

Finally click on Save.

The Deployment

Now we have the UDA configured and ready to roll with our ESXi installation all we have to do now is PXE boot our hosts and providing you have configured DHCP options 66 & 67 (see the end of this article) you should be presented with the UDA menu (see first screenshot).

The rest is easy, just select the host from the menu (we set this in SUBTEMPLATE) and it will install and configure ESXi with no user intervention. Using a scripted installation can be very powerful and a lot more can be configured than I’ve included here. Even if you don’t have mass ESXi deployments, this is a good way of ensuring that your ESXi hosts maintain your standard build. If you have an Enterprise Plus license then you can also use Host Profiles.

Kickstart script

rootpw --iscrypted $1$3vkd233f/wksSo$fhniM3fdcV6hr0
autopart --firstdisk --overwritevmfs
install url http://[UDA_IPADDR]/[OS]/[FLAVOR]
network --bootproto=static --ip=[IPADDR] --gateway= --nameserver= --netmask= --hostname=[FQDN] --addvmportgroup=0


# Configure additional commands at first boot.
%firstboot --unsupported --interpreter=busybox

# Setup VMotion portgroup on vSwitch0
esxcfg-vswitch -A VMotion vSwitch0

# Setup VMotion IP address
esxcfg-vmknic -a VMotion -i [VMKIPADDR] -n

# Wait for previous command to finish before enabling VMotion
sleep 10

# Enable VMotion (ESX uses vmware-vim-cmd and ESXi is vim-cmd)
vim-cmd hostsvc/vmotion/vnic_set vmk1
vim-cmd hostsvc/net/refresh



Configuring DHCP Options

  1. Set option 66 to the IP address of your UDA
  2. Set option 67 to pxelinux.0