2

I recently did a not-so-intelligent thing: I was installing Win 7 64bit on a new PC and I took my old Mac-formatted 4TB external HDD and mounted it internally on the PC.

What I did not realize was that Win 7 cannot recognize HDD's with more than 3TB capacity. While I was installing Win 7, it destroyed the original GPT partition map of the 4TB drive and replaced it with a MBR. Now I am left with an unrecognizable disk, both by Windows and by my MacBook Pro with Mavericks on.

Here is some of the info that I got from Terminal:

Rians-MacBook-Pro:~ RVL$ sudo gpt -r -vvv show -l /dev/disk1
gpt show: /dev/disk1: mediasize=4000787025920; sectorsize=4096; blocks=976754645
gpt show: /dev/disk1: MBR at sector 0
gpt show: /dev/disk1: Pri GPT at sector 1
gpt show: /dev/disk1: GPT partition: type=48465300-0000-11AA-AA11-00306543ECAC, 
start=6, size=51200
gpt show: /dev/disk1: GPT partition: type=48465300-0000-11AA-AA11-00306543ECAC, 
start=51206, size=976670666
gpt show: /dev/disk1: Sec GPT at sector 976754644
      start       size  index  contents
          0          1         MBR
          1          1         Pri GPT header
          2          4         Pri GPT table
          6      51200      1  GPT part - "EFI System Partition"
      51206  976670666      2  GPT part - "Mac Ext 6"
  976721872      32768         
  976754640          4         Sec GPT table
  976754644          1         Sec GPT header

Is there any way that I can restore the original GPT map and of course the data on the disk? What was particularly troubling was the following:

Rians-MacBook-Pro:~ RVL$ sudo fdisk /dev/disk1
Password:
Disk: /dev/disk1    geometry: 60800/255/63 [976754645 sectors]
Sector size: 4096 bytes
Signature: 0xAA55
         Starting       Ending
 #: id  cyl  hd sec -  cyl  hd sec [     start -       size]
------------------------------------------------------------------------
 1: 00    0   0   0 -    0   0   0 [         0 -          0] unused      
 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 

Does the above mean all the data is destroyed or is there a ray of hope. Is there anybody out there who can help? Thanks!

RianvL
  • 21
  • 2

1 Answers1

2

There is hope if Windows didn't write anything to disk (except the MBR). The steps below overwrite the bogus MBR and replaces it by a proper PMBR and a GUID partition table. All previous entries will be restored.

  • Attach the external drive to a Mac
  • Open Terminal and enter diskutil list and sudo gpt -r show /dev/diskX with X the disk identifier of the 4 TB drive (e.g. if you find that the disk identifier is disk1, replace in the commands above and below diskX by disk1).
  • Unmount the disk with diskutil umountDisk /dev/diskX
  • Enter sudo dd if=/dev/random of=/dev/diskX count=1 bs=512 to overwrite the MBR
  • Unmount the disk again with diskutil umountDisk /dev/diskX
  • Enter sudo gpt destroy /dev/diskX #just in case, this might fail
  • Then enter sudo gpt create /dev/diskX
  • if the last command fails you may overwrite the MBR again with sudo dd if=/dev/random of=/dev/diskX count=1 bs=4096 and reenter the last command: sudo gpt create /dev/diskX
  • Enter sudo gpt -r show /dev/diskX and check if PMBR and GUID partition header/table occupy the first six blocks (block0-block5). This is the case if the disk controller reports a block size of 4096 Bytes instead of 512 bytes.*

    In case of a 4096 logical block size the GUID partition table should look like this now:

    gpt show: /dev/diskX: Sec GPT at sector 976754644
          start       size  index  contents
              0          1         MBR
              1          1         Pri GPT header
              2          4         Pri GPT table
              6  976754634           
      976754640          4         Sec GPT table
      976754644          1         Sec GPT header
    
  • Then re-populate the GUID partition table with the above data (the type of the EFI partition is different though):

    sudo gpt add -b 6 -i 1 -s 51200 -t C12A7328-F81F-11D2-BA4B-00A0C93EC93B /dev/diskX
    sudo gpt add -b 51206 -i 2 -s 976670666 -t 48465300-0000-11AA-AA11-00306543ECAC /dev/diskX
    
  • Check the disk and the volume with

    diskutil verifyDisk /dev/diskX
    diskutil verifyVolume /dev/diskXs2
    

* Add a comment if you get a different list after the steps sudo gpt create /dev/diskX -> sudo gpt -r show /dev/diskX e.g the PMBR and the GUID partition table occupy the first 34 blocks (block0-block33). Then the disk controller reports a block size of 512 Bytes.

klanomath
  • 66,391
  • 9
  • 130
  • 201
  • I did get a different list Rians-MacBook-Pro:~ RVL$ sudo gpt -r show /dev/disk2 start size index contents 0 1 PMBR 1 1 Pri GPT header 2 4 Pri GPT table 6 976754634 976754640 4 Sec GPT table 976754644 1 Sec GPT header The original list had the EFI System Partition listed at 6 51200. – RianvL Jan 27 '16 at 15:35
  • For the first time since the calamity, I can see the Drive being mounted on the Desktop with its original name. That's encouraging. But I did a check as you suggested, and verifyDisk reports various discrepancies. What I thought of doing was to make a shadow copy of the disk to another of the same size with Techtool Pro, and afterwards repairing the file structures on the copy. Do you think that will fix the alignment of partitions with sectors/ cylinders? – RianvL Jan 27 '16 at 20:38
  • @RianvL Btw sudo gpt -r -vvv show -l /dev/disk1should yield the same as the list in your question except a PMBR instead the MBR and a different type for the EFI partition – klanomath Jan 27 '16 at 20:44
  • @RianvL Sorry i made an copy & paste error with the EFI type: the correct type is C12A7328-F81F-11D2-BA4B-00A0C93EC93B. – klanomath Jan 27 '16 at 20:48
  • @RianvL To correct this do 0. Check disk identifier 1. diskutil umountDisk /dev/diskX 2. sudo gpt remove -i 1 /dev/diskX 3. diskutil umountDisk /dev/diskX 4. sudo gpt add -b 6 -i 1 -s 51200 -t C12A7328-F81F-11D2-BA4B-00A0C93EC93B /dev/diskX. – klanomath Jan 27 '16 at 20:52
  • Thank you so much! I have been able to recover the whole drive with your help! You are my hero. All my stuff is on that disk and I am now making a backup to another disk just to be safe. I know, I should have done that from the start, but I will not make that mistake again. Thanks again! – RianvL Feb 04 '16 at 20:28