HowTo – Deploy ESXi Images and Configuration via PXE Part1

For a couple of days was thinking: What topic should we choose for our first blog post? What is the first think you need to do to setup your SDDC? Right! Install ESXi hosts! But what if you have a big bunch of servers? Should you install them all with ISOs on RLO management consoles or with USB drives? Nobody wants that! So why not just power them on and wait for them to install ESXi alone.

This is how I came to the topic of this blog post, where I want to build a Linux server based on CentOS to offer ESXi installations via PXE boot over the network.

You could also use vSphere Auto Deploy, but you need a vCenter for this. Maybe I’ll cover this later. So first, why not just start a VM on your laptop go and on.

What we need

  • a VM with CentOS or any other Linux distribution (I used CentOS-7-i386-Minimal-1804.iso, assigned a static IP address and added “marc” to /etc/sudoers)
  • Internet connection (to install Packages)
  • ESXi ISO file
  • a provisioning network/VLAN configured as access port
  • (optional) mac addresses of all server NICs

How it works

As orientation for this setup I used the “Installing ESXi Using PXE” guide for vShpere 6.0. But of course, I want to install ESXi 6.7 Update 1.

Here is an overview of the workflow with all the components needed for this:

After the ESXi host got the network boot loader it could ether boot from TFTP or HTTP. I decided to use TFTP for this. If you want to use HTTP take a look at the “Installing ESXi Using PXE” guide for vShpere 6.0 for configuration

Preparing the PXE Server

  1. Install CentOS in a VM
  2. Update CentOS using yum and wait till it’s complete
  3. Install needed packages
  4. Configure the DHCP config file in /etc/dhcp/dhcpd.conf
    Of course you need to change the IP addresses. The address for “next-server” is the address of your TFTP server. The static IP address of my lab server ist 192.168.216.234.
    In the subnet section make sure that you have enough addresses. For example a range from 192.168.216.130 to 192.168.216.149 would offer a maximum of 19 IP addresses.

    If you have the MAC addresses of you servers you can assign one IP address to a mac and protect other MAC addresses to get an IP address from the server, this is good if you don’t have a provisioning LAN:

    EDIT: If you also want to give the hostname to the ESXi hosts add “option host-name “NAME”;” to the specific host IP settings:
  5. After saving this configuration restart the dhcp deamon.
  6. To test the DHCP server you can boot a VM in the same network via PXE
  7. To check the current DHCP leases look in “/var/lib/dhcpd/dhcpd.leases”.

    and you’ll get a result like this (just power the hw servers on one-by-one with 20 secs pause between and you see all the MACs here):
  8. Activate TFTP by changing “disable” to “no” in /etc/xinetd.d/tftp
  9. Restart  and enable the xinetd service:
  10. Now you need to bring your ESXi installation files into the TFTP server. In my case this server is running inside of a VM, so I can just mount the ISO and copy the files to the server. After that unmount the ISO file:
  11. Before we can start, we need to remove all backslashes (“\”) in boot.cfg. If we wouldn’t do so it’ll references to the wrong path and could not load the files.
  12. Now you either need to know If your hosts have a legacy BIOS or UEFI. If you are not sure, you can do both:
    For UEFI: Copy both bootx64.efi (rename it to mboot.efi) and boot.cfg to “/var/lib/tftpboot/”:

    Now You need to add the folder name into boot.cfg. Add the name of the folder behind “prefix=” in /var/lib/tftpboot/boot.cfg. Here is how my first lines looked like:


    For legacy BIOS: Here it gets a bit more complicated, we need the syslinux files, we have installed in step 1.  This is for the PXE menu. Copy them to “/var/lib/tftpboot”:

    Now we need to write the configuration file for the PXE boot menu. Create a new file “default” in “/var/lib/tftpboot/pxelinux.cfg/”:

    and insert the following content  (need to change the path):

    (optional) You could add entries to the boot (i.e. different versions of ESXi) menu by adding some new entries (for this example ESXi 6.0):
  13. Add firewall rules for TFTP:
  14. It’s working with UEFI (no boot menu):
    … and with legacy BIOS (boot menu first):
    This is how it looks, using vesamenu and different boot entries (see step 11):
  15. After booting you can start the installation as normal:

    Now you can add a kickstart file to configure and install ESXi fully automated. I will cover this in part two.