3

I encountered this issue quite often and tested a few solutions so I hope this will help. Initially, I was aiming at dual-booting MacOS and Ubuntu on a Macbook Pro, which worked after few attempts but it had its major flaws :

  1. When installing Ubuntu through a USB flashdrive via the mac boot menu, the Ubuntu installer has this annoying habit of replacing the original Mac EFI settings* with Ubuntu EFI settings*.

*The EFI settings are - simply put - what allows your device to boot on a given OS. If you delete the EFI settings (= EFI partition on your hard drive), your device cannot boot on this OS and often leads to a black screen or equivalent at startup.

  1. Formatting the hard drive to make it Mac-compatible (HFS, HFS+) via Ubuntu (through GParted for instance) is far from easy because the Mac packages aren't available: you have to search & install them.

Basically I'm trying to have a dual-boot system (MacOS & Ubuntu) without affecting my EFI settings.

In other words : when I power on my Mac, I want my default OS to be MacOS. If I want to switch to Ubuntu, I'd like to select it from the boot menu.

The ultimate goal : having a trial-boot by adding Windows on BootCamp.

Any ideas?

I will post my successful attempts below.

9
  • Which macbook pro? The M1(pro/max) ones don't run Ubuntu AFAIK
    – Irsu85
    Feb 27, 2022 at 15:39
  • Make a seperate EFI for Ubuntu.
    – Joepie Es
    Feb 27, 2022 at 15:47
  • Maybe it would be better to have Ubuntu running in a docker container?
    – David
    Feb 27, 2022 at 15:49
  • @Irsu85 It's an Intel-based MacBook Pro.
    – James69
    Feb 27, 2022 at 16:32
  • @JoepieEs how exactly can you do that? I'm interested!
    – James69
    Feb 27, 2022 at 16:33

3 Answers 3

1

By default, Ubuntu can be accessed from the Mac Startup Manager by selecting the icon labeled EFI Boot. (You hold down the option key at startup to access to the Mac Startup Manager.) The Startup Manager instructions the boot loader in the firmware to boot using the file /EFI/BOOT/BOOX64.EFI file in the FAT32 formatted volume in the EFI partition. This file is an exact copy of the /EFI/ubuntu/shimx64.efi file stored in the same volume. When the BOOX64.EFI file executes, the software changes the EFI settings to make Ubuntu the default operating system to boot. According to Rod Smith (the current maintainer of the rEFInd Boot Manager), this file then transfers execution to the /EFI/ubuntu/grub64.efi file (GRUB), which can be used to boot Ubuntu.


Installing a macOS/Windows/Ubuntu triple boot on your Mac does create a conflict in that both Ubuntu and Windows both install a file in the original EFI partition at /EFI/Boot/bootx64.efi. This conflict can be resolved by having two EFI partitions.

The typical procedure to install a macOS (OS X) and Ubuntu dual boot is as follows.

  1. Install macOS.
  2. If desired, use the Boot Camp Assistant to install Windows 10.
  3. Use the macOS diskutil command to shrinking a existing macOS partition to create free space for Ubuntu. Free space is space that is not part of a partition.
  4. Use an Ubuntu installer (usually a flash drive) to install Ubuntu in the free space. When creating new partitions, include a new EFI partition. Installing Ubuntu will overwrite the Microsoft /EFI/Boot/bootx64.efi file in the original EFI partition. Note: The overwritten file is identical to the /EFI/Microsoft/bootmgfw.efi file in the original EFI partition.
  5. Boot to macOS, then move the /EFI/BOOT and /EFI/ubuntu folders from the original EFI partition to the new EFI partition. Afterwards, copy the /EFI/Microsoft/bootmgfw.efi file to /EFI/Boot/bootx64.efi in the original EFI partition.
  6. Boot to Ubuntu, then update the /etc/fstab file to reflect the change in EFI partitions for the Ubuntu boot files.

The typical procedure to remove Ubuntu and retain macOS (and Windows) is as follows.

  1. Boot to a live version of Ubuntu (usually a flash drive).
  2. Use a tool included with Ubuntu live to remove the Ubuntu related partitions. The gdisk command is a typical tool.
  3. Boot to macOS, then use diskutil command to expand an existing macOS partition to contain the free space created by removing Ubuntu.

Using macOS to remove Ubuntu usually results in an inability to boot macOS. This may be a bug or something that amuses Apple.

3
  • After creating a free partition for Ubuntu (through DiskUtility/Mac) and then created a second EFI partition (through the Ubuntu installer, step 4). I made sure to select this new EFI partition for the Ubuntu boot loader installation. But after rebooting my Mac, I only have two boot options (Mac & Windows). Also I couldn't find the EFI files (or the /dev folder for that matter since Finder does not show them). How do you perform step 4-5-6?
    – James69
    Mar 17, 2022 at 12:02
  • You stated, "I made sure to select this new EFI partition for the Ubuntu boot loader installation." However, my instructions did not tell you to do this. When you actually follow my instructions for step 4, you then should be able to proceed to steps 5 and 6. Mar 17, 2022 at 17:32
  • As you have discovered, choosing a location other than the default first EFI partition does not work. The purpose of steps 5 and 6 is to manually move the boot loader to the second EFI partition. Mar 17, 2022 at 17:33
0

First successful attempt:

  1. Downloaded Ubuntu Desktop (20.04 LTS)
  2. Mounted the ISO on a USB flash drive using an appropriate tool (balenaEtcher in my case)
  3. Turned off my Mac.
  4. Plugged my USB
  5. Turned on my Mac whilst pressing down the Option/alt (⌥) key to access the boot menu.
  6. Installed Ubuntu manually (default option suggests to erase the whole disk) : added an ext4 partition for Ubuntu on my free space.
  7. Ticked the "Add third-party software for Wifi & Graphics" option.

Note : there are plenty of tutorial on how to install Ubuntu using a USB flash drive. Here is a good one: Create a bootable USB stick on MacOS

  1. Finished installing & restarted my Mac.

Default OS became Ubuntu instead of Mac. To switch back to Mac, I had to access the boot menu (holding down the Option/alt (⌥) key when powering on) and select Macintosh.

0

Second attempt. Context: tried adding Windows through BootCamp to have a trial-boot system. It didn't work and caused my boot settings to crash.

How to create an HFS+ partition on a Mac using Ubuntu:

  1. Turned off my Mac
  2. Plugged the same flash drive but with Ubuntu 21.10 mounted on it (I'll explain why later).
  3. Powered on my Mac whilst holding the Option/alt (⌥) key.
  4. When accessing the boot menu, the only option displayed is "EFI boot": EFI boot screenshot
  5. Selected the Install Ubuntu option, but only to access the disk partitioning options.
  6. Selected & deleted all remaining partitions (even EFI which holds around 200Mb) to keep two lines only: the disk name and "empty space" partition underneath).
  7. Exit the installation menu (Clicked on "Exit" instead of Continue). The software takes you to the portable Ubuntu OS.
  8. Launched Terminal (or press CTRL+alt+T keys).
  9. Typed sudo passwd to setup a system password for the next step.
  10. Then su - root which will prompt for the same password and direct you the root system.
  11. (Optional)sudo apt install gparted (or sudo apt-get install gparted) to make sure you have GParted installed.
  12. Launch GParted.
  13. Select your empty disk, right-click on it & click on "New".
  14. On the file system drop-down menu, you should find quite a few of them available but Mac-compatible are likely to be grayed out (HFS, HFS+).
  15. Go back on Terminal.
  16. sudo apt-get install hfsprogs hfsutils hfsplus to install missing packages.
  17. You might get the following error: "Unable to locate hfsprogs" (after a few attempts at installing the missing package on the 20.04 LTS, I tried installing it using the 21.10 version).
  18. Type sudo add-apt-repository universe to allow your OS to installing non-official packages.
  19. Give a sudo apt-get update to clear the cache & update your packages.
  20. Try the following command again: sudo apt-get install hfsprogs.
  21. (Optional) you can find other HFS-related available packages by typing apt search hfs & installing the ones you need.
  22. Go back on GParted & create a Primary partition with HFS+ file system.

Expected results


Now that I have an HFS+ partition which is Mac-compatible, I am hoping I can reinstall MacOS through the Internet Recovery mode.


EDIT 1

After rebooting my Mac on Internet Recovery mode, the Disk Utility does not display my HFS+ partition. It only shows the Apple Disk Image.

Strange, I didn't use FileVault (encrypt or setup an encrypted APFS partition) when using MacOS earlier on.


EDIT 2

I pressed & hold COMMAND + OPTION + R when powering on my Mac and it did download the latest version of MacOS disk utility which displayed my HFS+ partition.

Not ideal, does not solve the issue (HFS+ partition should be read & manipulated by older versions of disk utility) but it is a good temporary workaround.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .