Thursday, November 11, 2010

EFI Partition

How to format EFI partition on Mac OS X (use it for boot partition)?
- This is useful if the hard disk is formatted with GUID/GPT partition table.
- On Mac OS X Leopard (10.5 to 10.5.X)
diskutil eraseVolume "HFS+" "EFI" /dev/diskXs1
- On Mac OS X Snow Leopard (10.6 to 10.6.X)
newfs_hfs -v EFI /dev/diskXs1
- Note: change the "X" with hard disk number (e.g. 0, 1, etc). Check with diskutil list.

How to restore or recover EFI partition?
- This is useful if your EFI partition auto-mounted (it is not supposed to) whenever boot into Mac OS X.
- This happen when you use "diskutil eraseVolume "HFS+" "EFI" /dev/diskXs1" on Snow Leopard to format the EFI partition.
- Steps are:-
1) Boot with Windows Vista or 7 installation DVD if Windows is not installed or corrupted.
2) Follow on-screen instruction, just like you're going to install Windows.
3) Select Custom.
4) You will see the hard disk partitions. Delete or remove the first 200MB partition. Sometime there are more than one 200MB partition at the beginning of the hard disk partitions, delete all of it (at the beginning only). Reboot.
5) Boot into OSX.
6) Execute these commands (assuming it only one hard disk - /dev/rdisk0. Press enter for each commands):-
fdisk -e /dev/rdisk0
Enter 'help' for information
fdisk: 1> p
Disk: /dev/rdisk0    geometry: 19457/255/63 [312581808 sectors]
Offset: 0    Signature: 0xAA55
         Starting       Ending
 #: id  cyl  hd sec -  cyl  hd sec [     start -       size]
------------------------------------------------------------------------
 1: EE 1023 254  63 - 1023 254  63 [         1 -     409639]
 2: AF 1023 254  63 - 1023 254  63 [    409640 -  156290904] HFS+       
*3: 07 1023 254  63 - 1023 254  63 [ 156962688 -  155356936] HPFS/QNX/AUX
 4: 00    0   0   0 -    0   0   0 [         0 -          0] unused     
fdisk: 1> e 1
         Starting       Ending
 #: id  cyl  hd sec -  cyl  hd sec [     start -       size]
------------------------------------------------------------------------
 1: EE 1023 254  63 - 1023 254  63 [         1 -     409639]
Partition id ('0' to disable)  [0 - FF]: [EE] (? for help) EE
Do you wish to edit in CHS mode? [n] n
Partition offset [0 - 312581808]: [63] 1
Partition size [1 - 312581807]: [312581807]
fdisk:*1>  w

(just enter these)
y
u
q
y
7) Reboot
- Now the EFI partition should be look like this (Type = EFI):-
diskutil list/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *160.0 GB   disk0
   1:                        EFI                         209.7 MB   disk0s1
   2:                  Apple_HFS OSX                     80.0 GB    disk0s2
   3:       Microsoft Basic Data                         79.5 GB    disk0s3


- Use this command to format the EFI partition:-
newfs_hfs -v EFI /dev/disk0s1

Good luck! :D