ks.cfg、ks-first.cfg和ks-first-safe.cfg 3个文件为ESX/ESXI脚本安装文件

官方《ESXi Installable 和 vCenter Server 安装指南》文档中(中文手册) 33-64页提到的内容但是官方的文档没有给出默认这3个文件的内容以及如何找到3个文件。

ks-first-safe.cfg  在第一个检测到的磁盘上安装 ESX并将 VMFS 数据存储保留在该磁盘上。
ks-first.cfg         在第一个检测到的磁盘上安装 ESX。
ks.cfg                在第一个检测到的磁盘上安装 ESXi。
使用 ks-first-safe.cfg 或 ks-first.cfg 安装 ESX 时默认根密码为 mypassword。

ks.cfg、ks-first.cfg和ks-first-safe.cfg文件是不可见的被压缩在 ESX/ESXI安装镜像中的 initrd.img 文件中initrd.img 文件位于ESX安装镜像中的isolinux目录中。
提取步骤
1.提取ESX安装镜像中的isolinux目录中initrd.img文件。
2.将initrd.img文件拷贝到一台linux系统的机器中。
3.一次执行下面的命令
   mv initrd.img initrd.img.gz     
   gunzip initrd.img.gz
   cpio -i < initrd.img
   
默认ks-first.cfg和ks-first-safe.cfg文件位置为usr/lib/vmware/weasel/examples/
    cd usr/lib/vmware/weasel/examples/ 
官方文档中说 ks.cfg 脚本默认位于 /etc/vmware/weasel/ks.cfg。
但是小提取的时候是在usr/lib/vmware/weasel/ks.cfg
要运行默认脚本请在引导菜单上按 Tab然后键入 ks=file:path to file。

官方文档中的默认脚本包含以下命令
#root Password
rootpw --iscrypted $1$MpéR&euml;&Egrave;í&Igrave;$n9sgFQJweS1PeSBpqRRu..
# Authconfig
authconfig --enableshadow --enablemd5
# BootLoader (Use grub by default.)
bootloader --location=mbr
# Timezone
timezone America/Los_Angeles --utc
#Install
install cdrom
#Network install type
network --device=MAC_address --bootproto=dhcp
#Keyboard
keyboard us
#Reboot after install?
reboot
# Clear partitions
clearpart --firstdisk
# Partitioning
part /boot --fstype=ext3 --size= --onfirstdisk
part storage1 --fstype=vmfs3 --size=10000 --grow --onfirstdisk
part None --fstype=vmkcore --size=100 --onfirstdisk
# Create the vmdk on the cos vmfs partition.
virtualdisk cos --size=5000 --onvmfs=storage1
# Partition the virtual disk.
part / --fstype=ext3 --size=0 --grow --onvirtualdisk=cos
part swap --fstype=swap --size=256 --onvirtualdisk=cos
#VMware Specific Commands
accepteula
serialnum --esx=XXXXX-XXXXX-XXXXX-XXXXX-XXXXX
# Accept the VMware End User License Agreement
vmaccepteula
# Set the root password for the DCUI and Tech Support Mode
rootpw mypassword
# Choose the first discovered disk to install onto
autopart --firstdisk --overwritevmfs
# The installation media is in the CD-ROM drive
install cdrom
# Set the network to DHCP on the first network adapater
network --bootproto=dhcp --device=vmnic0
# A sample post-install script
%post --unsupported --interpreter=python --ignorefailure=true
import time
stampFile = file('/finished.stamp', mode='w'
stampFile.write( time.asctime() )