How can I triple boot MacOS Catalina , Ubuntu 18.04, and Windows 10

Solution 1:

These instructions are for the latest Intel Macs which boot macOS from an APFS volume and EFI boot both Windows and Ubuntu.

If you need to install Ubuntu on a Mac with an internal PCIe-based SSD and/or T2 chip, then you should read japhwil's answer.

Note the following:

  • If your wireless mouse or keyboard will not work during the installation process, then I assume you have a wired replacement you can temporarily use.
  • Apple introduced the T2 Security Chip and Secure Boot starting with certain Macs in 2018. If your Mac includes the Apple T2 Security Chip, then you may have to modify the security settings in order to use the procedures given below. See the Apple website About Secure Boot for more information.
  • User therobyouknow has pointed out with the MacBook Pro Touch (15-inch, Late 2016), /dev/sda needs to be replaced by /dev/nvme0n1p in the instructions below.

Removing Boot Files from Previous Windows or Ubuntu Installation

If you removed a previous version of Windows or Ubuntu, then you may have files remaining in the EFI partition (disk0s1). The commands given below will remove these files.

sudo diskutil mount disk0s1
cd /Volumes/EFI/EFI
rm -r boot ubuntu windows
cd ~
diskutil unmount disk0s1

Note: If the boot ubuntu or windows directory (folder) does not exist, then expect to get an No such file or directory error message.

Installing Windows without Using the Boot Camp Assistant.

Note: If you can use the Boot Camp Assistant application to install Windows, I would suggest you do so. These instructions are mainly for those who have a special configuration which prohibits the use of the Boot Camp Assistant application to install Windows.

  1. Use the Disk Utility application to erase a 16 GB or larger flash drive. Choose the ExFAT format and the Master Boot Record scheme.

  2. Mount the Windows ISO file, the copy the files to the flash drive. The current Windows 10 ISO can be downloaded from the Microsoft website Download Windows 10 Disc Image (ISO File).

  3. Copy the Windows Support Software designed for your Mac to the flash drive. The Windows Support Software can be downloaded by using the Boot Camp Assistant application. Select Action->Download Window Support Software from menu bar.

    Below is the contents of Windows installation flash drive as viewed in the Finder application. The AutoUnattend.xml file and both the $WinPEDriver$ and BootCamp folders came from the Windows Support Software downloaded from Apple for an iMac (21.5-inch, Late 2013). The remaining files and folders were from the Win10_1909_English_x64.iso file downloaded from Microsoft.

  4. Create free space to be used by Windows. In this example, 400 GB will be reserved for Windows on a 1.1 TB drive. Before allocating the free space, the output from the command diskutil list disk0 is shown below.

    /dev/disk0 (internal, physical):
       #:                       TYPE NAME                    SIZE       IDENTIFIER
       0:      GUID_partition_scheme                        *1.1 TB     disk0
       1:                        EFI EFI                     209.7 MB   disk0s1
       2:                 Apple_APFS Container disk1         1.1 TB     disk0s2
    

    To make 300 GB of free space available, the command shown below was used.

    sudo diskutil apfs resizeContainer disk0s2 700G
    

    The new output from the command diskutil list disk0 is shown below. Notice, the 300 GB block of free space created directly below disk0s2 is not shown.

    /dev/disk0 (internal, physical):
       #:                       TYPE NAME                    SIZE       IDENTIFIER
       0:      GUID_partition_scheme                        *1.1 TB     disk0
       1:                        EFI EFI                     209.7 MB   disk0s1
       2:                 Apple_APFS Container disk1         700.0 GB   disk0s2
    
  5. Restart the Mac and immediately hold down the option key until the Startup Manager icons appear. Choose the EFI Boot label below the flash drive icon.

  6. When the image below appears, press the shift+F10 key combination. The Command Prompt window shown below should appear.

  7. Enter the following command to create the Windows partitions. There commands are based on the instructions found at the Microsoft website UEFI/GPT-based hard drive partitions.

    diskpart
    select disk 0
    create partition msr size=16
    create partition primary 
    shrink desired=800
    format quick fs=ntfs label=BOOTCAMP
    assign letter=w
    create partition primary id=de94bba4-06d1-4d40-a16a-bfd50179d6ac
    format quick fs=ntfs label=Recovery
    gpt attributes=0x8000000000000001
    list partition
    exit
    

    The output from the list partition command for this example is given below.

      Partition ###  Type              Size     Offset
      -------------  ----------------  -------  -------
      Partition 1    System             200 MB    20 KB
      Partition 2    Unknown            651 GB   200 MB
      Partition 3    Reserved            16 MB   652 GB
      Partition 4    Primary            371 GB   652 GB
    * Partition 5    Recovery           800 MB  1023 GB
    

    Enter the command exit to close the Command Prompt window.

  8. Proceed and finish the installation of Windows.

    Note: If the Mac boots back to macOS before the installation of Windows completes, open the Startup Disk pane of the System Preferences application. After unlocking, highlight the icon labeled Windows and then click on the Restart button. The installation of Windows should proceed.

  9. If after Windows finishes installing, the Windows Support Software does not automatically starting installing, run the Setup application in the BootCamp folder on the flash drive.

Installing Ubuntu

  1. Download the latest Ubuntu installation ISO file from the Ubuntu Home Page. The file download and used in this answer was named ubuntu-18.04.3-desktop-amd64.iso.

  2. Create free space to install Ubuntu. In this example, 300 GB of space will be reserved for Ubuntu. The output from diskutil list disk0 after install Windows is shown below.

    /dev/disk0 (internal, physical):
       #:                       TYPE NAME                    SIZE       IDENTIFIER
       0:      GUID_partition_scheme                        *1.1 TB     disk0
       1:                        EFI EFI                     209.7 MB   disk0s1
       2:                 Apple_APFS Container disk1         700.0 GB   disk0s2
       3:         Microsoft Reserved                         16.8 MB    disk0s3
       4:       Microsoft Basic Data BOOTCAMP                398.4 GB   disk0s4
       5:           Windows Recovery                         838.9 MB   disk0s5
    

    Note: In this example, the EFI partition (disk0s1) is 209.7 MB. Remember the size of the EFI partition on your drive. You will need this value in a later step.

    The command given below will shrink the APFS by 300 GB.

    Note: To be compatible with macOS, the entries in the Guid partition table (GPT) should occur in ascending order. To help insure this happens, dummy partitions need to be created when reserving the free space. Since the Ubuntu installer will be creating two new partitions, the command given below will create two dummy partitions.

    sudo diskutil apfs resizeContainer disk0s2 400G exfat DUMMY1 200M exfat DUMMY2 200M
    

    The dummy partition can arbitrary in size, since the partitions will be deleted later. The output from the command diskutil list disk0, after entering the above command, is given below.

    /dev/disk0 (internal, physical):
       #:                       TYPE NAME                    SIZE       IDENTIFIER
       0:      GUID_partition_scheme                        *1.1 TB     disk0
       1:                        EFI EFI                     209.7 MB   disk0s1
       2:                 Apple_APFS Container disk2         400.0 GB   disk0s2
       3:       Microsoft Basic Data DUMMY1                  199.2 MB   disk0s8
       4:       Microsoft Basic Data DUMMY2                  199.2 MB   disk0s9
       5:         Microsoft Reserved                         16.8 MB    disk0s3
       6:       Microsoft Basic Data                         398.4 GB   disk0s4
       7:           Windows Recovery                         838.9 MB   disk0s5
    
  3. Use Etcher to create a bootable Ubuntu flash drive installer, then boot from this flash drive. A tutorial can be found at the Ubuntu website Create a bootable USB stick on macOS.

  4. When the menu below appears, select Try Ubuntu without installing.

  5. When the Ubuntu desktop appears, press the control+option+T key combination to open a terminal window.

  6. Temporarily rename the folders containing the Windows EFI boot files. This is done so certain files will not be overwritten when Ubuntu installs. Also, this will prevent Windows being added to the GRUB boot menu. Enter the following commands to rename the folders

    sudo -i
    mkdir efi
    mount /dev/sda1 efi
    mv efi/EFI efi/EFI.win
    umount efi
    rmdir efi
    exit
    
  7. Enter the command exit to close the terminal window, then double click on the icon labeled Install Ubuntu 18.04.3 LTS shown on the desktop. Proceed with install Ubuntu.

  8. When the screen shown below appears, select "Install third-party software for graphics and Wi-Fi hardware and additional media formats", as shown below.

  9. When the screen shown below appears, select "Something else", as shown below.

  10. Delete the dummy partitions. Since the output from diskutil list disk0 showed the third and fourth partitions to be the dummies, the window below will identify these dummy partitions as devices /dev/sda3 and /dev/sda4. Highlight device /dev/sda3, then click on the - button to delete. Repeat for the /dev/sda4.

  11. Highlight the 300 GB of free space, as shown below, then click on the + button to add a new partition.

    In the popup window, select a size and a use as of EFI System Partition, as shown below. Here, 210 MB was used since the size of the original EFI partition was 209.7 MB. You should enter a value equal to the size of the original EFI partition on your drive rounded up to the nearest MB. Next, click on the OK button.

  12. Highlight the remaining free space, as shown below, then click on the + button to add new partition.

    In the popup window, select a mount point of /, as shown below. Let use as default to Ext4 journaling file system and do not change the size. Next, click on the OK button.

  13. Since all the new partitions have been created, click on the Install Now button. When the screen show below appears, click on the Continue button. Proceed and install Ubuntu.

  14. When Ubuntu finishes installing, the Mac will need to be restarted. If asked to remove the installation medium, then do so. When the Mac restarts, immediately hold down the option key until the Startup Manager icons appears. Next, hold down the control key while selecting the EFI Boot label under the internal drive icon. The Mac should boot Ubuntu.

  15. From the Ubuntu desktop, press the control+option+T key combination to open a terminal window. Enter the following commands to move the Ubuntu EFI boot files to the new EFI partition and restore the Windows boot folder names.

    sudo -i
    mkdir efi
    mount /dev/sda3 efi
    mv /boot/efi/EFI efi
    mv /boot/efi/EFI.win /boot/efi/EFI
    umount efi
    rmdir efi
    
  16. Use the following command to label sda3 with EFI2.

    fatlabel /dev/sda3 EFI2
    

    Use the following command to get the UUID value for the old (sda1) and new (sda3) partitions (to be used in the next step).

    blkid /dev/sda1 /dev/sda3
    

    From the output, the UUID value for sda1 and sda3 was determined to be 02E4-255E and 2BCF-0C4E, respectively. In your case, the UUID values themselves will be specific to your machine. The given UUID values are as an example and will likely be different in your case, as would be expected. The next step shows what to do with the UUID values.

  17. Change the UUID in the /etc/fstab file. Use the command nano /etc/fstab or some other command to open the /etc/fstab file in an editor. Replace the UUID for sda1 with the UUID for sda3. For this example, this would mean to replacing 02E4-255E with 2BCF-0C4E. Save the change and close the editor.

  18. Make sure the drive is not using hybrid partitioning. This can be accomplished by entering the command given below.

    gdisk /dev/sda
    

    This command is interactive. The interactive commands you will need to enter when prompted by gdisk are given below.

    x
    n
    w
    y
    
  19. Finally, enter the command exit twice to close the terminal window. Restart the Mac.

Adding an Ubuntu Icon and Label to the Startup Manager Menu (Optional)

  1. Boot back to macOS.

  2. Download a collection of icons from the sourceforge web site Mac icns. Use the Finder application to open the downloaded file mac-icns.dmg.

  3. Open a Terminal application window and enter the command given below to mount the EFI partition (/dev/disk0s3) containing the Ubuntu boot files.

    sudo diskutil mount disk0s3
    

    Under Ubuntu, this is the /dev/sda3 partition. The volume stored in this partition was given the volume label EFI2 during one of the previous Ubuntu installation steps.

  4. Enter the command below to copy the Ubuntu icon file os_ubuntu.icns to the EFI2 volume.

    cp /Volumes/mac-icns/OSX10.11.6/os_ubuntu.icns /Volumes/EFI2/.VolumeIcon.icns
    

    This will add the following Ubuntu icon to the Startup Menu.

    Note: When finished, you can use the Finder application to eject the mac-icns volume.

  5. Use the command shown below to change the label that will be shown below the Ubuntu icon on the Startup Manager menu.

    bless --folder /Volumes/EFI2/EFI/BOOT --label "Ubuntu"
    
  6. Use the Finder application or enter the command below to unmount the EFI System partition labeled EFI2.

    diskutil unmount disk0s3
    

References

About Secure Boot
About the Apple T2 Security Chip
Download Windows 10 Disc Image (ISO File)
UEFI/GPT-based hard drive partitions
Ubuntu Home Page
Create a bootable USB stick on macOS
Etcher Home Page
How to move EFI and boot partitions?
Installing Ubuntu on Mac with macOS and Windows already installed
Dual-Booting OS X or macOS with Linux without rEFInd
Mac icons