29
Creating an Automated ESXi Installer How-To Guide A how-to guide to create an automated installation of VMware ESXi from a PXE deployment server or from a USB stick. ESXi David Convery, VCDX www.DailyHypervisor.com Version 1.0 - 24 January 2010

ESXi4 Unattended Install

Embed Size (px)

Citation preview

Page 1: ESXi4 Unattended Install

Creating an Automated ESXi Installer How-To Guide A how-to guide to create an automated installation of VMware ESXi from a PXE deployment server or from a USB stick.

ESXi

David Convery, VCDX www.DailyHypervisor.com

Version 1.0 - 24 January 2010

Page 2: ESXi4 Unattended Install

Creating an Automated ESXi Installer

David Convery, VCDX Pg 2 of 29 www.dailyhypervisor.com/

Table of Contents Summary ....................................................................................................................................................... 3

Requirements ................................................................................................................................................ 3

Preparing the Ultimate Deployment Appliance ............................................................................................ 4

Initial Setup of the UDA ................................................................................................................................ 5

Adding Disk Space to the UDA ...................................................................................................................... 8

Uploading CD Images and Creating Templates in the UDA ........................................................................ 11

Extracting the ESXi Installer Files ................................................................................................................ 17

Editing the Installation Python Scripts ........................................................................................................ 19

Editing the PXE Boot Configuration File ...................................................................................................... 23

Testing the Automated Installer ................................................................................................................. 24

Creating a Bootable USB Installer ............................................................................................................... 25

Creating a Bootable USB Stick ................................................................................................................. 25

Creating a Bootable CD Image ................................................................................................................ 27

About the Author ........................................................................................................................................ 29

David Convery ......................................................................................................................................... 29

Creating an Automated ESXi Installer by David Convery is licensed under a Creative Commons

Attribution-Noncommercial-Share Alike 3.0 United States License.

Page 3: ESXi4 Unattended Install

Creating an Automated ESXi Installer

David Convery, VCDX Pg 3 of 29 www.dailyhypervisor.com/

Summary The ability to use an automated, unattended installation routine for a hypervisor is necessary whenever

it is deployed to multiple systems or is done frequently. Automated installations help avoid a

misconfiguration caused by human error, which become common when repetitive tasks are performed.

Because the “traditional” version of VMware ESX Server contains a Red Hat Linux based console

operating system, we have been able to leverage kickstart scripts for automated installation. With the

ESXi hypervisor, much of this functionality is not available because of the smaller footprint.

This document explains how to set up ESXi with little intervention. The modifications explained here can

be used to deploy ESXi using a PXE server. In our examples we will use the Ultimate Deployment

Appliance, but these methods will also transfer to such commercial packages as HP Rapid Deployment

Pack, Altiris, or even a home grown PXE server. The modifications can also be used for deploying ESXi

using a USB stick or a customized CD.

Requirements ESXi Server Installable The ESXi CD image can be downloaded from the VMware site, however

using a systems management and monitoring server, such as HP SIM or Dell OpenManage is

highly recommended. Since there are usually vendor specific CIM providers to enhance the

monitoring capabilities, some vendors will provide a customized CD image with the CIM

providers. These additional CIM providers will also allow for more information to be displayed in

the hardware sections of the vSphere Client. A search for “ESXi” on the HP and Dell sites

produced links to the latest customized images.

Deployment Server A deployment server will allow for a controlled, automated installation of

the ESXi Server software. The ability to handle multiple operating system installations is also

desired. The ability to provide PXE and DHCP services is required as well. Most times, the

deployment server will be running PXE services and TFTP. The DHCP services may be running on

a different server in an enterprise. This document does not explain how to set up a separate

DHCP server. For this document, we will be using the Ultimate Deployment Appliance (UDA)

version 2.0 (beta).

Virtualization Software The UDA runs as a “Virtual Appliance,” which is a pre-configured virtual

machine. It will run under VMware ESXi (available as a free or licensed instance), VMware

Workstation (available for purchase), VMware Player (free) or VMware Server (free). In this

document, VMware Workstation is used.

Optional software Although no additional software is required when using the UDA, you will

need additional software if you plan on using a USB stick or if you plan on creating a customized

CD image:

o VMware Converter If you plan on using ESXi or Server to host the UDA, VMware

Converter can be used to import the virtual appliance.

Page 4: ESXi4 Unattended Install

Creating an Automated ESXi Installer

David Convery, VCDX Pg 4 of 29 www.dailyhypervisor.com/

o Syslinux In order to make a bootable USB stick, you will need the syslinux utility. This

utility is available for Linux and Windows. The UDA does not include it. As an alternative,

you can use the unetbootin utility.

o CD Imaging and Burning In order to create a bootable CD image, you will need software

to create the CD image (mkisofs) and then software to burn the image to the CD media

(cdrecord). The cdrtools project includes versions for Linux and Windows. Most Debian

versions of Linux, such as Ubuntu, come with the cdrkit, which uses genisoimage for

imaging and wodim for burning.

o Linux Desktop If you look at the contents of the ESXi CDs using Windows (Windows 7

was used), you may see all of the files listed using all capital letters. Since the ESXi

software is based on Linux, all file operations are case sensitive and expect the files to

be all lower case. This may cause errors when attempting to create the automated

installer. For this reason, a Linux desktop is recommended. For most of the operations,

UDS may be used. The only missing software on the UDA is syslinux. For a feature rich

Linux desktop, Ubuntu is recommended. A few pre-configured Ubuntu Desktop virtual

appliances are also available.

Preparing the Ultimate Deployment Appliance The UDA is available for download as a Virtual Appliance in a zip file. You will need to download it and

unzip it to a directory. For Workstation or Player, just open the vmx file. For ESXi or Server, you can use

VMware Converter to import it.

Since the UDA is configured with a minimal size, you will need to create additional disk space for storage

of the ESXi files and, optionally, CD images and files for other operating systems. In this document, we

will create new virtual disks. You can also use NFS or CIFS shares on other servers to host these files. The

UDA is set up with Logical Volume Manager (LVM) and a nice front-end GUI, so adding disk space is easy.

There are two pre configured logical volumes on the UDA. The “systemlv” is the root file system and

hosts the OS. It also contains the space for the PXE boot files. The “locallv” is a space that can be shared

out using NFS or SMB (The Linux version of CIFS). It contains the space for uploading files and hosting

the CD images. These volumes should both be made larger so that we do not run out of space.

There is also an easy to use set up wizard that runs on first boot of the system. This is where you set up

the hostname, IP Address, etc. You will also be given options to enable services, such as PXE, DHCP, NFS

and SMB.

CAUTION!! In this document, we will be setting up a DHCP server. Serious problems can be introduced

into a production network by enabling this. If the network already has DCHP services, the UDA should be

placed in an isolated network or the existing DHCP service should be configured to point to the UDA for

PXE services. Instructions for setting up a separate DHCP server can be found on the pxelinux wiki page.

Page 5: ESXi4 Unattended Install

Creating an Automated ESXi Installer

David Convery, VCDX Pg 5 of 29 www.dailyhypervisor.com/

Initial Setup of the UDA

Once you have opened the virtual appliance, add two disks. The sizes will depend on the anticipated images and files to be hosted. In this case, we are going to allocate 20GB to the system volume and 10GB to the local volume. We are also using “thin provisioning” so only the disk space required by the files will be used. After adding the necessary disks, power on the VM.

At the welcome screen, hit <ENTER>.

Type a short hostname. Use lower case! Hit <ENTER>.

Page 6: ESXi4 Unattended Install

Creating an Automated ESXi Installer

David Convery, VCDX Pg 6 of 29 www.dailyhypervisor.com/

Use the arrow keys to navigate. Type the IP address, subnet mask and gateway information. Hit <ENTER>.

Use the arrow keys to navigate and <SPACE> to select. In our case we are enabling all services. Hit <ENTER>.

Use the arrow keys to navigate. Enter the IP address pool for the DHCP services. Hit <ENTER>.

The root and admin accounts use the same password. Type the password and hit <ENTER>.

Page 7: ESXi4 Unattended Install

Creating an Automated ESXi Installer

David Convery, VCDX Pg 7 of 29 www.dailyhypervisor.com/

Retype the password. Hit <ENTER>.

Confirm the selections and hit <ENTER>.

When the installation completes, hit <ENTER>. A reboot is not required.

CONGRATULATIONS! You have installed your Ultimate Deployment Appliance. Easy huh?

Page 8: ESXi4 Unattended Install

Creating an Automated ESXi Installer

David Convery, VCDX Pg 8 of 29 www.dailyhypervisor.com/

Adding Disk Space to the UDA The UDA uses a nice web based GUI for configuration. Since it uses LVM for disk management, adding

space is easy. Simply add disks to the VM and use the GUI to extend the volumes.

Using your browser, enter the IP address for the UDA. You will be prompted to log in. Use admin and the password you entered during setup.

At the welcome screen, click on the System link.

At the System screen, click on the Diskspace button.

Page 9: ESXi4 Unattended Install

Creating an Automated ESXi Installer

David Convery, VCDX Pg 9 of 29 www.dailyhypervisor.com/

In the Local Storage screen, select the systemlv volume and then click on the Extend button.

Select a disk to use and click the Apply button.

It will take a few minutes for the volume to be extended.

Page 10: ESXi4 Unattended Install

Creating an Automated ESXi Installer

David Convery, VCDX Pg 10 of 29 www.dailyhypervisor.com/

When completed, click the System link and repeat the process for the LVM and locallv volume.

Now your UDA has sufficient space for CD Images and PXE boot files.

Page 11: ESXi4 Unattended Install

Creating an Automated ESXi Installer

David Convery, VCDX Pg 11 of 29 www.dailyhypervisor.com/

Uploading CD Images and Creating Templates in the UDA You will need to get the contents of the ESXi CD image on to the UDA in order to serve up the

automated installation. Since you already have an image, it can be copied to the UDA and the files can

be extracted for the PXE boot installation. Since we need to modify some files, the end result will be to

host the files on the PXE server. In the UDA, a template is used to point to these files. For this example,

we will put those files in a directory named “esxi4u1.”

Click on the System link.

In the System screen, click on the Upload button.

Page 12: ESXi4 Unattended Install

Creating an Automated ESXi Installer

David Convery, VCDX Pg 12 of 29 www.dailyhypervisor.com/

In the Upload screen, click on the Browse button.

In the File Upload screen, browse and select the CD image you wish to upload.

Back in the Upload screen, click on the Upload button.

Page 13: ESXi4 Unattended Install

Creating an Automated ESXi Installer

David Convery, VCDX Pg 13 of 29 www.dailyhypervisor.com/

The file will be uploaded.

Once the upload is completed, click on the Templates link.

In the Templates screen, click on the New button.

Page 14: ESXi4 Unattended Install

Creating an Automated ESXi Installer

David Convery, VCDX Pg 14 of 29 www.dailyhypervisor.com/

Type in a Template Name and select VMware ESXi 4 Installable. Click on the Next button.

In the Confirm screen click the Finish button.

Click on the Templates link.

Page 15: ESXi4 Unattended Install

Creating an Automated ESXi Installer

David Convery, VCDX Pg 15 of 29 www.dailyhypervisor.com/

In the Templates screen, select the template that you just created and click on the Configure button.

In the Configure screen, click on the Advanced link.

Notice that there are several boot line entries that all begin with “[OS].[FLAVOR].”

Page 16: ESXi4 Unattended Install

Creating an Automated ESXi Installer

David Convery, VCDX Pg 16 of 29 www.dailyhypervisor.com/

Replace all instances of “[OS].[FLAVOR].” with “esxi4u1” – without the quotes. When completed, click on the Save button.

At this point, the framework has been set for PXE booting. Now we need to get the files where they

need to go.

Page 17: ESXi4 Unattended Install

Creating an Automated ESXi Installer

David Convery, VCDX Pg 17 of 29 www.dailyhypervisor.com/

Extracting the ESXi Installer Files Once you have copied the CD image to the UDA and have created a template pointing to the “esxi4u1”

directory, you will need to create that directory, mount the CD image and copy the files to the new

directory

Open a console to the UDA and log in as root with the password you entered during setup.

NOTE: The following commands are case sensitive.

First, we need to create the directory for the ESXi installer files. Type: mkdir /var/public/tftproot/esxi4u1

And hit <ENTER>.

In order to mount the CD image, we need to create a “mount point.” This is a directory that will act as a placeholder for the files. Type: mkdir /mnt/esxi

And hit <ENTER>.

Now that you have your directories created, you will need to mount the CD image. In the command listed below, substitute CD_Image_Name with the name of the CD image you will be using. Type: mount –o loop /var/public/smbmount/local/CD_Image_Name /mnt/esxi

And hit <ENTER>.

Page 18: ESXi4 Unattended Install

Creating an Automated ESXi Installer

David Convery, VCDX Pg 18 of 29 www.dailyhypervisor.com/

Next, copy the contents of the CD image to the template directory. Type: cp –v /mnt/esxi/* /var/public/tftproot/esxi4u1

And hit <ENTER>.

At this point, you have a set of useable PXE files for installing ESXi. Using them as is will result in a

prompted installation.

Page 19: ESXi4 Unattended Install

Creating an Automated ESXi Installer

David Convery, VCDX Pg 19 of 29 www.dailyhypervisor.com/

Editing the Installation Python Scripts In order to automate as much as possible, we will need to edit some files to reduce the prompts. On the

CD image, there is a compressed file – install.tgz – that contains the Python scripts that create the

installation prompts. A couple of these files can be edited to limit the number of prompts for the

installation.

The main file is: /usr/lib/vmware/installer/ThinESXInstall.py

It contains the call out for the installation steps. The file contains the following lines:

Steps = [ WelcomeStep, LicenseStep, TargetSelectionStep, ConfirmStep, \ WriteStep, PostConfigStep, CompleteStep, RebootStep ]

The WelcomeStep and LicenseStep can be removed, since they are not necessary for the

installation.

The TargetSelectionStep is used to select where to install the hypervisor. This step will remain in

this example.

The ConfirmStep can also be removed.

The WriteStep and PostConfigStep are both required and should not be removed.

The CompleteStep is optional. This step basically informs you that the installation is complete

and to hit <ENTER> to reboot. It can be removed if you are OK with the server rebooting

automatically on completion. If your server is set up properly, it will PXE boot until the OS is

installed and then it will boot to the local storage.

The RebootStep is required to cause the server to reboot at the end.

Once edited, the lines will look like this for PXE boot:

Steps = [TargetSelectionStep, WriteStep, PostConfigStep, RebootStep ]

If you plan on using a USB stick or CD based installation, edit it to look like this:

Steps = [TargetSelectionStep, WriteStep, PostConfigStep, CompleteStep, RebootStep ]

The steps called out in this script refer to steps located in the following file:

/usr/lib/vmware/installer/ThinESX/ThinESXInstallSteps.py

If you understand Python scripting, you can edit this file to change the way the steps operate if you

wish.

Page 20: ESXi4 Unattended Install

Creating an Automated ESXi Installer

David Convery, VCDX Pg 20 of 29 www.dailyhypervisor.com/

We will first need to create a temporary directory that will be used to stage the files contained in the install.tgz compressed archive. Type: mkdir /tmp/install

And hit <ENTER>.

Change to the new directory. Type: cd /tmp/install

And hit <ENTER>.

Now, we need to uncompress the install.tgz archive. Type: tar –zxvf /var/public/tftproot/esxi4u1/install.tgz

And hit <ENTER>.

Once you have extracted the files, you can list the contents. Type: ls

And hit <ENTER>.

Now we want to change to the directory that holds the Python script to be edited. Type: cd usr/lib/vmware/installer

And hit <ENTER>.

Page 21: ESXi4 Unattended Install

Creating an Automated ESXi Installer

David Convery, VCDX Pg 21 of 29 www.dailyhypervisor.com/

You will need to change the file permissions so that you can

write to the file. If you type ls –l you will see that the files do

not have write permissions set. The write permission will need

to be added using the chmod command.

Type: chmod +w ThinESXInstall.py

Then hit <ENTER>. You can confirm the write permission is set by typing the ls –l command.

Now that you can write to the file, you will need to edit it. In this example, we will use vi but you can also use nano if you wish.

Look for the following lines:

Steps = [ WelcomeStep, LicenseStep, TargetSelectionStep, ConfirmStep, \ WriteStep, PostConfigStep, CompleteStep, RebootStep ]

Change it to look like this:

Steps = [TargetSelectionStep, WriteStep, PostConfigStep, RebootStep ]

HINT: you can use dw to cut a word and then p to paste it.

When finished, use :wq to write and quit.

Page 22: ESXi4 Unattended Install

Creating an Automated ESXi Installer

David Convery, VCDX Pg 22 of 29 www.dailyhypervisor.com/

Change back to the /tmp/install directory. Type: cd /tmp/installer

Then hit <ENTER>.

Now, we need to create a new compress archive file. Type: tar –czvf ../install.tgz *

Then hit <ENTER>.

Once completed, change up to the /tmp directory. Type: cd ..

Then hit <ENTER>.

Copy the new archive file to the PXE template directory. Type: cp install.tgz /var/public/tftproot/esxi4u1

Then hit <ENTER>. Type y then <ENTER> to confirm the overwrite.

At this point, you have an automated installer for ESXi.

Page 23: ESXi4 Unattended Install

Creating an Automated ESXi Installer

David Convery, VCDX Pg 23 of 29 www.dailyhypervisor.com/

Editing the PXE Boot Configuration File We will also edit the PXE boot configuration file so that the ESXi installer is automatically selected. By

default, a menu with boot options is presented with no timeout. In our example, we will only have one

PXE boot template, so we want to have it automatically boot. Obviously, if you wish to use the UDA for

deployment of more than one OS, you can skip the steps that edit this file.

Change to the directory containing the PXE configuration file. Type: cd /var/public/tftproot/pxelinux.cfg

Then hit <ENTER>.

Now, we need to edit the file named default and make some changes. In this example, we will use vi but you can also use nano for this.

Look for the following at the end of the file: label ESXi4U1_Unattended menu label ESXi4U1_Unattended # no password kernel vesamenu.c32 append pxelinux.cfg/templates/ESXi4U1_Unattended.menu

Edit the section to add the menu default and the timeout 100 lines: label ESXi4U1_Unattended menu label ESXi4U1_Unattended menu default timeout 100 # no password kernel vesamenu.c32 append pxelinux.cfg/templates/ESXi4U1_Unattended.menu

And then save the file.

Now, you have an automated ESXi installer!

Page 24: ESXi4 Unattended Install

Creating an Automated ESXi Installer

David Convery, VCDX Pg 24 of 29 www.dailyhypervisor.com/

Testing the Automated Installer Once you have set this up, you will want to test it. You can do this by creating a VM or using a physical

server. If you use a physical server, erase the disk first so that it will PXE boot. You may also need to

configure the BIOS to allow for PXE booting.

If the system is configured properly, it will PXE boot over the

network.

The UDA menu will appear for 10 seconds. Just hit <ENTER> if

you want to speed things up.

The ESXi installer files will load into memory.

You will be prompted to select a disk to install the hypervisor.

ESXi will be installed.

Page 25: ESXi4 Unattended Install

Creating an Automated ESXi Installer

David Convery, VCDX Pg 25 of 29 www.dailyhypervisor.com/

The system will reboot and load the newly installed

hypervisor!

Creating a Bootable USB Installer Sometimes, the use of a PXE based installation will not be allowed for whatever reason. The files created

and edited in the steps above can be copied to a bootable USB stick or used to create a bootable CD

image.

Creating a Bootable USB Stick

Before copying the files to a USB stick, you will need to make it bootable. This will be done using the

syslinux utility. The syslinux utility comes installed on most Linux distributions. It can be installed on a

Windows system or on the UDA. The proper file can be downloaded from

http://www.kernel.org/pub/linux/utils/boot/syslinux/

Insert the USB stick into the system that will be used to make

it bootable. If a mount is not displayed in a Linux system, you

can use the fdisk –l command to display the disk information.

In this example, it is located on /dev/sdb1 (Notice the FAT16)

On a Windows system, it will be a drive letter, such as E:

In Linux you will use the following command:

sudo syslinux –sf /dev/sdb1

The sudo command is used if you are not logged in as root.

Substitute /dev/sdb1 with the device path listed from the

fdisk command.

In Windows, you will need to open a CMD prompt as an

administrator and use the following command:

syslinux –sfma E:

Substitute E: with the drive letter for the USB stick.

Page 26: ESXi4 Unattended Install

Creating an Automated ESXi Installer

David Convery, VCDX Pg 26 of 29 www.dailyhypervisor.com/

Once the USB stick is made bootable, attach it to the UDA.

Use the fdisk –l command to find the device path to the USB

stick. In this example, it is /dev/sdd1 (Notice the FAT16)

Make a directory for the USB mount point. Then mount the

stick and copy the files to it.

Type:

mkdir /mnt/usb mount /dev/sdd1 /mnt/usb cp –v /var/public/tftproot/esxi4u1/* /mnt/usb

You will also need to rename (move in Linux) the isolinux.cfg

file to syslinux.cfg

mv /mnt/usb/isolinux.cfg /mnt/usb/syslinux.cfg

You will need to edit the /mnt/usb/syslinux.cfg file to make

the ESXi Installer the default menu item. Look for the

following lines:

label ESXi Installer menu label ^ESXi Installer kernel mboot.c32 append vmkboot.gz --- vmkernel.gz --- sys.vgz --- cim.vgz --- ienviron.tgz --- image.tgz --- install.tgz

Page 27: ESXi4 Unattended Install

Creating an Automated ESXi Installer

David Convery, VCDX Pg 27 of 29 www.dailyhypervisor.com/

Since there is already a timeout entry, you just need to add

the menu default line.

label ESXi Installer menu label ^ESXi Installer menu default kernel mboot.c32 append vmkboot.gz --- vmkernel.gz --- sys.vgz --- cim.vgz --- ienviron.tgz --- image.tgz --- install.tgz

Then, unmount the USB stick to make sure all writes are

flushed.

umount /mnt/usb

In Windows, use the eject command.

Creating a Bootable CD Image

You can also create a bootable CD image of the ESXi automated installer.

Change to the /var/public/tftproot/esxi4u1 directory. You can

use the ls command to list the files and confirm they exist.

Since the files already make up a bootable system with the

customized scripts, we just need to create a bootable CD

image, using these files with the mkisofs command.

mkisofs –l –J –R –r –T –o ../ESXi4U1_Unattended.iso –b isolinux.cfg –c boot.cat –no-emul-boot –boot-load-size 4 –boot-info-table .

NOTE: The command listed above is a SINGLE LINE. Also, notice

the “.” at the end. In Debian based Linux distributions, such as

Ubuntu, you will use the genisoimage command.

Page 28: ESXi4 Unattended Install

Creating an Automated ESXi Installer

David Convery, VCDX Pg 28 of 29 www.dailyhypervisor.com/

Once the image is created, you can burn the image to blank CD

media. You can use the cdrecord command in Linux.

Now that you have a hypervisor installed you will need to configure the server and add it to vCenter in

an automated fashion. Look for a future doc covering this. For now, check out these resources for post

install configurations:

http://communities.vmware.com/docs/DOC-7364

http://communities.vmware.com/docs/DOC-7511

http://communities.vmware.com/docs/DOC-8170

Page 29: ESXi4 Unattended Install

Creating an Automated ESXi Installer

David Convery, VCDX Pg 29 of 29 www.dailyhypervisor.com/

About the Author

David Convery

David has been working as a VAC VCP for several years. During that time, he has participated in many

planning, design and implementation engagements. Previous to that, he worked at a major disaster

recovery services company, where he assisted in recoveries during disasters such as 9/11, and

hurricanes Katrina and Rita. He has worked in technology since 1998. David is currently a VMware

Certified Design Expert in VI3 and VMware Certified Professional in VI2, VI3 and vSphere 4. He was also

awarded the VMware vExpert designation for 2009. David also holds several certifications from HP,

Cisco, RedHat, Citrix, Brocade and Symantec.

The Daily Hypervisor is a blog site founded by Sid Smith and Dave Convery dedicated to discussions

regarding Virtualization and related technologies. As consultants focused on Virtualization technologies,

we have valuable real world experience and knowledge that we would like to share with the community.

Creating an Automated ESXi Installer by David Convery is licensed under a Creative Commons

Attribution-Noncommercial-Share Alike 3.0 United States License.