系統安裝咱們通常可採用如下方式:光盤、U盤、PXE網絡等,當咱們大批量安裝系統時,網絡是很是有效率的選擇。VMware ESXI是基於Linux開發的,因此它也和全部的Linux系統同樣,除了支持光盤引導安裝外,還支持基於PXE的網絡引導與安裝。PXE只是網絡安裝的引導方式,自動化的核心依賴於kickstart/autoyast/autounattend等生成的自動應答文件。html
tftpd32+esxi6.0u2+kickstart+hfs+syslinux4.05python
1.1 在windows服務器上,建立一個文件夾,做爲TFTP服務器的工做目錄,本測試環境是windows10, 目錄是D:\esxi6。 從syslinux程序中複製pxelinux.0文件到這個目錄。linux
1.2 將ESXI6.0U2鏡像中的全部文件複製到D:\esxi6目錄中,複製syslinux中的MENU.C32替換D:\esxi6中的同名文件。vim
1.3 在D:\esxi6目錄中建立pxelinux.cfg目錄,複製esxi6.0u2鏡像中的文件 ISOLINUX.CFG到pxelinux.cfg文件夾中。windows
備註服務器
若是你要爲全部的服務器安裝esxi6,請將ISOLINUX.CFG改名爲default。若是你要爲指定的服務器安裝,請記下服務器的MAC地址(服務器上可能有多個網卡,須要記下經過網卡引導的網卡的MAC地址),並複製ISOLINUX.CFG文件,重命名爲「序號+MAC地址」,其中序號用0一、0二、03代替,表示第1臺、第2臺服務器的順序,在序號與MAC地址之間,用短橫線代替,例如,第1臺服務器的MAC地址是F48E38873878,則文件名爲01-F4-8E-38-87-38-78網絡
注意socket
若是你是手動填寫相關信息,請忽略步驟1.5。 默認是kernelopt=runweaselide
若是選擇自動應答,還須要修改D:\esxi6目錄中boot.cfg配置文件,修改成kernelopt=ks=http://192.168.40.1/ks.cfg
post
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,設置完成後從網卡啓動,進入安裝
其實和上面的步驟同樣,作了一樣的事情。
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