1

I wonder if someone can help me with my mess. I created hybrid MBR which was working in the beginning, The I decided to delete the Bootcamp partition from the disk utility. This is where the things got messed up. Then I tried following this guide because I had the original data:

Disk /dev/disk1: 1000215216 sectors, 476.9 GiB
Sector size (logical): 512 bytes
Disk identifier (GUID): DF8BA5A4-2A3A-4A1B-9F1F-AA6A6332D9A5
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 1000215182
Partitions will be aligned on 8-sector boundaries
Total free space is 3213 sectors (1.6 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1              40          409639   200.0 MiB   EF00  EFI System Partition
   2          409640       707245575   337.0 GiB   AF0A  CATALINA
   3       707246080      1000212479   139.7 GiB   0700

Command (? for help): c
Partition number (1-3): 3
Enter name: WIN10APFSL

Command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/disk1.
Warning: The kernel may continue to use old or deleted partitions.
You should reboot or remove the drive.
The operation has completed successfully.
g5@G5s-Mac-Pro ~ % sudo gdisk /dev/disk1
GPT fdisk (gdisk) version 1.0.4

Partition table scan:
  MBR: hybrid
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with hybrid MBR; using GPT.

Command (? for help): p
Disk /dev/disk1: 1000215216 sectors, 476.9 GiB
Sector size (logical): 512 bytes
Disk identifier (GUID): DF8BA5A4-2A3A-4A1B-9F1F-AA6A6332D9A5
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 1000215182
Partitions will be aligned on 8-sector boundaries
Total free space is 3213 sectors (1.6 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1              40          409639   200.0 MiB   EF00  EFI System Partition
   2          409640       707245575   337.0 GiB   AF0A  CATALINA
   3       707246080      1000212479   139.7 GiB   0700  WIN10APFSL

And I did

sudo gpt remove -i 2 /dev/disk3

Attempted to add:

sudo gpt add -i 2 -b 409640 -s 707245575 -t apfs /dev/disk3

But got this error:

gpt add: /dev/disk3: error: no space available on device

This is the current state now:

 start        size  index  contents
           0           1         MBR
           1           1         Pri GPT header
           2          32         Pri GPT table
          34           6         
          40      409600      1  GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
      409640   706835936      2  MBR part 175
   707245576   292969607         
  1000215183          32         Sec GPT table
  1000215215           1         Sec GPT header

1 Answer 1

1

Well, nobody answered, but I was able to recover my APFS volume. It is important to mention that you have to have knowledge of your partition layout for successful restore. Hybrid MBR spans the entire volume and when I removed the incorrectly positioned volume the Hybrid MBR shrinked down to that point not leaving additional space and I got the error:

gpt add: /dev/disk3: error: no space available on device

I was able to fix it using:

sudo gdisk /dev/disk6
Password:
GPT fdisk (gdisk) version 1.0.5

Partition table scan:
  MBR: hybrid
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with hybrid MBR; using GPT.

Command (? for help): p
Disk /dev/disk6: 1000215216 sectors, 476.9 GiB
Sector size (logical): 512 bytes
Disk identifier (GUID): DF8BA5A4-2A3A-4A1B-9F1F-AA6A6332D9A5
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 1000215182
Partitions will be aligned on 8-sector boundaries
Total free space is 999805549 sectors (476.7 GiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1              40          409639   200.0 MiB   EF00  EFI System Partition
   2          409640       707245575   337.0 GiB   FFFF  CATALINA

Command (? for help): x

Expert command (? for help): n

Expert command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/disk6.
Warning: The kernel may continue to use old or deleted partitions.
You should reboot or remove the drive.
The operation has completed successfully.

That converted from Hybrid to Protective MBR (regular GPT). But still APFS did not have the correct code:

sudo gdisk /dev/disk6
GPT fdisk (gdisk) version 1.0.5

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.

Command (? for help): p
Disk /dev/disk6: 1000215216 sectors, 476.9 GiB
Sector size (logical): 512 bytes
Disk identifier (GUID): DF8BA5A4-2A3A-4A1B-9F1F-AA6A6332D9A5
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 1000215182
Partitions will be aligned on 8-sector boundaries
Total free space is 999805549 sectors (476.7 GiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1              40          409639   200.0 MiB   EF00  EFI System Partition
   2          409640       707245575   337.0 GiB   FFFF  CATALINA

So then I was able to issue:

sudo gpt add -i 2 -b 409640 -s 707245575 -t apfs /dev/disk6
/dev/disk6s2 added

sudo gdisk /dev/disk6                                          
GPT fdisk (gdisk) version 1.0.5

Warning: Devices opened with shared lock will not have their
partition table automatically reloaded!
Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.

Command (? for help): p
Disk /dev/disk6: 1000215216 sectors, 476.9 GiB
Sector size (logical): 512 bytes
Disk identifier (GUID): DF8BA5A4-2A3A-4A1B-9F1F-AA6A6332D9A5
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 1000215182
Partitions will be aligned on 8-sector boundaries
Total free space is 292559974 sectors (139.5 GiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1              40          409639   200.0 MiB   EF00  EFI System Partition
   2          409640       707655214   337.2 GiB   AF0A  CATALINA

Now the APFS restored the correct code AF0A and it reappeared in the disk utility and I could browse my files again.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .