Installing ESXi without destroying the datastore

Hey guys,

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:

  1. boot the ESXi 4.x installer

  2. switch to the trusted shell using Alt-F1 (username is "root" in ESX 4.1. In ESX 4.0 and 3.5 type "unsupported")

  3. use scp to copy the script to the host. The command should look like "scp user@host:path/to/ ."

  4. use fdisk to figure out the disk names on the system with the command "fdisk -l"

  5. run the command "python -s <disk name>" (in my case the disk name is mpx.vmhba1:C0:T0:L0)

  6. 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!)

  7. switch back to the installer using Alt-F2

  8. continue with the installation and install onto the disk you opted to save the datastore

  9. before rebooting after the installation has completed, switch back to the shell (Alt-F1)

  10. re-run the python script, but this time use the command "python -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!).



0 Kudos
3 Replies

The script threw and error for me, but it did provide me with enough information to understand how to do this and develop a manual process.

Thank you, Patrick.

On the ESX host, boot the ESXi4 installer, hit alt+f1

Type ‘unsupported’, hit enter.

At password prompt, hit enter.

You now have a shell.

Type ‘fdisk -l’ to list the current partitions. Note the device name /dev/disk/<device>.

Write down the partition number, start and end blocks for the VMFS partition. NOTE: if the start block is less than 1000, this procedure will probably not work.

Hit ‘alt+f2’ and continue the ESXi installation – DO NOT REBOOT.

Hit ‘alt+f1’ to return to the shell.

Type ‘fdisk -l’ and note the highest number end block. If this is larger than your VMFS start block, this won’t work; give up; go home.

Type ‘fdisk /dev/disk/<device>’

Create a new partition by typing ‘n’.

Type ‘p’ for primary partition.

Input the partition number you noted above, probably 2 or 3.

Input the start block for your VMFS partition.

Input the end block for your VMFS partition.

Type ‘t’ and change the partition id to ‘fb’ for VMFS.

Type ‘w’ to write the partition table and exit fdisk.

Hit ‘alt-f2’ to switch back to the installation completion screen and allow it to reboot.

Observe that your new ESXi host can see your original VMFS partition.

Add VMs to inventory.

Have a party.

0 Kudos

Hey thanks for trying this out. Where/how did it end up failing?

0 Kudos

I didn't note the details, sorry. If I have the opportunity to try it again, I'll post the results.

0 Kudos