1、安装PXE环境涉及软件

yum -y install dhcp* httpd tftp-server*


2、配置DHCP

vim /etc/dhcp/dhcpd.conf 

allow booting;

allow bootp;

ignore client-updates;

option routers 192.168.130.229;

option subnet-mask 255.255.255.0;

subnet 192.168.130.0 netmask 255.255.255.0{

        range 192.168.130.10 192.168.130.20;

        next-server 192.168.130.229;

        filename "gpxelinux.0";

}


vim /etc/rc.d/init.d/dhcpd

将user=dhcpd、group=dhcpd改为user=root、group=root


chkconfig dhcpd on

service dhcpd start


3、配置TFTP

vim /etc/xinetd.d/tftp 

service tftp

{

        socket_type             = dgram

        protocol                = udp

        wait                    = yes

        user                    = root

        server                  = /usr/sbin/in.tftpd

        server_args             = -s /var/lib/tftpboot

        disable                 = no

        per_source              = 11

        cps                     = 100 2

        flags                   = IPv4

}


chkconfig xinetd on

service xinetd start


4、配置HTTP

chkconfig httpd on

service httpd start


5、配置引导文件

yum -y install syslinux

cp /usr/share/syslinux/gpxelinux.0 /var/lib/tftpboot/


6、配置选项菜单

vim /var/lib/tftpboot/boot.msg

#########################################################

1 esxi6.0

#########################################################


7、配置default文件

mkdir /var/lib/tftpboot/pxelinux.cfg


vim /var/lib/tftpboot/pxelinux.cfg/default

default 1

prompt 1

timeout 60

display boot.msg


label 1

  kernel http://192.168.130.229/iso/esxi6.0/mboot.c32

  append -c http://192.168.130.229/iso/esxi6.0/boot.cfg ks=http://192.168.130.229/ks/esxi6.0/ks.cfg


8、拷贝镜像并做相应修改

mkdir -p /var/www/html/ks/esxi6.0 /var/www/html/iso/esxi6.0

mount /dev/cdrom /mnt

cp -r /mnt/* /var/www/html/iso/esxi6.0


将所有的/删除,并添加prefix=http://192.168.130.229/iso/esxi6.0

vim /var/lib/tftpboot/esxi6.0/boot.cfg

bootstate=0

title=Loading ESXi installer

timeout=5

prefix=http://192.168.130.229/iso/esxi6.0

kernel=tboot.b00

kernelopt=runweasel

modules=b.b00 --- jumpstrt.gz --- useropts.gz --- k.b00 --- chardevs.b00 --- a.b00 --- user.b00 --- uc_intel.

b00 --- uc_amd.b00 --- sb.v00 --- s.v00 --- mtip32xx.v00 --- ata_pata.v00 --- ata_pata.v01 --- ata_pata.v02 -

-- ata_pata.v03 --- ata_pata.v04 --- ata_pata.v05 --- ata_pata.v06 --- ata_pata.v07 --- block_cc.v00 --- ehci

_ehc.v00 --- elxnet.v00 --- emulex_e.v00 --- weaselin.t00 --- esx_dvfi.v00 --- ima_qla4.v00 --- ipmi_ipm.v00 

--- ipmi_ipm.v01 --- ipmi_ipm.v02 --- lpfc.v00 --- lsi_mr3.v00 --- lsi_msgp.v00 --- lsu_hp_h.v00 --- lsu_lsi_

.v00 --- lsu_lsi_.v01 --- lsu_lsi_.v02 --- lsu_lsi_.v03 --- lsu_lsi_.v04 --- misc_cni.v00 --- misc_dri.v00 --

- net_bnx2.v00 --- net_bnx2.v01 --- net_cnic.v00 --- net_e100.v00 --- net_e100.v01 --- net_enic.v00 --- net_f

orc.v00 --- net_igb.v00 --- net_ixgb.v00 --- net_mlx4.v00 --- net_mlx4.v01 --- net_nx_n.v00 --- net_tg3.v00 -

-- net_vmxn.v00 --- nmlx4_co.v00 --- nmlx4_en.v00 --- nmlx4_rd.v00 --- nvme.v00 --- ohci_usb.v00 --- qlnative

.v00 --- rste.v00 --- sata_ahc.v00 --- sata_ata.v00 --- sata_sat.v00 --- sata_sat.v01 --- sata_sat.v02 --- sa

ta_sat.v03 --- sata_sat.v04 --- scsi_aac.v00 --- scsi_adp.v00 --- scsi_aic.v00 --- scsi_bnx.v00 --- scsi_bnx.

v01 --- scsi_fni.v00 --- scsi_hps.v00 --- scsi_ips.v00 --- scsi_meg.v00 --- scsi_meg.v01 --- scsi_meg.v02 ---

 scsi_mpt.v00 --- scsi_mpt.v01 --- scsi_mpt.v02 --- scsi_qla.v00 --- uhci_usb.v00 --- xhci_xhc.v00 --- tools.

t00 --- xorg.v00 --- imgdb.tgz --- imgpayld.tgz

build=

updated=0


9、配置KS文件

vim /var/www/html/ks/esxi6.0/ks.cfg 

#Accept the vmware End User License Agreement

accepteula

# Set the root password for the DCUI and Tech Support Mode

rootpw Test@2017

clearpart --firstdisk=local --overwritevmfs

#Part disk

install --firstdisk=local  --overwritevmfs

#Set the network to DHCP IP on the first network adapater

network --bootproto=dhcp --device=vmnic0

#Final reboot

reboot