I have read long back about numerous posts on unattended Esxi installation but never tried it in my lab. Recently I started preparing for VCAP exam and there again mention of scripted install was there and it motivated me to finally try this in lab.
My first interaction with kickstart was 3 years back where in my previous organization our kickstart server died (running on really old hardware), but fortunately we had backup of the server and my boss handed over a task to me to build the server from scratch.
That was the time when I was so amazed by this wonderful piece of software and once I got the server up and running back in production, I setup an identical instance on my local system to play around options and enhance the pre/post installations script.
Like any other OS, ESXi can also be automatically deployed via PXE. PXE is a way to boot an operating system over the network using Ethernet card (PXE must be supported by the NIC card present in server and by the BIOS).
Overview of PXE Booting
A PXE environment relays on following 3 things:
- DHCP: the booting server will ask for IP configuration (IP, netmask, gateway and file server)
- TFTP: the TFTP server provides kernel and additional files via TFTP protocol.
- Support for PXE booting in NIC Card/BIOS of server.
Below diagram illustrates how PXE boot works in backend
The sequence of events that happens when a Esxi host boot over the network can be summarized as:
- The user boots the target ESXi host.
- The target ESXi host makes a DHCP request.
- The DHCP server responds with the IP information and the location of the TFTP server.
- The ESXi host contacts the TFTP server and requests the file that the DHCP server specified.
- The TFTP server sends the network boot loader, and the ESXi host executes it. The initial boot loader might load additional boot loader components from the TFTP server.
- The boot loader searches for a configuration file on the TFTP server, downloads the kernel and other ESXi components from the HTTP server or the TFTP server and boots the kernel on the ESXi host.
- The installer runs interactively or using a kickstart script, as specified in the configuration file.
Lets see how to configure things in lab and deploy an Esxi host over the network (without any human interaction)
Step 1: Build a Redhat/Centos VM
In my lab I am using CentOS 6.4 64 bit.
Step 2: Intall DHCP and TFTP-Serverand Syslinux packages
[root@kickstartsrv dhcp]# yum -y install dhcp tftp-server syslinux
Step 3: Configure DHCP Server
First we need to set ethernet interface name as DHCPDARGS in /etc/sysconfig/dhcpd file. Edit this configuration file and update the ethernet name. In my case I have only eth0 present in my system.
If you have more than one NIC card and you want to send dhcp traffic out from spcific NIC, then you have to define the same here.
[root@kickstartsrv dhcp]# cat /etc/sysconfig/dhcpd
# Command line options here
Configure dhcp settings in /etc/dhcp/dhcpd.conf file. My dhcpd.conf file looks like below
Once dhcpd.conf file is configured start the service
[root@kickstartsrv dhcp]# service dhcpd start
Starting dhcpd: [ OK ]
If you are getting any errors check /var/log/messages.
Step 4 (Optional): Test dhcp functionality
To test whether or not our dhcp serve ris working as expected, create a new blank VM and connect it to the portgroup/network to which your dhcp server is connected.
If there are no issues with dhcp configuration, you should see IP assigned to blank VM when it boots up over network.
Step 4: Enable TFTP Service
Modify /etc/xinetd.d/tftp file and set “disable” = no. By default it is set to “yes”
[root@kickstartsrv dhcp]# vim /etc/xinetd.d/tftp
Restart the xinetd service once changes are applied(tftp is controlled by xinetd and there is no dedicated service for tftpd).
[root@kickstartsrv dhcp]# service xinetd restart
Stopping xinetd: [ OK ]
Starting xinetd: [ OK ]
Also enable dhcpd and xinetd service to start automatically on system boot
[root@kickstartsrv dhcp]# chkconfig dhcpd on
[root@kickstartsrv dhcp]# chkconfig xinetd on
Step 5: Setup TFPT Directories
Create following directories on your server
[root@kickstartsrv ~]# mkdir -p /var/lib/tftpboot/pxelinux.cfg
[root@kickstartsrv ~]# mkdir -p /var/lib/tftpboot/images/ESXiv6.0U3
Step 6: Mount Esxi iso and copy files into image library
Download the Esxi iso from vmware.com and mount it on your server under /mnt or any other directory where you want
[root@kickstartsrv ~]# mount -o loop,ro Esxi-6.0-U3.iso /mnt
You should be able to see the following contents in /mnt directory
copy the contents from /mnt to /var/lib/tftp/images/Esxi directory created in step 5
[root@kickstartsrv images]# rsync -a /mnt/ /var/lib/tftpboot/images/ESXiv6.0U3
Step 6: Edit …..images/ESXiv6.0U3/boot.cfg and remove unwanted “/“ character.
[root@kickstartsrv ~]# sed -i ‘s/\///g’ /var/lib/tftpboot/images/ESXiv6.0U3/boot.cfg
Step 7: Install syslinux and Prepare Boot Files
Install syslinux – If it wasn’t installed in step 2.
# yum -y install syslinux
Copy pxelinux.0 to the /tftpboot folder. you can find the pxelinux.0 file using find command
[root@kickstartsrv ~]# find / -iname pxelinux.0
copy this file to /tftpboot folder
[root@kickstartsrv ~]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
copy the menu.c32 file into the /var/lib/tftpboot/
[root@kickstartsrv ~]# cp /usr/share/syslinux/menu.c32 /var/lib/tftpboot/images/ESXiv6.0U3/
cp: overwrite `/var/lib/tftpboot/images/ESXiv6.0U3/menu.c32′? y
Step 8: Create PXELinux configuration file
Create a file named “default” under /var/lib/tftpboot/pxelinux.cfg/ with below content:
[root@kickstartsrv ~]# vim /var/lib/tftpboot/pxelinux.cfg/default
<span style="color: #000000;">DEFAULT menu.c32</span>
<span style="color: #000000;">MENU TITLE ESXi-6.0 Boot Menu</span>
<span style="color: #000000;">NOHALT 1</span>
<span style="color: #000000;">PROMPT 0</span>
<span style="color: #000000;">TIMEOUT 300</span>
<span style="color: #000000;">LABEL install</span>
<span style="color: #000000;">KERNEL images/ESXiv6.0U3/mboot.c32</span>
<span style="color: #000000;">APPEND -c images/ESXiv6.0U3/boot.cfg</span>
<span style="color: #000000;">MENU LABEL ESXi-6.0U3 ^Installer</span>
<span style="color: #000000;">LABEL hddboot</span>
<span style="color: #000000;">LOCALBOOT 0x80</span>
<span style="color: #000000;">MENU LABEL ^Boot from local disk</span>
Note: The root directory for KERNEL and APPEND is “/var/lib/tftpboot”. So the “images/ESXiv6.0U3/mboot.c32” actually translates to “/var/lib/tftpboot/images/ESXiv6.0U3/mboot.c32”
Step 9: Testing Esxi deployment
Create an empty VM with 4 GB RAM/4 vCPU and 10 GB HDD and os as VMware Esxi 6.0
Boot this VM and DHCP server will assign an IP and redirect vm to the TFTP server. You should be able to see the Esxi installation menu.
And thats it. Esxi is successfully booting over the network now.
I hope you enjoyed reading this post. Feel free to share this on social media if it is worth sharing. Be sociable 🙂