#Creates a new Virtual Machine #####USER MODIFICATION################ #VMDIR is the directory which hold the .vmx file #VMNAME is the name of the new virtual machine #VMOS specifies which Operating System the virtual machine will have (consult vmware documentation for valid options) #VMDSIZE is the size of the virtual disk to be created (300m) or (60g) #VMMAC is the MAC address the VM will use (must start with 00:50:56) ##################################### VMDIR="vm_directory" #Specify only the folder name to be created; NOT the complete path VMNAME="MYTEST" VMOS="winNetEnterprise" VMDSIZE="200m" VMMEMSIZE="256" VMMAC="00:50:56:33:44:55" #Address must start with 00:50:56 #####END MODIFICATION##### #LOG="/opt/altiris/deployment/adlagent/bin/logevent" #$LOG -l:1 -ss:"Creating VMX Configuration File" mkdir /vmfs/volumes/storage1/$VMNAME exec 6>&1 exec 1>/vmfs/volumes/storage1/$VMNAME/$VMNAME.vmx # write the configuration echo #!/usr/bin/vmware echo config.version = '"'8'"' echo virtualHW.version = '"'4'"' echo floppy0.present = '"'TRUE'"' echo nvram = '"'TEST.nvram'"' echo powerType.powerOff = '"'default'"' echo powerType.powerOn = '"'default'"' echo powerType.suspend = '"'default'"' echo powerType.reset = '"'default'"' echo displayName = '"'$VMNAME'"' echo extendedConfigFile = '"'$VMNAME.vmxf'"' echo scsi0.present = '"'true'"' echo scsi0.sharedBus = '"'none'"' echo scsi0.virtualDev = '"'buslogic'"' echo memsize = '"'$VMMEMSIZE'"' echo scsi0:0.present = '"'true'"' echo scsi0:0.fileName = '"'$VMNAME.vmdk'"' echo scsi0:0.deviceType = '"'scsi-hardDisk'"' echo ide0:0.present = '"'true'"' echo ide0:0.clientDevice = '"'FALSE'"' echo ide0:0.deviceType = '"'cdrom-image'"' echo ide0:0.startConnected = '"'true'"' echo floppy0.startConnected = '"'false'"' echo floppy0.clientDevice = '"'true'"' echo ethernet0.present = '"'true'"' echo ethernet0.allowGuestConnectionControl = '"'false'"' echo ethernet0.networkName = '"'VM Network'"'' echo guestOS = '"'$VMOS'"' echo ide0:0.fileName = '"'/vmimages/tools-isoimages/winpe.iso'"' echo floppy0.fileName = '"'/dev/fd0'"' echo sched.cpu.affinity = '"'all'"' # close file exec 1>&- # make stdout a copy of FD 6 (reset stdout), and close FD6 exec 1>&6 exec 6>&- #$LOG -l:1 -ss:"VMX Configuration File Created Successfully" chmod 755 /vmfs/volumes/storage1/$VMNAME/$VMNAME.vmx # Create Disk & Register the .vmx configuration #$LOG -l:1 -ss:"Creating Virtual Disk" #Creates 300mb disk (can be modified for larger disk sizes) vmkfstools -c $VMDSIZE /vmfs/volumes/storage1/$VMNAME/$VMNAME.vmdk #$LOG -l:1 -ss:"Virtual Disk Created Successfully" #$LOG -l:1 -ss:"Registering .vmx Configuration" vmware-cmd -s register /vmfs/volumes/storage1/$VMNAME/$VMNAME.vmx #$LOG -l:1 -ss:"VMX Initialization Completed Successfully"