2

It seems annoying that when you boot into Ubuntu on a Mac it takes over and becomes the default OS, even if something else (e.g. macOS or Boot Camp Windows) was previously the default.

The only way I have found to get back macOS as the default boot OS is to fully boot back into macOS (using Alt/Option on boot to select it), and then manually set macOS back to being the default using 'System Preferences/Startup Disk', which seems a bit excessive.

I'm actually going to post my own command line answer which I've worked out.

But I am also genuinely very happy to hear and up-vote any other command line or GUI-based answers which can set macOS back to being the default from within Ubuntu. (Or can prevent Ubuntu from taking over as the default in the first place!)

4
  • This is related to askubuntu.com/q/739649 - but I believe they're not duplicates, as that Q was about how to get back to OS X at all after installing Ubuntu, and this is about how to 'stickily' got back to macOS using the command line or GUI within Ubuntu. (I guess we all know how to swap OS-es non-stickly as a one-off using Alt/Option during boot.)
    – MikeBeaton
    Oct 16, 2020 at 23:48
  • I don't know enough about the boot process with a Mac. If your computer is booting to GRUB, you can probably change the default that way as well. This is absolutely not an answer, it's something you can explore.
    – KGIII
    Oct 16, 2020 at 23:48
  • 1
    I explored it, see my answer below. Although actually when you boot via grub2 on a Mac it does seem to forcibly set Ubuntu as first in the boot order, even after changing settings that I think are supposed to ask it not to. (Maybe because the Mac UEFI boot vars are not standard?)
    – MikeBeaton
    Oct 16, 2020 at 23:50
  • 1
    That's surprisingly elegant. Don't forget that you can 'accept' your answer. I've bookmarked the thread to see what else pops up.
    – KGIII
    Oct 16, 2020 at 23:53

2 Answers 2

3

On the lastest version of Ubuntu (20.04) and on current versions of macOS (Catalina or Big Sur) this works to reset to macOS and stay reset:

As a one-time step, add this line to your Ubuntu .bashrc file:

alias osx='sudo efibootmgr -o 80,0 && reboot'

From then on, when you want to reboot into macOS, open a terminal in Ubuntu if you haven't got one open already.

Type osx and press return.

Enter your password if required.

This should reboot you back into macOS. If you have more than one macOS, it will reboot back into whatever was the previously selected macOS default. It is 'sticky' (macOS stays set back as the default).

There is no equivalent way back from macOS to Ubuntu; reboot while holding down Alt/Option as normal. But that is okay because Ubuntu stays selected once you've chosen it; unlike macOS without this method. 🙂

[Worked out after a fair bit of research, with the help of efibootmgr in Ubuntu and bootoption in macOS!]

0
2

When Ubuntu is installed, a EFI/BOOT/BOOTX64.EFI file is place on the first EFI partition. This is the file that can be selected to boot from the Mac Startup Manager. Also, the GRUB file EFI/ubuntu/grubx64.efi and secure boot file EFI/ubuntu/shimx64.efi are both placed in the first EFI partition. Having the firmware boot either of these two files will result in the booting of Ubuntu. The difference on a Mac is that the booting of EFI/ubuntu/shimx64.efi will result on configuring the Mac to always boot Ubuntu. Since EFI/BOOT/BOOTX64.EFI and EFI/ubuntu/shimx64.efi files are identical, using the Mac Startup Manger to boot Ubuntu will result in Ubuntu becoming the default.

Below are possible ways to avoid Ubuntu becoming the default.

  • Copy EFI/ubuntu/grubx64.efi to EFI/BOOT/BOOTX64.EFI. The problem with this solution is that an update to Ubuntu may undo this change.
  • Create a new EFI (or possibly a FAT or ExFAT partition) and install a UEFI shell. Configure this shell to boot EFI/BOOT/BOOTX64.EFI. This will result in a new item appearing in the Mac Startup Manager. You can change the icon and label of this item to distinguish this item from the other choices.
  • Create a new EFI (or possibly a FAT or ExFAT partition) and install rEFInd. Configure rEFInd to silently instruct the firmware to boot EFI/BOOT/BOOTX64.EFI. This will result in a new item appearing in the Mac Startup Manager. You can change the icon and label of this item to distinguish this item from the other choices. Although you may wish to use rEFInd as the default startup manager instead of the built‑in one.
1

You must log in to answer this question.

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