Installing Ubuntu on Mac with macOS and Windows already installed

I have a dual-boot MacBook Pro late 2013 with macOS Sierra and Windows 10 (BOOTCAMP) already installed. I want to install Ubuntu as a third OS. Is there any (easy) way to do it?

> Disk Partitions:

enter image description here

> Gpt dev disk0

enter image description here

> Fdisk disk0

enter image description here

Disk Utility


An update version of this has been posted here.

Note: These instruction have been updated for use with Ubuntu 18.

This answer installs Ubuntu on your computer without the use of third parity tools for either the installation of booting of Ubuntu. The Ubuntu file I downloaded was named ubuntu-16.10-desktop-amd64.iso. I assume you have created a bootable Ubuntu USB flash drive installer and have verified the contents. I also assume you have verified hardware compatibility by successfully booting the live version of Ubuntu. These instructions have been divided into the three main sections listed below.

  • Create Space on the Drive for Ubuntu : This is accomplished by using the MacOS Terminal application to enter commands.
  • Install Ubuntu : This uses the Ubuntu flash drive installer.
  • Add Ubuntu to Startup Manager - Here you basically use the MacOS to move the necessary files to the proper locations. This will allow Ubuntu to be selected from the Startup Manager. You will not need rEFInd to boot Ubuntu.

Note: If another user has a different partition scheme than shown in this example, the post a comment to me and I will try to update my answer.

Create Space on the Drive for Ubuntu

For the purpose of illustrating the steps needed, I created a drive slightly larger than your actual drive.

Note: macOS 10.11 and above have System Integrity Protection (SIP). You must disable this before following the commands below.

The output from diskutil list disk0 is given below.

/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *256.0 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                  Apple_HFS Macintosh HD            180.7 GB   disk0s2
   3:         Microsoft Reserved                         16.8 MB    disk0s3
   4:       Microsoft Basic Data BOOTCAMP                70.1 GB    disk0s4

The output from sudo gpt -r show /dev/disk0 is given below.

      start       size  index  contents
          0          1         PMBR
          1          1         Pri GPT header
          2         32         Pri GPT table
         34          6         
         40     409600      1  GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
     409640  352968704      2  GPT part - 48465300-0000-11AA-AA11-00306543ECAC
  353378344       4056         
  353382400      32768      3  GPT part - E3C9E316-0B5C-4DB8-817D-F92DF00215AE
  353415168  136818688      4  GPT part - EBD0A0A2-B9E5-4433-87C0-68B6B72699C7
  490233856    9766151         
  500000007         32         Sec GPT table
  500000039          1         Sec GPT header

The output from sudo fdisk /dev/disk0 is given below.

Note: After repartitioning the drive, you should verify that the values shown below have not changed. Certain changes will cause Windows to view the drive as hybrid partitioned. If this occurs, Windows may fail to boot or malfunction.

Disk: /dev/disk0    geometry: 31123/255/63 [500000040 sectors]
Signature: 0xAA55
         Starting       Ending
 #: id  cyl  hd sec -  cyl  hd sec [     start -       size]
------------------------------------------------------------------------
 1: EE 1023 254  63 - 1023 254  63 [         1 -  500000039] <Unknown ID>
 2: 00    0   0   0 -    0   0   0 [         0 -          0] unused      
 3: 00    0   0   0 -    0   0   0 [         0 -          0] unused      
 4: 00    0   0   0 -    0   0   0 [         0 -          0] unused      

I decided to allow total of about 40 GB for Ubuntu. If you need a different size, then make the appropriate adjustments. I will be creating 3 new partitions for Ubuntu. A description for each is given below.

  • A Swap partition. The size of this partition should be between 1 to 2 times the size of the memory installed in your Mac computer. I will be using a size of 800 MB. Obviously, the size you will be using will be much larger.
  • A Ext4 Journaling file system partition to hold Ubuntu. This partition will consume most the approximately 40 GB of space I allocated for Ubuntu.
  • An EFI System partition. This is required for Ubuntu to appear on the Mac Startup Manager. This manager appears when you turn on or restart your Mac and hold down the option key. The Startup Manager can be used to change the default startup disk (i.e. operating system) or can be used to temporarily boot from a startup disk. I have chosen size of 500 MB for this partition.

I have chosen to allow the Ubuntu installer to actually create the 3 new partitions. So at this point, I only need to shrink the MacOS partition by approximately 40 GB and create 3 new placeholder partitions. The placeholders will be replaced later by the Ubuntu installer with the actual partitions described above.

The command to change to partitioning is given below. Since the MacOS partition is about 180 GB, I used a desired value of 140 GB (140G). Also, I used a value of 800 MB (800M) for the size of the new Swap partition. Since you will desire a larger size, then you will need to make the appropriate substitution. Note: The two values of 200 MB (200M) were chosen arbitrarily, these values will change later.

diskutil resizevolume disk0s2 140G 3 jhfs+ part1 800M jhfs+ part2 200M jhfs+ part3 200M

The output from this command is shown below.

Started partitioning on disk0s2 Macintosh HD
Verifying the disk
Verifying file system
Checking Journaled HFS Plus volume
Checking extents overflow file
Checking catalog file
Checking multi-linked files
Checking catalog hierarchy
Checking extended attributes file
Checking volume bitmap
Checking volume information
The volume Macintosh HD appears to be OK
File system check exit code is 0
Resizing
Waiting for the disks to reappear
Formatting disk0s3 as Mac OS Extended (Journaled) with name part1
Initialized /dev/rdisk0s3 as a 763 MB case-insensitive HFS Plus volume with a 8192k journal
Mounting disk
Formatting disk0s4 as Mac OS Extended (Journaled) with name part2
Initialized /dev/rdisk0s4 as a 191 MB case-insensitive HFS Plus volume with a 8192k journal
Mounting disk
Formatting disk0s5 as Mac OS Extended (Journaled) with name part3
Initialized /dev/rdisk0s5 as a 37 GB case-insensitive HFS Plus volume with a 8192k journal
Mounting disk
Finished partitioning on disk0s2 Macintosh HD
/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *256.0 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                  Apple_HFS Macintosh HD            140.0 GB   disk0s2
   3:                  Apple_HFS part1                   800.0 MB   disk0s3
   4:                  Apple_HFS part2                   200.0 MB   disk0s4
   5:                  Apple_HFS part3                   39.5 GB    disk0s5
   6:         Microsoft Reserved                         16.8 MB    disk0s6
   7:       Microsoft Basic Data BOOTCAMP                70.1 GB    disk0s7

Note: The last 200M was ignored by the diskutil command. Instead, most of the remaining free space was allocated to the disk0s5 slice.

The output from sudo gpt -r show /dev/disk0 is given below.

      start       size  index  contents
          0          1         PMBR
          1          1         Pri GPT header
          2         32         Pri GPT table
         34          6         
         40     409600      1  GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
     409640  273437496      2  GPT part - 48465300-0000-11AA-AA11-00306543ECAC
  273847136     262144         
  274109280    1562496      3  GPT part - 48465300-0000-11AA-AA11-00306543ECAC
  275671776     390616      4  GPT part - 48465300-0000-11AA-AA11-00306543ECAC
  276062392   77057864      5  GPT part - 48465300-0000-11AA-AA11-00306543ECAC
  353120256     262144         
  353382400      32768      6  GPT part - E3C9E316-0B5C-4DB8-817D-F92DF00215AE
  353415168  136818688      7  GPT part - EBD0A0A2-B9E5-4433-87C0-68B6B72699C7
  490233856    9766151         
  500000007         32         Sec GPT table
  500000039          1         Sec GPT header

The output from the command sudo fdisk /dev/disk0 is unchanged from what was given above.

Install Ubuntu

  1. Insert the Ubuntu flash drive and restart the Mac. Hold down the option key to invoke the Startup Manager. Select to EFI boot from the USB flash drive. When prompted, choose the option shown below.

    Note: For a better view, either click on the image or open the image in a new window.

    21

  2. Select language.

    22

  3. I choose to select both options below.

    23

  4. Choose the option shown below.

    24

  5. Select the partition shown below. This partition should be the same size as previously specified for the Swap partition when the diskutil resize volume command was entered.

    61

  6. Click on "Change..." and select "swap area" in the popup window as shown below. Do not change the partition size. Next, click on "OK".

    62

  7. Select the partition shown below. Next, click on the "-" to delete this partition.

    63

  8. Select the free space as shown below.

    64

  9. Click on the "+" to open a "Create partition" popup window. Select "EFI System Partition". Also, change the size to 500 MB and click on the "End of this space" button. Next, click on "OK".

    65

  10. Select the partition shown below. Next, click on the "-" to delete this partition.

    66

  11. Select the free space as shown below.

    67

  12. Click on the "+" to open a "Create partition" popup window. Select "Ext4 journaling file system". Also, select "/" as the "Mount point". Do not change the partition size. Next, click on "OK".

    68

  13. Click on the "Install Now" button shown below.

    69

  14. Click on the "Continue" button shown below.

    70

  15. Select your desired location.

    71

  16. Select your keyboard.

    72

  17. Continue and install Ubuntu Linux. When finished, restart and hold down the option key to invoke the Startup Manager. Select to boot from the MacOS volume.

Add Ubuntu to Startup Manager

After installing Ubuntu, the command diskutil list disk0 produced the following output.

/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *256.0 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                  Apple_HFS Macintosh HD            140.0 GB   disk0s2
   3:                 Linux Swap                         800.0 MB   disk0s3
   4:           Linux Filesystem                          39.3 GB    disk0s4
   5:                        EFI NO NAME                 500.2 MB   disk0s5
   6:         Microsoft Reserved                         16.8 MB    disk0s6
   7:       Microsoft Basic Data BOOTCAMP                70.1 GB    disk0s7

The command sudo gpt -r show /dev/disk0 produced the following output.

      start       size  index  contents
          0          1         PMBR
          1          1         Pri GPT header
          2         32         Pri GPT table
         34          6         
         40     409600      1  GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
     409640  273437496      2  GPT part - 48465300-0000-11AA-AA11-00306543ECAC
  273847136     262144         
  274109280    1562496      3  GPT part - 0657FD6D-A4AB-43C4-84E5-0933C84B4F4F
  275671776       1312         
  275673088   76732416      4  GPT part - 0FC63DAF-8483-4772-8E79-3D69D8477DE4
  352405504     976896      5  GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
  353382400      32768      6  GPT part - E3C9E316-0B5C-4DB8-817D-F92DF00215AE
  353415168  136818688      7  GPT part - EBD0A0A2-B9E5-4433-87C0-68B6B72699C7
  490233856    9766151         
  500000007         32         Sec GPT table
  500000039          1         Sec GPT header

Note: The 3 placeholder partitions have be replaced by the partitions specified while installing Ubuntu.

To make Ubuntu appear in the Startup Manager, execute the following steps.

  1. Mount the EFI System partitions by entering the commands given below.

    sudo diskutil mount disk0s1
    sudo diskutil mount disk0s5
    
  2. Use the Finder application to copy the EFI folder from volume EFI to the volume NO NAME.

  3. If you are not installing Ubuntu 18 or newer, then you can skip steps 4, 5 and 6.
  4. Move all the folders and files in the EFI/Boot folder on the EFI volume to the Trash.
  5. Copy the file bootmgfw.efi on the EFI volume from the folder /EFI/Microsoft/Boot to the folder /EFI/Boot.
  6. Rename the file bootmgfw.efi in the /EFI/Boot folder on the EFI volume to the name bootx64.efi.
  7. Remove the folders and files that were added to the EFI volume during the Ubuntu installation. To accomplish this, move the folder EFI/Ubuntu on the EFI volume to the Trash.
  8. Remove the Microsoft related files from the NO NAME volume. To accomplish this, move the folder EFI/Microsoft on the NO NAME volume to the Trash.
  9. If you are installing Ubuntu 18 or newer, then you can skip steps 10, 11 and 12.
  10. Move the file EFI/Boot/bootx64.efi on the NO NAME volume to the Trash.
  11. Copy the file grubx64.efi on the NO NAME volume from the folder /EFI/ubuntu to the folder /EFI/Boot.
  12. Rename the file grubx64.efi in the /EFI/Boot folder on the NO NAME volume to the name bootx64.efi.
  13. Empty the Trash.
  14. (Optional) Download a collection of icons from the sourceforge web site Mac icns. Use the Finder application to open the downloaded file mac-ices.dmg, then enter the command below to copy the Ubuntu icon file os_ubuntu.icns to the NO NAME volume.

    cp /Volumes/mac-icns/os_ubuntu.icns "/Volumes/NO NAME/.VolumeIcon.icns"
    

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

    os_ubuntu.png

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

  15. Use the Finder application or enter the commands below to unmount the EFI System partitions labeled EFI and NO NAME.

    diskutil unmount disk0s1
    diskutil unmount disk0s5