Top

ESXi - AutoInstall - With Kickstart and PXE

by

Yves Sandfort

By
Yves Sandfort
and

Sometimes vSphere AutoDeploy is not possible, like for an initial deployment or other reasons. In this article I described how to setup a bootserver for generic ESXi install, but also how to autoinstall an individual host.

ESXi+-+AutoInstall+-+With+Kickstart+and+PXEA few packages were installed:

  • tftp & tftp-server: provide for the server daemon and client for the tftp protocol
  • xinted: inetd based daemon integration which will allow the tftp-server to be loaded when accessed
  • dhcp: DHCP Server to hand out IP addresses and direct PXE boot to the proper tftp source

yum install -y tftp tftp-server xinetd dhcp rsync syslinux vsftpd

Edit the /etx/xinetd.d/tftp file and change disable to no:


 service tftp
    {
    	socket_type		= dgram
    	protocol		= udp
    	wait			= yes
    	user			= root
    	server			= /usr/sbin/in.tftpd
    	server_args		= -c -s /var/lib/tftpboot
    	disable			= no
    	per_source		= 11
    	cps			    = 100 2
    	flags			= IPv4
    }

Configure DHCP daemon: /etc/dhcp/dhcpd.conf

option domain-name "demovcd.com";
option domain-name-servers 10.185.1.6;
default-lease-time 3600;
max-lease-time 7200;
authoritative;
subnet 10.185.1.0 netmask 255.255.255.0 {
	range 10.185.1.51 10.185.1.100;
	option routers 10.185.1.1;
}


class "pxeclients" {
	match if substring(option vendor-class-identifier, 0, 9) = "PXEClient";
	next-server 10.185.1.6;
	filename "pxelinux.0";
}

Enable as a service


systemctl start dhcpd
systemctl start xinetd
systemctl start tftp
systemctl enable dhcpd
systemctl enable xinetd
systemctl enable tftp

Configure firewalld


firewall-cmd --permanent --add-port=69/udp
firewall-cmd --zone=public --add-service=tftp --permanent
firewall-cmd --zone=public --add-service=dhcp --permanent
firewall-cmd --permanent --add-port=21/tcp
firewall-cmd --zone=public --add-service=ftp --permanent
systemctl enable firewalld
systemctl restart firewalld

Create boot image, attach the ESXi image to the CentOS VM:


mkdir /mnt/cdrom
mount -t iso9660 /dev/sr0 /mnt/cdrom
mkdir -p /var/lib/tftpboot/pxelinux.cfg
mkdir -p /var/lib/tftpboot/images/esxi650U1
rsync -a /mnt/cdrom /var/lib/tftpboot/images/esxi650U1
sed -i 's/\///g' /var/lib/tftpboot/images/esxi650U1/boot.cfg
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot
cp /usr/share/syslinux/menu.c32 /var/lib/tftpboot

Create a simple boot menu in /var/lib/tftpboot/pxelinux.cfg/default


DEFAULT menu.c32
MENU TITLE ESXi-6.5.0 Boot Menu
NOHALT 1
PROMPT 0
TIMEOUT 300
LABEL install
KERNEL images/esxi650U1/mboot.c32
APPEND -c images/esxi650U1/boot.cfg
MENU LABEL ESXi-6.5.0U1 ^Installer
LABEL hddboot
LOCALBOOT 0x80
MENU LABEL ^Boot from local disk

Optional to create a machine specific config and kickstart file:

Create a file named 01-MAC of your machine i.e. 01-00-50-56-06-52-6c for MAC 00-50-56-06-52-6c


DEFAULT menu.c32
MENU TITLE ESXi-6.5.0 Boot Menu
NOHALT 1
PROMPT 0
TIMEOUT 300
LABEL install
KERNEL images/esxi650U1/mboot.c32
APPEND -c images/esxi650U1/boot.cfg ks=ftp://10.185.1.6/pub/00-50-56-06-52-6c.cfg
MENU LABEL ESXi-6.5.0U1 ^Installer
LABEL hddboot
LOCALBOOT 0x80
MENU LABEL ^Boot from local disk

And then we create a kickstart file in /var/ftp/pub/00-50-56-06-52-6c.cfg


# Accept the VMware EULA
vmaccepteula
# Initial Root password is VMware123!
rootpw VMware123!
# Install on first disk
install --firstdisk --overwritevmfs --novmfsondisk
# Network configuration
network --bootproto=static --device=vmnic0 --ip=10.185.1.101 --netmask=255.255.255.0 --gateway=10.185.1.1 --nameserver=10.185.1.6 --hostname=esxi01.demovcd.com --addvmportgroup=0
# Reboot host
reboot --noeject
# Stage 2
# Start in command mode
%firstboot --interpreter=busybox
# Set search domain
esxcli network ip dns search add --domain=demovcd.com
# Diasble IPv6
esxcli network ip set --ipv6-enabled=false
# Enable Maintenance Mode
esxcli system maintenanceMode set -e true
# Final reboot
esxcli system shutdown reboot -d 15 -r "rebooting after base configuration"

Questions?

Questions?

Ask

Yves

Thank you! Your message has been sent!
Oops! Something went wrong while submitting the form.