说明
系统安装我们一般可采用以下方式:光盘、U盘、PXE网络等,当我们大批量安装系统时,网络是非常有效率的选择。VMware ESXI是基于Linux开发的,所以它也和所有的Linux系统一样,除了支持光盘引导安装外,还支持基于PXE的网络引导与安装。PXE只是网络安装的引导方式,自动化的核心依赖于kickstart/autoyast/autounattend等生成的自动应答文件。
软件准备
tftpd32+esxi6.0u2+kickstart+hfs+syslinux4.05
一.基于windows宿主机+VMware Workstation12
步骤
1.1 在windows服务器上,创建一个文件夹,作为TFTP服务器的工作目录,本测试环境是windows10, 目录是D:\esxi6。 从syslinux程序中复制pxelinux.0文件到这个目录。
1.2 将ESXI6.0U2镜像中的所有文件复制到D:\esxi6目录中,复制syslinux中的MENU.C32替换D:\esxi6中的同名文件。
1.3 在D:\esxi6目录中创建pxelinux.cfg目录,复制esxi6.0u2镜像中的文件 ISOLINUX.CFG到pxelinux.cfg文件夹中。
备注
如果你要为所有的服务器安装esxi6,请将ISOLINUX.CFG更名为default。如果你要为指定的服务器安装,请记下服务器的MAC地址(服务器上可能有多个网卡,需要记下通过网卡引导的网卡的MAC地址),并复制ISOLINUX.CFG文件,重命名为“序号+MAC地址”,其中序号用01、02、03代替,表示第1台、第2台服务器的顺序,在序号与MAC地址之间,用短横线代替,例如,第1台服务器的MAC地址是F48E38873878,则文件名为01-F4-8E-38-87-38-78
注意
如果你是手动填写相关信息,请忽略步骤1.5。 默认是kernelopt=runweasel
如果选择自动应答,还需要修改D:\esxi6目录中boot.cfg配置文件,修改为kernelopt=ks=http://192.168.40.1/ks.cfg
1.4 设置TFTP,打开tftpd,设置D:\esxi6为根目录。设置IP地址的起始地址(地址应该与服务器的地址在同一网段,并且在服务器的地址之后),设置如下,红色部分是要填写的。
1.5 设置hfs服务。将自动应答文件ks.cfg设置可以访问到(直接拖动文件到左边的框中即可。其实你也可以自己架设一个http服务,如果你想手动填写相关信息,可以忽略此步骤)
内容如下:
#
# Sample scripted installation file
#
# Accept the VMware End User License Agreement
vmaccepteula
# Set the root password for the DCUI and Tech Support Mode
rootpw mypassword
# Install on the first local disk available on machine
install --firstdisk --overwritevmfs
# Set the network to DHCP on the first network adapter
network --bootproto=dhcp --device=vmnic0
# A sample post-install script
%post --interpreter=python --ignorefailure=true
import time
stampFile = open('/finished.stamp', mode='w')
stampFile.write( time.asctime() )
1.6 设置防火墙允许TFTP通过防火墙或者直接关闭防火墙。
1.7 开启网络安装,新建虚拟机类型选择ESXI,设置完成后从网卡启动,进入安装
二.基于Centos6.8_x64+VMware Workstation12
其实和上面的步骤一样,做了同样的事情。
2.1 安装dhcp、tftp-server、syslinux、xinetd
yum install dhcp tftp-server syslinux xinetd
2.2 挂载ESXi ISO到/mnt
mount /dev/cdrom /mnt
2.3 修改vim /etc/dhcp/dhcpd.conf
ddns-update-style interim;
allow booting;
allow bootp;
class "pxeclients" {
match if substring(option vendor-class-identifier, 0, 9) = "PXEClient";
next-server 192.168.10.78;
filename = "pxelinux.0";
}
subnet 192.168.10.0 netmask 255.255.255.0 {
range 192.168.10.100 192.168.10.110;
}
2.4 启用tftp,修改/etc/xinetd.d/tftp中的disable = yes为disable = no
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
}
2.5 复制pxelinux.0到tftp根目录
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
2.6 新建目录/var/lib/tftpboot/pxelinux.cfg
mkdir /var/lib/tftpboot/pxelinux.cfg
2.7 复制ESXi ISO文件中的isolinux.cfg到/var/lib/tftpboot/pxelinux.cfg/下并改名default
cp /mnt/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
2.8 复制ESXi ISO中的全部文件到/var/lib/tftpboot/下
cp -a /mnt/* /var/lib/tftpboot/
2.9 复制syslinux自带的menu.c32到tftp根目录替换掉ESXI ISO里的menu.c32。
cp /usr/share/syslinux/menu.c32 /var/lib/tftpboot/
2.10 重启dhcp、xinetd服务
systemctl restart dhcpd
systemctl restart xinetd
2.11 自定义安装脚本,安装httpd,此文件可以放在任何可以通过url访问到的地方。 编辑脚本ks.cfg
vim /var/www/html/ks.cfg
#
# Sample scripted installation file
#
# Accept the VMware End User License Agreement
vmaccepteula
# Set the root password for the DCUI and Tech Support Mode
rootpw mypassword
# Install on the first local disk available on machine
install --firstdisk --overwritevmfs
# Set the network to DHCP on the first network adapter
network --bootproto=dhcp --device=vmnic0
# A sample post-install script
%post --interpreter=python --ignorefailure=true
import time
stampFile = open('/finished.stamp', mode='w')
stampFile.write( time.asctime() )
2.12 编辑ESXi ISO复制过来的boot.cfg文件,添加kernelopt=ks=http://192.168.40.1/ks.cfg
bootstate=0
title=Loading ESXi installer
timeout=5
kernel=/tboot.b00
kernelopt=ks=http://192.168.40.1/ks.cfg
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 --- /lsi_mr3.v00 --- /lsi_msgp.v00 --- /bnxtnet.v00 --- /net_tg3.v00 --- /elxnet.v00 --- /ima_be2i.v00 --- /lpfc.v00 --- /scsi_be2.v00 --- /net_i40e.v00 --- /net_igb.v00 --- /net_ixgb.v00 --- /nmlx4_co.v00 --- /nmlx4_en.v00 --- /nmlx4_rd.v00 --- /nmlx5_co.v00 --- /qedentv.v00 --- /ima_qla4.v00 --- /misc_cni.v00 --- /net_bnx2.v00 --- /net_bnx2.v01 --- /net_cnic.v00 --- /net_qlcn.v00 --- /net_qlge.v00 --- /qlnative.v00 --- /scsi_bnx.v00 --- /scsi_bnx.v01 --- /scsi_qla.v00 --- /mtip32xx.v00 --- /scsi_meg.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 --- /emulex_e.v00 --- /weaselin.t00 --- /esx_dvfi.v00 --- /esx_ui.v00 --- /ipmi_ipm.v00 --- /ipmi_ipm.v01 --- /ipmi_ipm.v02 --- /lsu_hp_h.v00 --- /lsu_lsi_.v00 --- /lsu_lsi_.v01 --- /lsu_lsi_.v02 --- /lsu_lsi_.v03 --- /lsu_lsi_.v04 --- /misc_dri.v00 --- /net_e100.v00 --- /net_e100.v01 --- /net_enic.v00 --- /net_forc.v00 --- /net_mlx4.v00 --- /net_mlx4.v01 --- /net_nx_n.v00 --- /net_vmxn.v00 --- /nvme.v00 --- /ohci_usb.v00 --- /rste.v00 --- /sata_ahc.v00 --- /sata_ata.v00 --- /sata_sat.v00 --- /sata_sat.v01 --- /sata_sat.v02 --- /sata_sat.v03 --- /sata_sat.v04 --- /scsi_aac.v00 --- /scsi_adp.v00 --- /scsi_aic.v00 --- /scsi_fni.v00 --- /scsi_hps.v00 --- /scsi_ips.v00 --- /scsi_meg.v01 --- /scsi_meg.v02 --- /scsi_mpt.v00 --- /scsi_mpt.v01 --- /scsi_mpt.v02 --- /uhci_usb.v00 --- /vsan.v00 --- /vsanheal.v00 --- /vsanmgmt.v00 --- /xhci_xhc.v00 --- /tools.t00 --- /dell_con.v00 --- /xorg.v00 --- /imgdb.tgz --- /imgpayld.tgz
build=
updated=0