How to change the GPT partition type of an EFI partition

bootefipartition

I have a perplexing problem with the EFI partition on my boot SSD. The GPT partition type is "Microsoft Basic Data". On all other drives in my system, including my Carbon Copy Cloner clone of my boot drive, the partition type is "EFI" (see below):

$ diskutil list
/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *512.1 GB   disk0
   1:       Microsoft Basic Data EFI                     209.7 MB   disk0s1
   2:                  Apple_HFS Tims Boot SSD           498.7 GB   disk0s2
/dev/disk1
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *960.2 GB   disk1
   1:                        EFI EFI                     209.7 MB   disk1s1
   2:                  Apple_HFS Users                   959.9 GB   disk1s2

...

/dev/disk4
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *512.1 GB   disk4
   1:                        EFI EFI                     209.7 MB   disk4s1
   2:                  Apple_HFS Tims Boot SSD Clone     511.8 GB   disk4s2

My system boots just fine, but it appears to be loading the bootloader (Clover in this case) from the /Users drive (disk1) instead of from the boot SSD (disk0), and I think the incorrect GPT partition type is to blame.

I tried to update the partition type using the "asr adjust" command as outlined at https://unix.stackexchange.com/questions/58705/mac-os-x-partition-type-problem, but it doesn't work and gives me a very unhelpful error message:

$ sudo asr adjust --target /dev/disk0s1 --settype EFI
asr: Volume adjustment failed: Unknown error: -123

I have found information about other possible ways to set the GPT partition type through Google searches, but all the other methods seem risky, with warnings about erasing the partition in question, etc.

Does anyone know how I can fix this?

Best Answer

I recreated your problem using a 4 GB flash drive. Below is the output from the command diskutil list /dev/disk1.

/dev/disk1
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *4.0 GB     disk1
   1:       Microsoft Basic Data EFI                     209.7 MB   disk1s1
   2:                  Apple_HFS Tims Boot SSD           3.7 GB     disk1s2

Below is the output from the command sudo gpt -r show /dev/disk1

    start     size  index  contents
        0        1         PMBR
        1        1         Pri GPT header
        2       32         Pri GPT table
       34        6         
       40   409600      1  GPT part - EBD0A0A2-B9E5-4433-87C0-68B6B72699C7
   409640  7220264      2  GPT part - 48465300-0000-11AA-AA11-00306543ECAC
  7629904   262150         
  7892054       32         Sec GPT table
  7892086        1         Sec GPT header

The problem is the partition type GUID for the EFI partition is EBD0A0A2-B9E5-4433-87C0-68B6B72699C7 and it should be C12A7328-F81F-11D2-BA4B-00A0C93EC93B.

To correct this, I entered the following commands. In your case, you would substitute disk0 for disk1. You should enter these commands from the bootable USB backup clone of your boot drive.

diskutil unmountdisk /dev/disk1
sudo gpt remove -i 1 /dev/disk1
diskutil unmountdisk /dev/disk1
sudo gpt add -i 1 -b 40 -s 409600 -t C12A7328-F81F-11D2-BA4B-00A0C93EC93B /dev/disk1

Before entering type above commands, make sure your start and size entries are 40 and 409600, respectively. If not, make the appropriate corrections to the -b and -s options.