Question

I made a huge mistake. I resized my Bootcamp Windows Partition and messed up with my Mac partition; without any data, since my sister needed my backup hard drive for something urgent.

To recover the data, I tried to install a new Mac partition onto the Bootcamp partition.

Now I try to recover the original Mac partition.

These are the outputs:

Testdisk:

     Partition                  Start        End    Size in sectors

 1 P EFI System                    40     409639     409600 [EF]
 2 P Windows Recovery Env      409640  400800263  400390624 [Ma]
 3 P Mac HFS                400800264  488965175   88164912 [Apple_HFS_Untitled_2]
 4 P Mac Boot               488965176  490234711    1269536 [Recovery HD]


diskutil list
/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *251.0 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2: DE94BBA4-06D1-4D40-A16A-BFD50179D6AC               205.0 GB   disk0s2
   3:                  Apple_HFS BOOTCAMP                45.1 GB    disk0s3
   4:                 Apple_Boot Recovery HD             650.0 MB   disk0s4
/dev/disk1
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *252.9 GB   disk1
   1:                        EFI EFI                     209.7 MB   disk1s1
   2:                  Apple_HFS Ohne Titel              252.5 GB   disk1s2
/dev/disk2
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *31.6 GB    disk2
   1:                 DOS_FAT_32 UNTITLED                31.6 GB    disk2s1
/dev/disk3
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     Apple_partition_scheme                        *21.0 MB    disk3
   1:        Apple_partition_map                         32.3 KB    disk3s1
   2:                  Apple_HFS rEFIt                   20.9 MB    disk3s2


sudo gpt show disk0
Password:
      start       size  index  contents
          0          1         PMBR
          1          1         Pri GPT header
          2         32         Pri GPT table
         34          6         
         40     409600      1  GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
     409640  400390624      2  GPT part - DE94BBA4-06D1-4D40-A16A-BFD50179D6AC
  400800264   88164912      3  GPT part - 48465300-0000-11AA-AA11-00306543ECAC
  488965176    1269536      4  GPT part - 426F6F74-0000-11AA-AA11-00306543ECAC
  490234712          7         
  490234719         32         Sec GPT table
  490234751          1         Sec GPT header
Thomass-MacBook-Pro:~ Thomas$ 
Was it helpful?

Solution

The partition GUID of disk0s2 (DE94BBA4-06D1-4D40-A16A-BFD50179D6AC) is probably wrong. It designates the partition as a Windows Recovery Environment, which is the ugly stepsibling of macOS' recovery partition. Changing the GUID of a partition doesn't modify the volume format! A wrong GUID usually renders a partition unbootable though.

It's rather unclear how and why the GUID has been modified.

Depending on your (former) macOS system version it should be either the GUID of an APFS, a CoreStorage or an HFS+ partition instead. To detect the proper GUID for disk0s2, use the method described here. If you remember the system version the steps to detect the partition type outlined there are usually not required.

Here, the system of the broken boot volume is known (macOS 10.5 Catalina). Catalina's boot partition type exclusively is APFS.


Then the standard procedure would be:

  1. Boot to another boot device (either Internet Recovery/macOS Recovery (alt-cmd-R), another Mac (with the broken Mac attached in Target Disk Mode) or a thumb drive. Preferred system version: the same as the "broken" one. Below I assume you booted to Internet Recovery/macOS Recovery Catalina!
  2. Open Terminal and enter:

    diskutil list
    

    to determine the disk number of the internal disk of the "broken" Mac (below I assume it's disk0 - apply accordingly)

  3. Get the partition table with gpt:

    gpt -r show /dev/disk0
    

    Depending on the boot drive you have to prepend sudo and/or disable SIP here, if you want to execute gpt ...

    sudo is required if you boot to another Mac/thumb drive (sw_vers < 10.15) and using an admin account. sudo & disable SIP is required booted to another Mac/thumb drive (sw_vers >= 10.15) and using an admin account. Booting to Internet Recovery 10.15 doesn't require additonal steps.

  4. Unmount the broken Mac's internal drive/volumes

    diskutil umount disk0s3
    diskutil umountDisk disk0
    
  5. Remove the second partition

    gpt remove -i 2 /dev/disk0
    
  6. Unmount the broken Mac's internal drive/volumes

    diskutil umount disk0s3
    diskutil umountDisk disk0
    
  7. add the second partition with the proper GUID

    gpt add -i 2 -b 409640 -s 400390624 -t 7C3457EF-0000-11AA-AA11-00306543ECAC disk0
    
  8. Verify the disk and the volume

    diskutil list
    diskutil verifyDisk disk0
    diskutil verifyVolume diskXsY #use the proper diskXsY of the APFS volume in the diskutil list output
    
Licensed under: CC-BY-SA with attribution
Not affiliated with apple.stackexchange
scroll top