On Macs, the gpt command is the low-level partition editor required to configure the GPT. Please use an installation or recovery disk because booting from the recovery partition of the affected disk will mount it, making low-level operations impossible. It is also just good practice.
Display the mounted volumes:
Unmount the affected disk's volumes that are automatically mounted by the recovery system:
mac# diskutil unmount /Volumes/[volume name]
Display the partition table(replacing disk0 with disk* as necessary):
mac# gpt show disk0
Take a photograph of the displayed data. The sector numbers and sizes proved critical to restoring my disk.
Mac's "gpt" command does not offer the ability to save the partition table to a file so we need to boot another "unix" to do this. (Remember what I said about gpt tools not being mature?) As you can see in the images above, I had lost everything but "Systems" so the Mac couldn't boot. Fortunately, the sector numbers were correct and the other unix systems could see different pieces of the missing information.
Insert your selected unix system disk and restart your Mac, holding down the "Option" key before the startup chime. Select the unix system at the next prompt and run it. Open a terminal when ready.
If your system automatically mounts any disks, unmount them
Proceed very carefully from here on! These are the GPT editors in the systems I investigated: Ubuntu Linux(gdisk which might need to be downloaded), FreeBSD(gpart), NetBSD(gpt), OpenBSD(fdisk). While Linux's gdisk has an interactive mode and does not write changes unless you say so, all the other editors work in a "command mode.". We have to issue single commands with relevant options to perform a single operation that is FINAL. Please be careful.
I settled on NetBSD and Ubuntu but, as I mentioned, GPT utilities are not mature and I encountered issues in both. gpt did not properly display the entire partition information with the labels assigned by OS X and gdisk could not write changes to the misconfigured "special" partitions. gdisk had the more informative display but I felt gpt was more "powerful" (with great power comes…)
Both are able to backup and restore the raw partition table to a file so their incomplete interpretation of the data was not a showstopper. I used gpt for the backup.
On Linux enter "linux# gdisk /dev/sd[letter]" and then "p" to display the table.
Type "r" for recovery and you will have the option to backup to a file
On NetBSD enter "netbsd# gpt show wd[number]" to display the table.
Type "netbsd# gpt backup wd[number] > [file path]" to backup the table.
It was a relief to see that the structure was intact and that only the partition types and numbers were changed. My ultimate goal was to somehow get a bootable Mac Recovery Disk from the Recovery Partition. Reading about GPT partition types allowed me to set the correct type GUID and it became visible at boot. Unfortunately, the missing system partition and general "incorrectness" of the table prevented my Mac from completing the boot process. My next step was to copy that partition to a USB disk.
Continued in part3...