availability: January 2017
If you frequently want to rebuild a virtual machine, chances are that you grow tired of going through the web interface of vmware server: after your first installation , you have to enter the bios to select booting from PXE to have higher priority then HDD boot. But if you do a PXE install then, you have to make sure that you catch the installation reboot because otherwise it will loop doing the installation.
In the following scenario we will create a vmx and vmdk file usable to start a PXE-boot.
Let's see how we can make this work via the commandline.
Create a VMX template
Just as a side note: there exist alternatives to the vmware workstation and vmware server way of creating vmx files.
Stop the virtual Machine
If there is one registered, stop it before we will scratch it.
Unregister the Virtual Machine
Remove it from the inventory
Remove the previous files
remove and recreate the files in the Virtual Machine location = VMWARE_PATH
Re-create the virtual disk
First thing to recreate is the disk with disksize $DISK_SIZE and with the controller type that matches the VMX file we created.
$DISK_Controller has to correspond to the controller in the VMX. lsilogic for centos
"qemu-img" can be used as alternative, but it does not have an option to specify the controller type
Fix the Mac Addres
When you make a standard VMX, vmware assigns a self generated mac-address. In order to have the machine respond to the PXE-boot, we need to fix the mac address by removing the ethernet0.autogeneratedAddress and setting the addressType to 'static'.
The valid range for Mac-Addresses is : 00:50:56:00:00:00 - 00:50:56:3f:ff:ff
See http://sanbarrow.com/vmx/vmx-network-advanced.html for more detail.
We will get the mac-address from another source where the names and mac-addresses are managed. In our case we get it from the cobbler inventory
Add remote management
To enable the remote display of a virtual machine we set the correct VNC port , so when the machine boots we can access it on VNC_PORT
Ignore altered UID
Vmware has a way of detecting changes to virtual machines by using uuid's. For more details see http://communities.vmware.com/thread/189294
In the VM_TEMPLATE we had:
uuid.location = "56 4d 71 ec 89 ef d7 7a-c5 6a d5 e2 8d ec 91 dd" uuid.bios = "56 4d 71 ec 89 ef d7 7a-c5 6a d5 e2 8d ec 91 dd" vc.uuid = "52 ae 03 1b 89 41 c3 06-9f 1a 7c 35 f8 fc 3b 30"
If we would boot our machine, the startup would hang, asking you to confirm the following:
msg.uuid.altered:This virtual machine may have been moved or copied. In order to configure certain management and networking features VMware Server needs to know which. Did you move this virtual machine, or did you copy it? If you don't know, answer "I copied it".
Register the new virtual machine
Start the new virtual machine
Installation starts over PXE
If the Cdrom and Harddisk do not contain any operating system, the default for a vmware machine is to try to do a PXE boot over the network, which will start the installation and after a reboot you will get your system booting from the HDD install.
You can follow the installation using a VNC client to connect to the virtual machine booting on VNC_PORT