Creating a PXE boot for ESXi 4.1 with a kickstart installation
For the VMware course I teach for Ictivity Training VMware ESXi server have to be deployed on a regular basis. In the passed I have made a kickstart installation for ESX witch could be used on a USB stick during the boot of the DVD. Now that we’re upgrading the VMware courses to vSphere ESXi 4.1 I wanted to create a PXE boot environment witch could be used to install different ESXi 4.1 servers.
Because I’m a Novell/VMware guy I wanted to create a SLES11 virtual machine for the PXE boot environment that runs on VMware vSphere or VMware Workstation.
I’m assuming that you all know how to create a virtual machine and how to install SLES 11 inside this virtual machine with the VMware tools.
During installation make sure you select the following packages:
- DHCP Server
- TFTP Server
- Apache
- syslinux
I’m also assuming you have downloaded the VMware ESXi 4.1 iso file from the VMware website and that this is located in the /root directory.
For testing purpose, we’re not going to enable the kickstart installation during the test of PXE boot. This is added later.
PXE Setup
First step is to configure the DHCP server. Here is my configuration file.
option domain-name “training.local”;
option domain-name-servers 172.16.1.100;
option routers 172.16.1.1;
default-lease-time 14400;
ddns-update-style none;
authoritative ;
filename “pxelinux.0”;
subnet 172.16.0.0 netmask 255.255.0.0 {
range 172.16.1.200 172.16.1.220;
default-lease-time 14400;
max-lease-time 172800;
}
This configuration file gives a lease in the range 172.16.1.200 – 172.16.1.220 with a subnetmask of 255.255.0.0, a default gateway 172.16.1.1 and a domain name server 172.16.1.100. The option filename “pxelinux.0” will tell the PXE client to look on this server with the tftp protocol for a fill called pxelinux.0. We’re going to provide this file later on.
Make sure that the DHCP server is started at boot time.
Second step is to configure the TFTP server.
In yast under Network Services select TFTP server. Yast will tell you that the default location for the TFTP files will be /tftpboot. In my case I move this location to /srv/tftp because I think this is a better location. Make sure that the TFTP server is started at boot time.
Third step is to provide the necessary file for the PXE boot.
- Copy the /usr/share/syslinux/pxelinux.0 to /srv/tftp
- Create a directory /srv/tftp/pxelinux.cfg
- In this directory create a file called default and open this file in your default text editor. Below is my file.
- This file is read during the PXE boot. We will provide the files in vmware/esxi4.1/* in a later step.
MENU TITLE Ictivity Training VMware ESXi installation menu
PROMPT 1 #display the boot: option during boot
TIMEOUT 100 # a timeout value of 10 second after this de DEFAULT will be started unless another option is entered during boot
DEFAULT localboot #default is the option localbootSAY Welcom to the Ictivity Training VMware ESXi installation menu #Some text messages
SAY Type esxinstall to start the VMware ESXi installation, do nothing local boot will happen. #Some text messagesLABEL localboot
localboot 0x80LABEL esxinstall
kernel vmware/esxi4.1/mboot.c32
append vmware/esxi4.1/vmkboot.gz — vmware/esxi4.1/vmkernel.gz — vmware/esxi4.1/sys.vgz — vmware/esxi4.1/cim.vgz — vmware/esxi4.1/ienviron.vgz — vmware/esxi4.1/install.vgz — vmware/esxi4.1/image.tgz
Foured step is to provide the ESXi file for installation.
- Mount the iso file that you have save in the /root directory with the command:
mount -o loop /root/VMware-VMvisor-Installer-4.1.0-260247.x86_64.iso /mnt/iso
This assumes that you have a directory called /mnt/iso!
- Create a directory /srv/tftp/vmware/esxi4.1/
- Give the command:
cp -R /mnt/iso /srv/tftp/vmware/esxi4.1/
Now we’re ready to test the PXE boot.
Kickstart
Now PXE booting is working we can create a kickstart script file (normally called ks.cfg). This file will be located in the default documentroot of Apache (/srv/www/htdocs).
- Create a file called ks.cfg, place this file in /srv/www/htdocs and open this file with you favorite text editor.
- Below is my ks.cfg file. This is not a complex file but for my purpose (setting-up the classroom environment) this does the trick.
#Kickstart script file for host vsphere1
#Created by: M. Wilmsen/WilmsenIT
#Date: 8/12/2010accepteula
rootpw yourpassword
autopart –firstdisk –overwritevmfs
install url http://172.16.1.100/vmware
network –bootproto=static –ip=172.16.1.25 –gateway=172.16.1.1 –nameserver=172.16.1.100 –netmask=255.255.0.0 –hostname=vsphere1.training.local –addvmportgroup=0 - In the documentroot of Apache the installation files of ESXi 4.1 have to be available. The file will be place in the directory vmware. Ofcourse you can copy the files from the iso file again to the vmware directory. But we did this already for the PXE setup. So rather than copying the files again we make a symbolic link to /srv/tftp/vmware/esxi4.1/
ln -s /srv/ftfp/vmware/esxi4.1/ vmware
- Because we’re using a symbolic link and that the ks.cfg file is located on the documentroot of Apache we have to enable the options Indexes and FollowSymLinks in the /etc/apache2/default-server.conf file.
<Directory “/srv/www/htdocs”>
# Possible values for the Options directive are “None”, “All”,
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that “MultiViews” must be named *explicitly* — “Options All”
# doesn’t give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs-2.2/mod/core.html#options
# for more information.
Options Indexes FollowSymLinks
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be “All”, “None”, or any combination of the keywords:
# Options FileInfo AuthConfig Limit
AllowOverride None
# Controls who can get stuff from this server.
Order allow,deny
Allow from all
</Directory> - The final step is to modify the default PXE configuration file in order to tell the ESXi setup to make use of our ks.cfg file. To do this open the /srv/tftp/pxelinux.cfg/default in you favorite text editor and add ks=http://172.16.1.100/ks.cfg after the vmkboot.gz option. Your default file will look like this:
menu title Ictivity Training VMware ESXi installation menu
PROMPT 1
TIMEOUT 100
DEFAULT localbootSAY Welcom to the Ictivity Training VMware ESXi installation menu
SAY Type the servername to start the VMware ESXi installation, do nothing local boot will happen.
SAY Valid servernames are: vsphere1LABEL localboot
localboot 0x80LABEL vsphere1
kernel vmware/esxi4.1/mboot.c32
append vmware/esxi4.1/vmkboot.gz ks=http://172.16.1.100/ks.cfg — vmware/esxi4.1/vmkernel.gz — vmware/esxi4.1/sys.vgz4.1/image.tgz
And there you go. Now we can use PXE boot to install our ESXi 4.1 servers. Of course you can create a more advanced ks.cfg file but that’s up to you.
About Michael
Michael Wilmsen is a experienced VMware Architect with more than 20 years in the IT industry. Main focus is VMware vSphere, Horizon View and Hyper Converged with a deep interest into performance and architecture.
Michael is VCDX 210 certified, has been rewarded with the vExpert title from 2011, Nutanix Tech Champion and a Nutanix Platform Professional.