ESXi installation failed with error "partedUtil failed with message: Error: The primary GPT table states that the backup GPT is located beyond the end of disk"

Sometimes installation of VmWare ESXi failed (between 5% and 8%) with the following error:
"partedUtil failed with message: Error: The primary GPT table states that the backup GPT is located beyond the end of disk. This may happen if the disk has shrunk or partition table is corrupted. ... Error: Can't have a partition outside the disk! Unable to read partition table for device..."
This issue may occur if you just created RAID array and created logical disks (LUN), but didn't create any partitions and didn't format them. The most strange, that this error may happen when you created RAID10, and RAID5 array does not generate the error and ESXi installs normal.
Solution
Anyway, you should try the following solution: boot with any iso-image, where you can create partitions and format them. There just create any partition and format it. In my case I did this with Windows Server 2008 R2 installation image (mostly because I could load disk controller drivers there).
After that ESXi installed without any errors.
- Hits: 107690
I booted then a live linux iso (deft8) and then used the command "gdisk" which reported an erroneus GPT, which was easy to fix using the following commands:
===============================
deft8 ~ % gdisk /dev/sda
GPT fdisk (gdisk) version 0.8.5
Warning! Disk size is smaller than the main header indicates! Loading
secondary header from the last sector of the disk! You should use 'v' to
verify disk integrity, and perhaps options on the experts' menu to repair
the disk.
Warning! One or more CRCs don't match. You should repair the disk!
Partition table scan:
MBR: not present
BSD: not present
APM: not present
GPT: damaged
Found invalid MBR and corrupt GPT. What do you want to do? (Using the
GPT MAY permit recovery of GPT data.)
1 - Use current GPT
2 - Create blank GPT
Your answer: 2
Command (? for help): p
Disk /dev/sda: 46883828912 sectors, 21.8 TiB
Logical sector size: 512 bytes
Disk identifier (GUID): F9F7FE7D-3541-4078-91BE-DCBF41759FAC
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 46883828878
Partitions will be aligned on 2048-sector boundaries
Total free space is 46883828845 sectors (21.8 TiB)
Number Start (sector) End (sector) Size Code Name
Command (? for help): w
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!
Do you want to proceed? (Y/N): Y
OK; writing new GUID partition table (GPT) to /dev/sda.
The operation has completed successfully.
deft8 ~ %
===============================
No need to create a partition, after fixing the GPT the esxi installed without problems ;-)
Hope this helps others, too.
Thanks for another fix. I'm too bad in linux so I even didnt try this way.
I'm wondering, if ESXi distrib have built-in gdisk or some similar command...
But doing what Sergio wrote did the trick! :)
somewhere during ESXi installer,
note the /dev/disks/* identifier of the disk you want to fix
press alt-f1.
login root/
partedUtil --help
note the /dev/disks/* identifier
press alt+f1 during esxi installer
root/[no password]
partedUtil --help
partedUtil mklabel [/dev/disks/whatever] msdos
this overwrites the borked partition table, which we might have encountered.
[tested on dl380 gen10, P408i-a and 2x480gb ssd's with raid1]
Windows Server 2012 USB.
Perfect, that worked right in the installer, you are amazing!
partedUtil getptbl /vmfs/devices/disks/naa.600508b1001c2bac8b8d1f8ed64c48d8
Error: Function not implemented during read on /dev/disks/naa.600508b1001c2bac8b8d1f8ed64c48d8
Error: The primary GPT table states that the backup GPT is located beyond the end of disk. This may happen if the disk has shrunk or partition table is corrupted. Fix, by writing backup table at the end? This will also fix the last usable sector appropriately as per the new reduced size. diskPath (/dev/disks/naa.600508b1001c2bac8b8d1f8ed64c48d8) diskSize (3906963632) AlternateLBA (3907029167) LastUsableLBA (3907029134)
Warning: The available space to /dev/disks/naa.600508b1001c2bac8b8d1f8ed64c48d8 appears to have shrunk. This may happen if the disk size has reduced. The space has been reduced by (65536 blocks). You can fix the GPT to correct the available space or continue with the current settings ? This will also move the backup table at the end if it is not at the end already. diskSize (3906963632) AlternateLBA (3907029167) LastUsableLBA (3907029134) NewLastUsableLBA (3906963598)
gpt
243197 255 63 3906963632
Solution:
partedUtil mklabel /vmfs/devices/disks/naa.600508b1001c2bac8b8d1f8ed64c48d8 msdos
After fix
partedUtil getptbl /vmfs/devices/disks/naa.600508b1001c2bac8b8d1f8ed64c48d8
msdos
243197 255 63 3906963632