Corrupted GUID partition table on secondary hard drive

disk-utilityguidhard drivepartition

I have a Hackintosh computer, with a secondary hard drive installed with a bunch of data on it. I was trying to partition off part of the secondary hard drive to install Windows so I could dual boot, and I have managed to completely ruin the partition table and I'm afraid that I've lost my data. I used the Windows 10 installer to create a partition, but it did some weird stuff where it labeled my existing data partition as a recovery partition, so I ended up deleting everything that the installer did but I cannot see my old data back in OS X now. Here is the output of diskutil list:

/dev/disk1
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *2.0 TB     disk1
   1: DE94BBA4-06D1-4D40-A16A-BFD50179D6AC               1.9 TB     disk1s1

$ sudo gpt -r show disk1

       start        size  index  contents
           0           1         PMBR
           1           1         Pri GPT header
           2          32         Pri GPT table
          34      409606         
      409640  3798935504      1  GPT part - DE94BBA4-06D1-4D40-A16A-BFD50179D6AC
  3799345144   107683991         
  3907029135          32         Sec GPT table
  3907029167           1         Sec GPT header
$ sudo fdisk /dev/disk1
Disk: /dev/disk1    geometry: 243201/255/63 [3907029168 sectors]
Signature: 0xAA55
         Starting       Ending
 #: id  cyl  hd sec -  cyl  hd sec [     start -       size]
------------------------------------------------------------------------
 1: EE    0   0   2 - 1023 255  63 [         1 - 3907029167] <Unknown ID>
 2: 00    0   0   0 -    0   0   0 [         0 -          0] unused      
 3: 00    0   0   0 -    0   0   0 [         0 -          0] unused      
 4: 00    0   0   0 -    0   0   0 [         0 -          0] unused      

disk1s1 was where my data originally was, but it is no longer recognized by Disk Utility and I cannot mount it.

Is there anything I can do to repair this, or is my data all lost?

edit: I ran fsck and it recognizes the volume type and name, so it appears that it's still there:

sudo fsck_hfs -fy /dev/disk1s1
Password:
** /dev/rdisk1s1
   Executing fsck_hfs (version hfs-285).
** Checking Journaled HFS Plus volume.
   The volume name is Macintosh HD
** Checking extents overflow file.
** Checking catalog file.
** Checking multi-linked files.
** Checking catalog hierarchy.
** Checking extended attributes file.
** Checking volume bitmap.
** Checking volume information.
** The volume Macintosh HD appears to be OK.

I'm not sure how to mount the drive/fix the partition table, however.

edit2: so, using this method I was able to mount the disk and see the data. Is there an easy way to fix the partition?

Best Answer

  1. Boot to your OS X system
  2. Open Terminal and enter diskutil list
  3. Enter sudo gpt -r show diskX with X the device number of your external disk found in the previous output (probably 1 - below I assume it's 1 but use the disk number found in your environment in the commands below)
  4. Enter diskutil umountDisk disk1
  5. Remove the one and only partition:

    sudo gpt remove -i 1 disk1
    
  6. Add the EFI parititon:

    sudo gpt add -i 1 -b 40 -s 409600 -t C12A7328-F81F-11D2-BA4B-00A0C93EC93B disk1
    
  7. Add the main partition:

    sudo gpt add -i 2 -b 409640 -s 3798935504 -t 48465300-0000-11AA-AA11-00306543ECAC disk1
    
  8. Verify disk and volume:

    diskutil verifyDisk disk1
    diskutil verifyVolume disk1s2
    
  9. If you get an error in the last two steps add a comment.