EFI Partitions – Separating EFI Partitions of Ubuntu 20.04 and Mac OSX on Macbook Pro

disk-utilityefihard drivemacospartition

I installed Ubuntu 20.04 alongside OSX on my early 2015 Macbook pro by following this answer. And somehow I messed up.

I created a separate 400MB EFI partition for Ubuntu but, the system automatically selected Mac OS EFI partition. Can I transfer the Ubuntu boot files to the separate Partition without reinstall? I recently started using Linux. please someone help me out?

$: fdisk /dev/sda
Disk /dev/sda: 233.78 GiB, 251000193024 bytes, 490234752 sectors
Disk model: APPLE SSD SM0256
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: E25C4B1F-9E64-4BCB-B346-07F1727F45F3

Device         Start       End   Sectors   Size Type
/dev/sda1         40    409639    409600   200M EFI System
/dev/sda2     409640 234784639 234375000 111.8G unknown
/dev/sda3  234784768 235567103    782336   382M EFI System
/dev/sda4  235567104 362520575 126953472  60.5G Linux filesystem
/dev/sda5  362520576 391817215  29296640    14G Linux swap
/dev/sda6  391817216 392595455    778240   380M Microsoft basic data
/dev/sda7  392597504 490233855  97636352  46.6G Microsoft basic data

$ gdisk /dev/sda
Disk /dev/sda: 490234752 sectors, 233.8 GiB
Model: APPLE SSD SM0256
Sector size (logical/physical): 512/4096 bytes
Disk identifier (GUID): E25C4B1F-9E64-4BCB-B346-07F1727F45F3
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 490234718
Partitions will be aligned on 8-sector boundaries
Total free space is 3045 sectors (1.5 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1              40          409639   200.0 MiB   EF00  
   2          409640       234784639   111.8 GiB   AF0A  
   3       234784768       235567103   382.0 MiB   EF00  
   4       235567104       362520575   60.5 GiB    8300  
   5       362520576       391817215   14.0 GiB    8200  
   6       391817216       392595455   380.0 MiB   0700  
   7       392597504       490233855   46.6 GiB    0700  

Best Answer

I am not sure why the Ubuntu installer allows the user to select which EFI partition to use, then ignores the setting and installs to the first EFI partition. Below are the step to move the boot files to the second EFI partition.

  1. Boot to Ubuntu.

  2. Press the control+option+T key combination to open a Terminal window.

  3. Enter the command below to become the root user.

    sudo bash
    
  4. Enter the command below to format the second EFI partition.

    Note: This command will erase the contents of this partition.

    mkfs.vfat -F 32 -n EFI2 /dev/sda3
    
  5. Enter the command below to mount the second EFI partition.

    mkdir efi2
    mount -t vfat /dev/sda3 efi2
    
  6. Enter the commands below to copy the boot files from the first EFI partition to the second EFI partition.

    mkdir efi2/EFI
    mv /boot/efi/EFI/BOOT efi2/EFI
    mv /boot/efi/EFI/ubuntu efi2/EFI
    
  7. Enter the commands below to get the UUID of the two EFI partitions.

    blkid /dev/sda1
    blkid /dev/sda3
    
  8. Edit the /etc/fstab file to change the UUID value for the mount point /boot/efi. This can be accomplished by replacing the UUID of the first EFI partition with the UUID of the second EFI partition. Below is the command to open the file in the nano editor.

    nano /etc/fstab
    
  9. Enter the command given below to output the contents of the /etc/fstab file. Visually confirm the changes to the file.

    cat /etc/fstab
    
  10. Enter the command given below to unmount the second EFI partition.

    umount efi2
    rmdir efi2
    
  11. Enter the commands given below to close the Terminal window.

    exit
    exit
    
  12. Restart the Mac.