MacBook – Create an EFI partition

efihard drivemacbook propartition

I had the following problem with my internal HD. When I started my mac, after the logo loaded the screen went black and an error panel with the message: "Unapproved caller. SecurityAgent may only be invoked by Apple software" showed. I've had HD problems before so I have an external HD with Mac OS X installed. I used it to boot Mac OS (with no problems) and used Disk utility to repair the ESP (disk0s1 partition of my internal HD), but the partition was deleted in this process. My internal HD (disk0) now looks like this:

enter image description here

enter image description here

I have a backup of my internalHD on disk1, so I could just delete the disk and reinstall everything but I'm curious if the HD can be restored without doing this, so no worries about data loss if the attempt fails.

My thoughts on how to solve this are to implement the following procedure:

  1. Copy the ESP from disk1, and add it to a new partition on disk0 (I don't know if this can be done simultaneously, so the newly created partition has the exact size of the ESP, or if I need to create a partition and then copy the ESP into it).
  2. Move the newly created partition from disk0s3 to disk0s1, and then disk0s3 (internal HD) to disk0s2.

I don't know if this will solve the problem, of it can be done, and if so, how to do it.

Any suggestions are welcome!

Best Answer

Googling the error message I get a plethora of different causes: e.g. no space on the main volume, broken SATA cables etc.

So restoring or rebuilding the EFI partition probably won't solve your problem.

Recreating a/the EFI partition should be easy though:

  • Create some OS X installer thumb drive
  • Detach your external drive
  • Boot to the thumb drive.
  • Open Terminal in the menubar > Utilities
  • Enter diskutil list to get the disk identifier of your internal disk (probably disk0) - you will get about 12-14 disks almost all of them related to the thumb drive. Check the sizes to get the right one - below I assume it's disk0.
  • Unmount disk0 with diskutil umountDisk disk0
  • Check partition table:

    gpt show -r /dev/disk0
    
  • Remove the two existing partitions:

    gpt remove -i 1 /dev/disk0
    gpt remove -i 2 /dev/disk0
    
  • Create a new partition and re-add the other two:

    gpt add -i 1 -b 40 -s 409600 -t C12A7328-F81F-11D2-BA4B-00A0C93EC93B /dev/disk0
    gpt add -i 3 -b 1952255592 -s 1269536 -t 426F6F74-0000-11AA-AA11-00306543ECAC /dev/disk0
    gpt add -i 2 -b 409640 -s 1951845952 -t 48465300-0000-11AA-AA11-00306543ECAC /dev/disk0
    
  • If the disk is stubborn destroy the gpt and a add a new one:

    gpt destroy /dev/disk0
    gpt create -f /dev/disk0
    

    Now repeat the previous step and add the three partitions.

  • Attach the external drive
  • Get the disk identifier of the external drive with diskutil list (probably disk14 or even higher - below I assume it's disk14)
  • Unmount disk0 with diskutil umountDisk disk0
  • Unmount disk14 with diskutil umountDisk disk14
  • Clone the EFI partition of the external drive to your internal drvie with:

    dd if=/dev/disk14s1 of=/dev/disk0s1 bs=1m
    
  • Enter reboot to reboot your Mac