How to fix the error: "This disk doesn’t contain an EFI system partition"?

I get the following error and cannot start Bootcamp after accidentally deleting the EFI-partition of my main drive.

This disk doesn’t contain an EFI system partition. If you want to start up your computer with this disk or include it in a RAID set, back up your data and partition this disk.

Here is my diskutil list result :

/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *500.1 GB   disk0
   1:                  Apple_HFS                         209.7 MB   disk0s1
   2:          Apple_CoreStorage                         499.2 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
/dev/disk1
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                  Apple_HFS Macbook Pro            *498.9 GB   disk1
                                 Logical Volume on disk0s2
                                 A6AC962B-74A5-42E8-B84D-B5A7A6325432
                                 Unlocked Encrypted
/dev/disk3
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:        CD_partition_scheme                        *154.1 MB   disk3
   1:     Apple_partition_scheme                         134.2 MB   disk3s0
   2:        Apple_partition_map                         1.0 KB     disk3s0s1
   3:                  Apple_HFS BOLT! 4G E5372s         8.5 MB     disk3s0s2

And here is my sudo gpt -r show disk0 result :

start       size  index  contents
          0          1         PMBR
          1          1         Pri GPT header
          2         32         Pri GPT table
         34          6         
         40     409600      1  GPT part - 48465300-0000-11AA-AA11-00306543ECAC
     409640  975093952      2  GPT part - 53746F72-6167-11AA-AA11-00306543ECAC
  975503592    1269536      3  GPT part - 426F6F74-0000-11AA-AA11-00306543ECAC
  976773128          7         
  976773135         32         Sec GPT table
  976773167          1         Sec GPT header

The currently installed OS is Yosemite.

How do I fix that error?


Solution 1:

You can recreate the EFI System Partition (ESP) using the command-line tool gpt. Since you have to modify your current start device you need to boot to Internet Recovery Mode or an external (thumb) drive.

Additionally you need a valid EFI-partition or an image file of it.

Here is a similar question: How to fix broken EFI partition?. I have copied some of the steps of the accepted answer. Check all the warnings there before proceeding. So please credit the OP.

Preparation:

  • Backup your data.
  • Detach any external drive (especially your external Time Machine backup drive).
  • Restart to Internet Recovery Mode by pressing alt cmd R at startup.
    The prerequisites are the latest firmware update installed, either ethernet or WLAN (WPA/WPA2) and a router with DHCP activated.
    On a 50 Mbps-line it takes about 4 min (presenting a small animated globe) to boot to a recovery netboot image which usually is loaded from an apple/akamai server.

    I recommend ethernet because it's more reliable. If you are restricted to WIFI and the boot process fails, just restart your Mac until you succeed booting.

    Alternatively you may start from a bootable installer thumb drive (Mavericks or Yosemite) or a thumb drive containing a full system (Mavericks or Yosemite). The disk identifiers may be different then.

Rebuild the EFI-partition:

First you should get an overview of your disks and the partition layout:

  • Enter diskutil list
    Example listing:

    /dev/disk0
       #:                       TYPE NAME                    SIZE       IDENTIFIER
       0:      GUID_partition_scheme                        *500.1 GB   disk0
       1:                  Apple_HFS                         209.7 MB   disk0s1
       2:          Apple_CoreStorage                         499.2 GB   disk0s2
       3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
    /dev/disk1
       #:                       TYPE NAME                    SIZE       IDENTIFIER
       0:     Apple_partition_scheme                         *1.3 GB    disk1
       1:        Apple_partition_map                         30.7 KB    disk1s1
       2:                  Apple_HFS OS X Base System        *1.3 GB    disk1s2
    /dev/disk2
       #:                       TYPE NAME                    SIZE       IDENTIFIER
       0:                  Apple_HFS Macbook Pro            *498.9 GB   disk2
                                 Logical Volume on disk0s2
                                 A6AC962B-74A5-42E8-B84D-B5A7A6325432
                                 Unlocked Encrypted
    /dev/disk3-disk12 ...belong to the OS X Base System (your recovery system you booted to previously)
    

    Disk0 is your main internal disk device containing the EFI-partition (dis0s1), the CoreStorage partition (disk0s2) and the Recovery HD (disk0s3).

    Disk1 is a logical disk created by booting to the netboot image which contains a recovery system (OS X Base System = disk1s2) similar to the Recovery HD.

    Disk2 is also a logical disk residing in disk0s2 and it contains the CoreStorage stack.

  • Enter sudo gpt -r show disk0
    Example listing:

        start       size  index  contents
            0          1         PMBR
            1          1         Pri GPT header
            2         32         Pri GPT table
           34          6         
           40     409600      1  GPT part - 48465300-0000-11AA-AA11-00306543ECAC
       409640  975093952      2  GPT part - 53746F72-6167-11AA-AA11-00306543ECAC
    975503592    1269536      3  GPT part - 426F6F74-0000-11AA-AA11-00306543ECAC
    976773128          7         
    976773135         32         Sec GPT table
    976773167          1         Sec GPT header
    

    The partition with the index number 1 is the wrong formatted EFI-partition, the partition with index number 2 is your CoreStorage partition and the partition with index number 3 is your Recovery HD.
    The correct GUID for the EFI-partition is C12A7328-F81F-11D2-BA4B-00A0C93EC93B.

  • To manipulate the GPT you have to unmount all mounted volumes on disk0 (first the CoreStorage volume, which has its own disk identifier disk2 but resides on disk0, then disk0):

    diskutil unmountDisk disk2
    diskutil unmountDisk disk0
    
  • To delete your wrong EFI-partition enter:

    gpt remove -i 1 disk0
    
  • Now re-add the EFI-partition with the correct layout and type

    gpt add -b 40 -i 1 -s 409600 -t C12A7328-F81F-11D2-BA4B-00A0C93EC93B disk0
    
  • Enter exit and quit Terminal.

  • Reboot to your main volume

    This should sort out the partition itself, but as you've created an HFS partition in its place, you need to fix its format as well.

  • The format of the EFI System Partition is documented by Apple here. As you can see, they recommend you clone an existing ESP rather than recreating the file system with newfs_msdos. If you have an external drive with a GPT partition table (OSX install stick should have it), you can clone that.

    Make sure you have your disk and partition numbers the right way around or you may overwrite data:

    If disk1 is your external drive, and it contains an ESP as the first partition (disk1s1) and disk0 is the drive whose ESP (disk0s1) you want to fix, run this command:

    sudo dd if=/dev/disk1s1 of=/dev/disk0s1
    

    you have to enter an admin password.

    This will copy every single block of disk1's ESP and overwrite the corresponding block in disk0's ESP with it.

    Alternatively, take a gamble with newfs_msdos.