Sign up ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I have an iMac running OSX Lion. I also installed bootcamp and Windows 7. During the install of Windows 7 I wasn't paying complete attention and deleted and formatted the EFI partition.

I didn't really realise the significance of this as the machine continued to work fine, booting both into Windows and OSX.

I did notice that the EFI firmware updates failed to install, but paid this no mind.

However now I want to install Mountain Lion and there's a whole heap of trouble. Mountain Lion won't install without a valid EFI partition.

Here's my partition table.

   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *1.0 TB     disk0
   1:                  Apple_HFS EFI                     209.7 MB   disk0s1
   2:                  Apple_HFS Macintosh HD            799.0 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
   4:       Microsoft Basic Data BOOTCAMP                200.3 GB   disk0s4

As you can see I've had a go at fixing the EFI partition with the following command:

newfs_hfs -v EFI /dev/disk0s1

This didn't seem to create the correct type of partition, it created an Apple_HFS instead of EFI.

My question is (without formatting the disk) how do I create an EFI partition?

Thanks Rich

share|improve this question

4 Answers 4

up vote 18 down vote accepted

You can recreate the EFI System Partition (ESP) using the command-line gpt tool. It should start at sector 40, and it should be 409600 sectors (exactly 200MiB) long. The GPT entry's type should be C12A7328-F81F-11D2-BA4B-00A0C93EC93B, and if you have a hybrid MBR, the type there should be EE. The format is actually a subset of FAT, not HFS+. You can read the GPT using the command sudo gpt -r show disk0 in a Terminal window, this produces output that looks something like this:

      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  447801712      2  GPT part - 48465300-0000-11AA-AA11-00306543ECAC
  448211352    1269536      3  GPT part - 426F6F74-0000-11AA-AA11-00306543ECAC
  449480888   40753831         
  490234719         32         Sec GPT table
  490234751          1         Sec GPT header

You can see the correct EFI partition at index 1. If that line doesn't match exactly, the easiest way is to delete the partition in its place and recreate it.

Make sure you know what you're doing before proceeding from here - you may lose data if you mess up.

You can't edit the partition table using gpt while partitions on the drive are mounted, so you'll need to boot from another drive (e.g. a USB stick with the OSX installer) or run the mac in target disk mode and do the partitioning from another mac. You may need to unmount any automatically mounted volumes using diskutil unmountDisk disk0 before proceeding, and in between commands.

To delete your "bad" EFI partition, run this command:

sudo gpt remove -i 1 disk0

Make sure disk0 is really the disk you want to change - the numbers can change between reboots. Also, this will only work if you already have a non-ESP partition in the place of the ESP - if not, deleting partition 1 could be disastrous! In this case, you'll need to move the indices along, as I think the ESP must have index 1. By the sound of it, this won't be necessary in your case.

Once deleted, re-add the partition with the correct layout and type:

sudo gpt add -b 40 -i 1 -s 409600 -t C12A7328-F81F-11D2-BA4B-00A0C93EC93B disk0

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

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.

share|improve this answer
Thanks for the very detail reply. I did eventually manage to fix my problem using iParition. However reading through your method, seems to be the exact method I was looking for had iParition not existed. Thanks again, I'm marking this as the correct answer. – Rich Aug 2 '12 at 10:43
This method worked great for me on 10.6 after GParted cloned the ESP to block 2048 on an SSD. Booting an install disk and following the above, I used dd to store the cloned ESP in a file before deleting, re-creating, and writing it back. Thanks! – Nick Westgate Oct 14 '12 at 12:03
Worked great on my mbp with ssd hybrid drive. EFI was overwritten by a grub install and this method worked perfectly to bring it back. – sean_m Mar 28 '13 at 17:00
Thanks for sharing. To save typing you can actually specify EFI as partition type instead of the GUID: sudo gpt add -b 40 -i 1 -s 409600 -t EFI disk0 – user55751 Aug 24 '13 at 15:37
What exactly did you do with iPartition @Rich ? – laarsk Jan 10 '14 at 21:23

Try this:

  1. Back up drive on time machine.
  2. Restart, rebooting on Lion install disk.
  3. Go to Disk Utility.
  4. Erase Partition.
  5. Erase HD.
  6. Re-erase partition again, this time giving it a name.
  7. Click on HD.
  8. Verify HD to confirm EFI error message no longer appears.
  9. Go back to install screen.
  10. Choose restore from back up.
share|improve this answer

Try iPartition 3 or above. Go to view menu and display system devices. Since it is missing the 200mb EFI, shrink the first partition on disk hopefully by 200mb. Create new partition, then in the disk inspector window there are tabs. You can choose a many different type of file system. Just choose EFI System Partition.

share|improve this answer

This fixed the issue for me.

1) Backup the Bootcamp partition using Winclone

2) Backup Mac OSX drive using Carbon Copy Clone to an external drive

3) Install Mountain Lion to a flash drive or external drive

4) Purchase a copy of iPartition, download to flash drive or external drive

5) Reboot while holding the Option key to get boot menu

6) Select the flash or external drive to boot from

7) Extract iPartition and execute. Select View and Inspector from the dropdown menu.

8) Select Bootcamp Partition under the Partition tab and check off the two boxes in the list (Active and Visible in Windows) then close the box.

9) The Go button should be illuminated, if not then grow the Bootcamp partition a little. Mine is 2 TB OSX, 500 GB Windows on a 2.5 TB Drive.

10) Once the Go button is pressed it should start to process; although you may have to kill any process that keeps it from running (Done with Activity Monitor)

11) Once finished shut down and remove the external boot device and then power the Mac back on. It should be fixed and boot normal -- at least mine did.

I'm running an iMac 27, 3.2 GHz Intel Core i3 with 16 GB RAM and a 2.5 TB hard drive. Most of the items listed I had already done prior to Mountain Lion install except for a current backup of the Bootcamp drive. Winclone worked even though Bootcamp wouldn't boot and the restore process generated an error writing the MBR. I just ignored the error and continued onward with the rest of the process. Apparently Mountain Lion messed with the PMBR or the EFI and even rEFIt wouldn't fix it but whatever iPartition did; its now fixed.



I highly recommend Carbon Copy Clone for backing up the OSX partition because it can create a bootable clone that I've never had fail.

I'm sure others have had success elsewhere in resolving this issue and appreciate everyone who has posted what they have done as it helped me resolve this issue on my iMac.

Thanks to everyone and I hope this helps someone else. (Posted in Apple Forum)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.