Cannot boot into Ubuntu installed on an external SSD after installing Windows with Boot Camp

bootbootcampmojavepartition

I have a MacBook Pro running macOS Mojave and an external SSD with Ubuntu installed on it. The way I swapped between macOS and Ubuntu was by pressing the Option/Alt during boot to choose between Macintosh and EFI Boot (when the EFI Boot was selected it booted Ubuntu automatically).

Now I have installed Windows with Boot Camp and the EFI Boot has disappeared. Now I can only choose between Macintosh or Boot Camp.

How can I boot into Ubuntu with the external SSD again?

This is the output of running diskutil list:

/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *251.0 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                 Apple_APFS Container disk1         180.0 GB   disk0s2
   3:       Microsoft Basic Data BOOTCAMP                70.8 GB    disk0s3

/dev/disk1 (synthesized):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      APFS Container Scheme -                      +180.0 GB   disk1
                                 Physical Store disk0s2
   1:                APFS Volume Macintosh HD            121.0 GB   disk1s1
   2:                APFS Volume Preboot                 46.7 MB    disk1s2
   3:                APFS Volume Recovery                509.7 MB   disk1s3
   4:                APFS Volume VM                      1.1 GB     disk1s4

/dev/disk2 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *240.1 GB   disk2
   1:                 Linux_Swap                         8.0 GB     disk2s1
   2:                      Linux                         40.0 GB    disk2s2
   3:                      Linux                         192.1 GB   disk2s3

Best Answer

Grub was installed on the EFI partition of the internal drive. When you installed Windows the BOOTX64.EFI file was overwritten. The shimx64.efi file usually is a duplicate of the overwritten file.

Since the boot files for both Windows and Ubuntu are sharing the same EFI partition, the simplest solution would be to install the rEFInd boot manager. There are many ways to install rEFInd. Below are two different ways. Once you have installed rEFInd, you will probably want to edit the refind.conf file to remove duplicate entries.

Install rEFInd to the EFI partition.

This is the default. You will have to temporarily disable System Integrity Protection (SIP) to install this way. The instructions are given here. To edit the refind.conf file from macOS, you will have to mount the EFI partition. The mount command is given below.

sudo diskutil mount disk0s1

To unmount, enter the command given below.

diskutil unmount disk0s1

Install rEFInd to a HFS+ partition.

You have to use the Disk Utility application or the diskutil command to create a small "Mac OS Extended (Journaled)" formatted partition to hold the rEFInd files. This way does not require you to disable SIP to install. Also, you can select rEFInd as the default directly from the Startup Manager (by holding down the option key on startup). The installation instructions are given here.

Create Another EFI partition for Grub.

An alternative solution, which does not require rEFInd, involves using the Disk Utility application or the diskutil command to create another EFI partition. You can then copy the /EFI/BOOT and /EFI/ubuntu folders to the new partition. Afterwards, you will need to overwrite the /EFI/BOOT/BOOTX64.EFI file with the EFI/ubuntu/shimx64.efi file in this new EFI partition. This solution would allow both Windows and Ubuntu to appear in the Startup Manager. If you use this solution, you should consider changing the label to something other than EFI Boot and using an Ubuntu icon. Basically, you have to adapt steps 5 and 6 of this answer.