Score:1

Cannot dual boot MacOS & Ubuntu

ar flag

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.

Jeff avatar
mx flag
@James69 If you can access the live environment, you should be able to partition the drives as you wish. In this case, you should start with running the installer, and modifying partitions manually. The EFI boot is the partition mounted at /boot/, called EFI, is between 100 and 512 MB, and contains the GRUB bootloader. The partition should be at the beginning of the drive. You can edit it (not too hard), and I suggest adding Clover EFI to it in order to detect and boot off of both Mac and Ubuntu. For reference, check out https://www.tonymacx86.com and you can download Clover from there.
Jeff avatar
mx flag
@James69 Have fun exploring the world of Hackintosh and experimenting with Mac (Personally, I hate Mac. Too proprietary)
Irsu85 avatar
cn flag
Which macbook pro? The M1(pro/max) ones don't run Ubuntu AFAIK
Joepie Es avatar
eg flag
Make a seperate EFI for Ubuntu.
David avatar
cn flag
Maybe it would be better to have Ubuntu running in a docker container?
James69 avatar
ar flag
@Irsu85 It's an Intel-based MacBook Pro.
James69 avatar
ar flag
@JoepieEs how exactly can you do that? I'm interested!
David Anderson avatar
us flag
What model year is your Mac Book Pro?
James69 avatar
ar flag
@DavidAnderson 2017 MacBook Pro Intel-based
Score:0
ar flag

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.

I'm searching online for possible causes:

  • The disk was encrypted using FileVault -- No, I didn't 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.

Score:0
ar flag

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.

Score:0
us flag

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.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.