1、安装必须的软件包
yum -y install httpd xinetd syslinux tftp-server system-config-kickstart dhcp

2、将LINUX和ESXI的ISO镜像拷贝进/mnt/iso目录
mkdir -p /mnt/iso

3、挂载去apache里展示的目录
mkdir -p /var/www/html/centos75
mkdir -p /var/www/html/esxi67u3a
mkdir -p /var/www/html/clonezilla264
mkdir -p /var/www/html/gparted1005
mkdir -p /var/www/html/ks
mount -o loop /mnt/iso/CentOS-7-x86_64-DVD-1804.iso /var/www/html/centos75
mount -o loop /mnt/iso/VMware-VMvisor-Installer-6.7.0.update03-14320388.x86_64.iso /var/www/html/esxi67u3a
mount -o loop /mnt/iso/clonezilla-live-2.6.4-10-amd64.iso /var/www/html/clonezilla264
mount -o loop /mnt/iso/gparted-live-1.0.0-5-amd64.iso /var/www/html/gparted1005

4、创建PXE启动目录
mkdir /var/lib/tftpboot/pxelinux.cfg
cd /var/lib/tftpboot/pxelinux.cfg
mkdir centos75
mkdir esxi67u3a
mkdir clonezilla264
mkdir gparted1005
mkdir partedmagic2013
cp /usr/share/syslinux/{pxelinux.0,gpxelinux.0} /var/lib/tftpboot/
cp /var/www/html/centos75/isolinux/vesamenu.c32 /var/lib/tftpboot/
cp /var/www/html/centos75/isolinux/{vmlinuz,initrd.img} /var/lib/tftpboot/centos75/
cp /var/www/html/centos75/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
cp /var/www/html/esxi67u3a/efi/boot/{boot.cfg,bootx64.efi} /var/lib/tftpboot/esxi67u3a/
ln -s /var/www/html/esxi67u3a/efi/boot/bootx64.efi /var/www/html/esxi67u3a/efi/boot/mboot.efi
cp /var/www/html/esxi67u3a/mboot.c32 /var/lib/tftpboot/esxi67u3a/
cp /var/www/html/clonezilla264/live/{vmlinuz,initrd.img} /var/lib/tftpboot/clonezilla264/
cp /var/www/html/gparted1005/live/{vmlinuz,initrd.img} /var/lib/tftpboot/gparted1005/
cp /mnt/iso/pmagic_2013_06_14_i586.iso /var/lib/tftpboot/partedmagic2013
mkdir -p /tmp/iso
mount /mnt/iso/pmagic_2013_06_14_i586.iso /tmp/iso
cp /tmp/iso/boot/syslinux/memdisk /var/lib/tftpboot/partedmagic2013

5、编辑启动文件
vi /var/lib/tftpboot/pxelinux.cfg/default
label 1
menu label ^Install CentOS 7.5mini
menu default
kernel centos75/vmlinuz
append initrd=centos75/initrd.img ks=http://172.16.10.1/ks/centos75.cfg

label 2
menu label ^Install esxi67u3a
kernel esxi67u3a/mboot.c32
append -c esxi67u3a/boot.cfg
ipappend 2

label 3
MENU LABEL Clonezilla Live
kernel clonezilla264/vmlinuz
append initrd=lonezilla264/initrd.img boot=live union=overlay live-config noswap nolocales edd=on nomodeset ocs_live_run=”ocs-live-general” ocs_live_extra_param=”” keyboard-layouts= ocs_live_batch=”no” locales= vga=788 nosplash fetch=http://172.16.10.1/clonezilla264/live/filesystem.squashfs

label 4
menu label Parted Magic
#kernel partedmagic2013/bzImage
#append initrd=partedmagic2013/initrd.img fetch=http://172.16.10.1/partedmagic2013/pmagic/pmodules/PMAGIC_2013_06_14.SQFS
linux partedmagic2013/memdisk
initrd partedmagic2013/pmagic_2013_06_14_i586.iso
append iso

label 5
MENU LABEL GParted Live
kernel gparted1005/vmlinuz
append initrd=gparted1005/initrd.img boot=live config components union=overlay username=user noswap noeject ip= vga=788 fetch=http://172.16.10.1/gparted1005/live/filesystem.squashfs

# 去掉boot.cfg里面的/符号
sed -i ‘s/\///g’ /var/lib/tftpboot/esxi67u3a/boot.cfg

修改vsphere网络安装需要的引导内容
vi /var/lib/tftpboot/esxi67u3a/boot.cfg
prefix=http://172.16.10.1/esxi67u3a
kernelopt=ks=http://172.16.10.1/ks/esxi67u3a.cfg

6、开启tftp
vi /etc/xinetd.d/tftp
将disable = yes 改成 no

7、配置DHCP,使用 HTTP (IPv4) 引导。例如PXE服务器IP为172.16.10.1
cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf
vi /etc/dhcp/dhcpd.conf
default-lease-time 600;
max-lease-time 7200;
subnet 172.16.10.0 netmask 255.255.255.0 {
range 172.16.10.100 172.16.60.200;
option domain-name-servers 172.16.10.1;
option domain-name “localhost.local”;
option routers 172.16.10.1;
option broadcast-address 172.16.10.255;
allow booting;
allow bootp;
option client-system-arch code 93 = unsigned integer 16;
class “pxeclients” {
match if substring(option vendor-class-identifier, 0, 9) = “PXEClient”;
next-server 172.16.10.1;
if option client-system-arch = 00:07 or option client-system-arch = 00:09 {
if exists user-class and option user-class = “iPXE” {
# Instruct iPXE to load mboot.efi as secondary bootloader
filename = “mboot.efi”;
} else {
# Load the snponly.efi configuration of iPXE as initial bootloader
filename = “snponly.efi”;
}
} else {
filename “gpxelinux.0″;
}
}

8、配置Kickstart文件
vi /var/www/html/ks/entos75.cfg
#version=DEVEL
# X Window System configuration information
#xconfig –startxonboot
# License agreement
eula –agreed
# System authorization information
auth –enableshadow –passalgo=sha512
# Use CDROM installation media
#cdrom
# Use network installation
url –url=”http://172.16.10.1/centos75″
# Use graphical install
graphical
# Run the Setup Agent on first boot
firstboot –enable
ignoredisk –only-use=sda
# Keyboard layouts
keyboard –vckeymap=cn –xlayouts=’cn’
# System language
lang zh_CN.UTF-8

# Network information
network –bootproto=dhcp –device=eth0 –onboot=on –ipv6=auto –no-activate
network –hostname=localhost.localdomain

# Root password
rootpw –iscrypted $6$N5iv1YnS1Y4rEIxd$pjbmVlcFmxX8oz81iF1VG71.g5QFZ2Yo4GPKkFFGjMbJ1
# System services
services –enabled=”chronyd” –disable auditd,cups,atd
# 屏蔽selinux
selinux –disabled
# System timezone
timezone Asia/Shanghai –isUtc
# System bootloader configuration
bootloader –location=mbr –boot-drive=sda
autopart –type=lvm
# Partition clearing information
zerombr
clearpart –all –initlabel
# Disk partitioning information
#part /boot –fstype=”xfs” –size=1024
#part pv.157 –fstype=”lvmpv” –size=999999999 –grow
#volgroup centos –pesize=4096 pv.157
#logvol / –fstype=”xfs” –size=99999999 –name=root –vgname=centos –grow
#logvol swap –fstype=”swap” –size=8064 –name=swap –vgname=centos

%packages
@^minimal
@core
chrony
lrzsz
net-tools
sysstat

%end

%addon com_redhat_kdump –disable –reserve-mb=’auto’

%end

%anaconda
pwpolicy root –minlen=6 –minquality=1 –notstrict –nochanges –notempty
pwpolicy user –minlen=6 –minquality=1 –notstrict –nochanges –emptyok
pwpolicy luks –minlen=6 –minquality=1 –notstrict –nochanges –notempty
%end

—————–
vi /var/www/html/ks/esxi67u3a.cfg
# /etc/vmware/weasel/ks.cfg
# Accept the VMware End User License Agreement 按受VMware协议
vmaccepteula

# Set the root password for DCUI 设置密码sha512加密openssl passwd -1 yourPASSWORD
rootpw –iscrypted $6$N5iv1YnS1Y4rEIxd$pjb1VG71.g5QFZ2Yo4GPKkFFGjMbJ1

# Install on the first local disk available on machine 将ESXi安装在系统中的第一个磁盘上
install –firstdisk –overwritevmfs

# Set the keyboard
keyboard ‘US Default’

# Management Network Setting 配置IP地址
#network –bootproto=static –ip=192.168.0.22 –netmask=255.255.255.0 –gateway=192.168.0.1 –hostname=ESXi01 –nameserver=192.168.0.1 –addvmportgroup=1
network –bootproto=dhcp –device=vmnic0

# reboot the host after installation is completed
reboot

9、设置开机自动启动
systemctl enable {httpd,dhcpd,xinetd}

PS:
https://docs.vmware.com/cn/VMware-vSphere/6.7/com.vmware.esxi.install.doc/GUID-91E32FD0-A33C-4302-9FAB-B52B8A5CEFBC.html#GUID-91E32FD0-A33C-4302-9FAB-B52B8A5CEFBC