I created a script that I thought people might find useful. It allows you to install ESXi 4.x installable over the top of an ESX installation without erasing your datastore or trashing any virtual machines. I've successfully used it to install the ESXi 4.1 beta over the top of ESX 3.5 and ESX 4.0. The key to it working really comes down to where your VMFS datastore sits on the disk, so it should work fine for ESX 3.5 and later installations. Keep in mind that the script may not work, so don't assume it's bulletproof. **ALWAYS BACK UP YOUR DATA**
Here are the steps to get it to work:
boot the ESXi 4.x installer
switch to the trusted shell using Alt-F1 (username is "root" in ESX 4.1. In ESX 4.0 and 3.5 type "unsupported")
use scp to copy the script to the host. The command should look like "scp user@host:path/to/save_vmfs.py ."
use fdisk to figure out the disk names on the system with the command "fdisk -l"
run the command "python save_vmfs.py -s <disk name>" (in my case the disk name is mpx.vmhba1:C0:T0:L0)
write down the geometry information that is printed out. You shouldn't need to use it, however if the power kicks out in the middle of your installation or if something goes bad you'll need it to restore the datastore. If the datastore couldn't be saved it should give you a warning message saying it's not going to work. *** IF YOU DON'T WRITE THIS DOWN YOU COULD LOSE YOUR DATASTORE *** (and double check it too!)
switch back to the installer using Alt-F2
continue with the installation and install onto the disk you opted to save the datastore
before rebooting after the installation has completed, switch back to the shell (Alt-F1)
re-run the python script, but this time use the command "python save_vmfs.py -r <disk name>". It will then rewrite the partition table with the VMFS datastore you already had on the disk.
If you are unfortunate enough to have the power yanked during your installation, or if you accidentally reboot before restoring, just boot back into the ESXi installer, re-copy the script to the install environment (described above) and use the command "python save_vmfs -r -g <start>,<end> <disk name>".
Let me know if it works for you or any questions/comments. Feedback would be greatly appreciated (particularly failure cases!).
save_vmfs.py 5.5 K