accidentaly removed efi boot partition

hi guys,


I accidentally deleted EFI partition mac and now I can see the following when I run:


sudo gpt -r 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  157271616      2  GPT part - FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF


  157681256        408         


  157681664    7548928      3  GPT part - 48465300-0000-11AA-AA11-00306543ECAC


  165230592     262144         


  165492736   70215864      4  GPT part - 48465300-0000-11AA-AA11-00306543ECAC


  235708600    1269536      5  GPT part - 426F6F74-0000-11AA-AA11-00306543ECAC


  236978136          7         


  236978143         32         Sec GPT table


  236978175          1         Sec GPT header



so the 409640  157271616      2  GPT part - FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF partition is unmounted and I can't access it.


Any help to get this partition accessible again? I'm looking forward to someone that could help me on this.


many thanks


Marco

Posted on Jan 13, 2021 3:04 AM

Reply
Question marked as Top-ranking reply

Posted on Jan 13, 2021 9:09 AM

This looks like an APFS header. Run


sudo gdisk /dev/disk0

p (print)

t (change type)

2 (GPT2)

AF0A (Apple APFS)

p (print)

w (write)

y (yes)

q (quit, if necessary)


Reboot and test if you can see the APFS partition. Be aware that some versions of macOS have older APFS KEXTs which may not understand newer versions.


Similar questions

31 replies
Question marked as Top-ranking reply

Jan 13, 2021 9:09 AM in response to marks2510

This looks like an APFS header. Run


sudo gdisk /dev/disk0

p (print)

t (change type)

2 (GPT2)

AF0A (Apple APFS)

p (print)

w (write)

y (yes)

q (quit, if necessary)


Reboot and test if you can see the APFS partition. Be aware that some versions of macOS have older APFS KEXTs which may not understand newer versions.


Jan 13, 2021 7:51 AM in response to marks2510

Given the output you have posted, you seem to have


GPT1 - EFI

GPT2 - APFS (?)

GPT3 - HFS+

GPT4 - HFS+

GPT5 - Apple Boot (Recovery HD)


Can you post the output of


sudo dd if=/dev/rdisk0s2 count=5 2>/dev/null | hexdump -C


This will show the first five (5) blocks of the file system header.


Also, download and install GPT FDisk (https://sourceforge.net/projects/gptfdisk/) which will help us change the GPT Type.

Jan 13, 2021 8:39 PM in response to marks2510

marks2510 wrote:


diskutil apfs resizeContainer disk1 0g
Started APFS operation
Aligning grow delta to 40,600,002,560 bytes and targeting a new physical store size of 121,123,069,952 bytes
Determined the maximum size for the targeted physical store of this APFS Container to be 121,122,041,856 bytes
....
Growing APFS Physical Store disk0s2 from 80,523,067,392 to 121,123,069,952 bytes
Modifying partition map
Growing APFS data structures
Finished APFS operation

You should have your full disk space back.

Jan 13, 2021 8:39 AM in response to Loner T

sure, this is the output:


sudo dd if=/dev/rdisk0s2 count=5 2>/dev/null | hexdump -C


Password:


00000000  f0 62 ea b0 ff df 40 c0  01 00 00 00 00 00 00 00  |.b....@.........|


00000010  25 0a 29 01 00 00 00 00  01 00 00 80 00 00 00 00  |%.).............|


00000020  4e 58 53 42 00 10 00 00  c8 f8 2b 01 00 00 00 00  |NXSB......+.....|


00000030  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|


00000040  02 00 00 00 00 00 00 00  9c c2 54 2c 0d 3d 4b e1  |..........T,.=K.|


00000050  97 17 48 62 48 6a d7 58  8e 93 7b 00 00 00 00 00  |..HbHj.X..{.....|


00000060  26 0a 29 01 00 00 00 00  18 01 00 00 18 6c 00 00  |&.)..........l..|


00000070  05 8c 00 00 00 00 00 00  d6 18 00 00 00 00 00 00  |................|


00000080  18 00 00 00 68 4d 00 00  16 00 00 00 02 00 00 00  |....hM..........|


00000090  4a 4d 00 00 1e 00 00 00  cf d1 4d 00 00 00 00 00  |JM........M.....|


000000a0  3b b0 04 00 00 00 00 00  01 04 00 00 00 00 00 00  |;...............|


000000b0  00 00 00 00 64 00 00 00  7a 71 45 00 00 00 00 00  |....d...zqE.....|


000000c0  f9 31 04 00 00 00 00 00  fb 31 04 00 00 00 00 00  |.1.......1......|


000000d0  79 da 04 00 00 00 00 00  b1 71 45 00 00 00 00 00  |y........qE.....|


000000e0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|


*


000003d0  00 00 00 00 00 00 00 00  79 68 04 2e 00 00 00 00  |........yh......|


000003e0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|


*


000004f0  00 00 00 00 00 00 00 00  55 02 bc 00 00 00 00 00  |........U.......|


00000500  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|


00000510  d7 f9 f8 00 00 00 00 00  01 00 00 00 00 00 00 00  |................|


00000520  01 00 04 00 08 00 00 00  00 00 00 00 00 00 00 00  |................|


00000530  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|


*


00000560  00 00 00 00 00 00 00 00  80 74 19 cf 50 04 05 00  |.........t..P...|


00000570  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|


*


00000a00


I have also installed GPT

Jan 13, 2021 11:44 AM in response to Loner T

here is the diskutil list output:


/dev/disk0 (internal, physical):

  #:            TYPE NAME          SIZE    IDENTIFIER

  0:   GUID_partition_scheme            *121.3 GB  disk0

  1:            EFI EFI           209.7 MB  disk0s1

  2:         Apple_APFS Container disk1     80.5 GB  disk0s2

  3:         Apple_HFS maverik         3.9 GB   disk0s3

  4:         Apple_APFS Container disk2     36.6 GB  disk0s4


/dev/disk1 (synthesized):

  #:            TYPE NAME          SIZE    IDENTIFIER

  0:   APFS Container Scheme -           +80.5 GB  disk1

                 Physical Store disk0s2

  1:        APFS Volume Macintosh HD - Data   64.9 GB  disk1s1

  2:        APFS Volume Preboot         83.4 MB  disk1s2

  3:        APFS Volume Recovery        528.5 MB  disk1s3

  4:        APFS Volume VM           2.2 GB   disk1s4

  5:        APFS Volume Macintosh HD      11.0 GB  disk1s5


/dev/disk2 (synthesized):

  #:            TYPE NAME          SIZE    IDENTIFIER

  0:   APFS Container Scheme -           +36.6 GB  disk2

                 Physical Store disk0s4

  1:        APFS Volume disk0s4 - Data     11.2 GB  disk2s1

  2:        APFS Volume Preboot         81.3 MB  disk2s2

  3:        APFS Volume Recovery        528.8 MB  disk2s3

  4:        APFS Volume VM           2.1 GB   disk2s4

  5:        APFS Volume disk0s4         11.2 GB  disk2s5

Jan 13, 2021 1:54 PM in response to Loner T

sure:


Device Identifier:     disk1s5

  Device Node:        /dev/disk1s5

  Whole:           No

  Part of Whole:       disk1


  Volume Name:        Macintosh HD

  Mounted:          Yes

  Mount Point:        /


  Partition Type:      41504653-0000-11AA-AA11-00306543ECAC

  File System Personality:  APFS

  Type (Bundle):       apfs

  Name (User Visible):    APFS

  Owners:          Enabled


  OS Can Be Installed:    No

  Booter Disk:        disk1s2

  Recovery Disk:       disk1s3

  Media Type:        Generic

  Protocol:         PCI

  SMART Status:       Verified

  Volume UUID:        EAB9A645-6D87-4246-9EEA-6A0CCF4BF2CF

  Disk / Partition UUID:   EAB9A645-6D87-4246-9EEA-6A0CCF4BF2CF


  Disk Size:         80.5 GB (80523067392 Bytes) (exactly 157271616 512-Byte-Units)

  Device Block Size:     4096 Bytes


  Container Total Space:   80.5 GB (80523067392 Bytes) (exactly 157271616 512-Byte-Units)

  Container Free Space:   1.7 GB (1745248256 Bytes) (exactly 3408688 512-Byte-Units)

  Allocation Block Size:   4096 Bytes


  Read-Only Media:      No

  Read-Only Volume:     Yes


  Device Location:      Internal

  Removable Media:      Fixed


  Solid State:        Yes

  Hardware AES Support:   No


  This disk is an APFS Volume. APFS Information:

  APFS Container:      disk1

  APFS Physical Store:    disk0s2

  Fusion Drive:       No

  APFS Volume Group:     AA0157FE-907D-40D9-8479-B18E3587FA91

  FileVault:         No

  Locked:          No

Jan 13, 2021 3:14 PM in response to Loner T

ok just before I'm gonna run the last command that you sent me -> diskutil apfs deleteContainer disk2


I'm gonna double check with you that the -> +80.5 GB  disk1 partition is where I have all. my data and I don't have to delete it,

instead the -> +36.6 GB  disk2 can be deleted.


so this is what I am going to execute:


diskutil apfs deleteContainer disk2

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

accidentaly removed efi boot partition

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.