Partition map rebuild
Solution 1:
The disk lost its GUID partition table and the EFI volume was partly overwritten. The disk was mounted in an enclosure which doesn't properly report a logical block size of 512 bytes. Instead 4096 bytes are used. The disk itself has a physical block size of 4096 bytes.
After trying some known but actually unsuccessful methods (e.g. Disk Warrior or answers here at stackexchange: HFS+ invalid number of allocation blocks to recover the disk, we formatted an equally sized disk, dded
the EFI volume to a temporary file and recovered the partition table (including the main volume) by using the same standard values we got by formatting the empty disk.
The EFI of the previously partitioned (empty) disk was saved to a file with:
diskutil unmountDisk /dev/disk2
dd if=/dev/disk2s1 of=/Users/user/Desktop/disk2s1.raw
Repairing the corrupted disk:
The partly "repaired" but corrupted GUID partition table originally looked like this
sudo gpt -r show disk2
start size index contents
0 1 PMBR
1 1 Pri GPT header
2 4 Pri GPT table
6 34
40 409600 1 GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
409640 243781000
244190640 4 Sec GPT table
244190644 1 Sec GPT header
After removing the EFI partition with:
sudo gpt remove -i 1 /dev/disk2
and rewriting the GUID partition table with
sudo gpt destroy /dev/disk2
sudo gpt create /dev/disk2
the EFI volume and the main volumes were added with:
sudo gpt add -b 6 -i 1 -s 76800 -t C12A7328-F81F-11D2-BA4B-00A0C93EC93B /dev/disk2
sudo dd if=/Users/user/Desktop/disk2s1.raw of=/dev/disk2s1
sudo gpt add -b 76806 -i 2 -s 244081066 -t 48465300-0000-11AA-AA11-00306543ECAC /dev/disk2
The disk and the main volume were verified:
diskutil verifyDisk /dev/disk2
diskutil verifyVolume /dev/disk2s2
Finally the disk looks like this:
sudo gpt -r show disk2
start size index contents
0 1 PMBR
1 1 Pri GPT header
2 4 Pri GPT table
6 76800 1 GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
76806 244081066 2 GPT part - 48465300-0000-11AA-AA11-00306543ECAC
244157872 32768
244190640 4 Sec GPT table
244190644 1 Sec GPT header
All data was recovered.