I wrote the following script to rename the old local ESXi 5.0 datastore with the help of kickstart first-time script:
_____________________________________________________________________
accepteula
#clearpart --firstdisk=cciss,local --all --overwritevmfs # Deletes all partitions of local drive (for G1 Blade servers) but won't delete the VMFS label
clearpart --firstdisk=hpsa,local --all --overwritevmfs # Deletes all partitions of local drive (for G6 Blade servers) but won't delete the VMFS label
install --firstdisk=hpsa,local --overwritevmfs
rootpw SECRET
reboot
%include /tmp/networkconfig
%pre --interpreter=busybox
# extract network info from bootup
VMK_INT="vmk0"
VMK_LINE=$(localcli network ip interface ipv4 get | grep "${VMK_INT}")
IPADDR=$(echo "${VMK_LINE}" | awk '{print $2}')
NETMASK=$(echo "${VMK_LINE}" | awk '{print $3}')
GATEWAY=$(esxcfg-route | awk '{print $5}')
DNS="10.130.0.21,10.130.0.22"
HOSTNAME=$(nslookup "${IPADDR}" | grep Address | awk '{print $4}')
echo "network --bootproto=static --addvmportgroup=false --device=vmnic0 --ip=${IPADDR} --netmask=${NETMASK} --gateway=${GATEWAY} --nameserver=${DNS} --hostname=${HOSTNAME}" > /tm
p/networkconfig
%firstboot --interpreter=busybox
# Extract the host number from the hostname
# Example: sc-moon01.tapkit.net = '01, sc-moon02.tapkit.net = '02,sc-moonNN.tapkit.net = 'NN,'
hl=`hostname -s |wc -c`
hostNum=$(hostname -s | cut -c`expr $hl - 2`-`expr $hl - 1`)
# Rename local datastore to something more meaningful
# Find the current local datastore name/LABEL (Exclude all SAN HSV200 datastore)
DatastoreName="$(esxcli storage vmfs extent list | grep ` esxcli --formatter=csv --format-param=fields="Device,Model" storage core device list | grep -v "HSV200" |grep -v "Device" | cut -d, -f1` | awk '{print $1}')"
NewDataStoreName="datastore$hostNum"
# Rename the datastore
vim-cmd hostsvc/datastore/rename $DatastoreName $NewDataStoreName
# copy %first boot script logs to persisted datastore
cp /var/log/hostd.log "/vmfs/volumes/$NewDataStoreName/firstboot-hostd.log"
cp /var/log/esxi_install.log "/vmfs/volumes/$NewDataStoreName/firstboot-esxi_install.log"
# Needed for configuration changes that could not be performed in esxcli (thanks VMware)
reboot
_____________________________________________________________________
Hope this help...
Many thanks to William Lam for his great contribution: http://www.virtuallyghetto.com/2011/07/automating-esxi-5x-kickstart-tips.html
Gilles Marcil