~ # ./ghetto-esxi-linked-clones.sh
######################################################
#
# UCSB ResNet Linked Clones Tool for ESXi
# Author: william2003[at]gmail[dot]com
# duonglt[at]engr[dot]ucsb[dot]edu
# Created: 09/30/2008
#
######################################################
Usage: ghetto-esxi-linked-clones.sh [FULL_PATH_TO_MASTER_VMX_FILE] [VM_NAME] [START_#] [END_#]
i.e.
./ghetto-esxi-linked-clones.sh /vmfs/volumes/4857f047-4e4ec6bf-a8b8-001b78361a3c/LabMaster/LabMaster.vmx LabClient- 1 200
Output:
LabClient-{1-200}
~ #
Thanks for sharing this script I tested it and its worked great job!
What issues are you having? Once you've created your pristine image and generated the Linked Clones off of that base image, you can use the following documentation for further configurations to make each LC unique: http://communities.vmware.com/docs/DOC-9201 , this is the implementation that my colleague Tuan and I have deployed into production at UCSB.
this is the situation
I have created 10 Linked clones of a golden image, I can start all of them and it's working, also I can take 1 or more snapshots from each linked clones but i can not remove the snapshots.
I got this error message:
an attempt was made to write to a read-only file.
Are you creating the new snapshots using the VI Client or through the console? What version of ESXi are you running? In either case, we've not heard or run into this issue before, if I get some time will try to test but I'll be pretty busy with some new projects.
yes through VI Client , I don't no how through console.
I'm using ESXi 3i, 3.5.0, 123629
also we have ESX server 3.5 same problem.
I had the same problem and it turned out that the clone was in a template mode.
http://hash-depot.blogspot.com/2009/05/vmwares-esxi-snapshot-removal-problem.html
Check advanced settings for templateVM and if its set to "true" change it to "false". Worked for me.
This is really good stuff. Thought I'd share a wee gotcha. If you dowhload the script using the obvious wget from the esxi commandline it turns up with ^M at the end of each line and the shell script falls over. Took me a while to work out what was going on.
Mike
just changed the script a bit, thought i might share back ![]()
vmdks_count=`grep ^scsi "${GOLDEN_VM}" | grep fileName | awk -F "\"" '{print $2}' | wc -l`
vmdks=`grep ^scsi "${GOLDEN_VM}" | grep fileName | awk -F "\"" '{print $2}'`
what changed : I changed the grep scsi to ^scsi
why : I had a floppy mounted vmscsi*.flp that contains the drivers to install xp. This blocked me from doing linked clones even after i detached the floppy, because it was still in the config. Grepping on ^scsi makes more sense because this is the pattern you are looking for
macfile() {
#grab mac addresses of newly created VMs (file to populate dhcp static config)
if -f ${LC_CREATED_VMS} ; then
for i in `cat ${LC_CREATED_VMS}`;
do
TMP_LIST=${LC_EXECUTION_DIR}/vm_list.$$
VM_P=`echo ${i##*/}`
VM_NAME=`echo ${VM_P%.vmx*}`
VM_MAC=`grep ethernet0.generatedAddress "${i}" | awk '{print $3}' | sed 's/\"//g' | head -1 | sed 's/://g'`
while
do
sleep 1
VM_MAC=`grep ethernet0.generatedAddress "${i}" | awk '{print $3}' | sed 's/\"//g' | head -1 | sed 's/://g'`
echo $(grep ethernet $i)
done
echo "${VM_NAME} ${VM_MAC}" >> ${TMP_LIST}
done
LCS_OUTPUT="lcs_created_on-`date +%F-%H%M%S`"
echo -e "Linked clones VM MAC addresses stored at:"
cat ${TMP_LIST} | sed 's/[:digit:]/ &/1' | sort -k2n | sed 's/ //1' > "${LCS_OUTPUT}"
echo -e "\t${LCS_OUTPUT}"
fi
}
#mac generation is done after the vm powers up. if you want to generate this file you will need to power on the vms first
#macfile()
what changed : Made a function to generate the file with static macs
why : Here in my version the mac addresses where only generated after the machine was powered on. This meant that the script kept looking and waiting for the mac address to be written to the vmx file. Since I don't need these mac addresses i just disabled it.
Hope it helps
Hi William. Do you plan on updating this script to support ESXi 4?
Thanks
The script actually should work but theres a section of the code that checks for the vmware -v version, you should be able to modify that and get it to work. I haven't had the time to update the older linked clones script but I know for a fact that ghetto-esx-linked-clones.sh does work and just needs the version modified but I've never tested the ESXi version.
If you're using a licensed version of ESX(i) 4.0, here is an updated version using the vSphere SDK for Perl to create the Linked Clones: http://engineering.ucsb.edu/~duonglt/vmware/vGhettoLinkedClone.html
Thanks for your reply William! Yes, I've seen your vGhettoLinkedClone script for ESXi 4, but as I've asked in another post it look like I need vCenter to use this script. Is this correct or can I use it without vCenter?
Thanks again.
As stated per the requirements, you need vCenter.
Forgot to mention, you can also find more scripts/resources located at:
http://engineering.ucsb.edu/~duonglt/vmware/