To set macOS as the default boot option in Ubuntu, you must modify the GRUB bootloader configuration file. This involves identifying the correct menu entry index for your macOS partition and updating the GRUB_DEFAULT variable in /etc/default/grub. After saving the changes, run sudo update-grub to apply them. Note that this method applies to Intel-based Macs; Apple Silicon (M1/M2) machines do not use GRUB in the same way.
Understanding GRUB and Default Selection
When you install Ubuntu alongside macOS on an Intel-based Mac, the system uses GRand Unified Bootloader (GRUB) to manage the startup sequence. By default, GRUB selects the first operating system listed in its menu, which is often Ubuntu itself. To change this behavior so that macOS loads automatically, you need to instruct GRUB to remember a specific selection or use a saved state. The previous approach of using string matching forGRUB_DEFAULT is deprecated and unreliable because menu titles can change with kernel updates or OS upgrades. The modern, robust standard is to use numeric indices or the saved keyword. Numeric indices are static but fragile if the menu order changes. The saved method is dynamic and user-friendly, allowing you to change the default temporarily from the boot menu without editing config files again.
For most users seeking a permanent fix where macOS always boots first regardless of previous choices, setting the numeric index is the direct solution. However, you must be precise about which number corresponds to your macOS installation.
Identifying Your macOS Menu Entry
Before changing any settings, you need to know the exact position of the macOS entry in the GRUB menu. GRUB counts entries starting from zero. You can find this by restarting your computer and looking at the GRUB screen. If you have multiple Linux kernels installed, they will appear as separate entries. macOS might appear under "OS X" or "macOS". Count carefully:- 0: The first item (often Ubuntu)
- 1: The second item
- ...
sudo update-grub, but visual inspection during reboot is safer. Ensure you note the exact text of the macOS entry as well, just in case you prefer to use the saved method later.
Modifying the GRUB Configuration
The primary configuration file for GRUB is located at/etc/default/grub. You will need administrative privileges to edit this file. Open a terminal in Ubuntu and use a text editor like nano or vim.
sudo nano /etc/default/grub
Locate the line that begins with GRUB_DEFAULT=. It likely says GRUB_DEFAULT=0 or GRUB_DEFAULT="Ubuntu". Change this value to the numeric index of your macOS entry. For example, if macOS is the third item in the list, you would change it to:
GRUB_DEFAULT=2
Remember that counting starts at 0. If macOS is the second item, the index is 1. Be careful not to skip lines or miscount, especially if you have multiple Windows or Linux entries.
After modifying the default value, you should also ensure that GRUB_TIMEOUT is set to a reasonable value, such as 5 or 10 seconds, so you have time to interrupt the boot process if needed. Save the file and exit the editor. In nano, you press Ctrl+O to save and Ctrl+X to exit.
Applying the Changes
Editing the configuration file does not immediately affect the boot process. You must regenerate the GRUB configuration file to apply your changes. Run the following command in the terminal:sudo update-grub
This command reads /etc/default/grub and creates a new grub.cfg file in the /boot/grub/ directory. Once this process completes successfully, restart your computer. Upon reboot, GRUB should automatically select the macOS entry based on your new default setting.
If you encounter issues, such as the system still booting into Ubuntu, double-check your index number. You can also try the saved method by setting GRUB_DEFAULT=saved and adding GRUB_SAVEDEFAULT=true to the config file. This allows you to hold Shift while booting to choose macOS once, and it will become the new default for subsequent boots.
For those interested in more complex setups involving multiple operating systems, see our guide on Triple Boot MacOS, Windows, Linux: Windows Boots over Grub which discusses similar GRUB management challenges. Additionally, if you are considering partitioning strategies, refer to Is adding a macOS partition while having Ubuntu installed possible? for insights on disk layout.
Troubleshooting Common Issues
Sometimes, despite correct configuration, the boot order may not behave as expected. One common issue is Secure Boot interfering with non-Ubuntu OS detection. While macOS usually handles its own secure boot requirements, ensure that your BIOS/UEFI settings allow for multi-boot configurations. Another issue arises if the macOS partition is not detected by GRUB. This can happen if the EFI partition is corrupted or if the macOS bootloader is missing. In such cases, you may need to repair macOS from a recovery drive before adjusting Ubuntu's GRUB settings. If you accidentally lock yourself out of selecting other OSes, you can always revert the change by editing/etc/default/grub again and setting GRUB_DEFAULT=0, then running sudo update-grub.
It is important to note that these instructions assume an Intel-based Mac. Apple Silicon Macs (M1, M2, M3) use a different firmware architecture and do not support traditional dual-booting with GRUB in the same manner. They rely on Apple's native boot picker or specialized tools like rEFInd, which operate differently than the GRUB methods described here.
Frequently Asked Questions
Can I use the 'saved' method instead of a numeric index?
Yes, settingGRUB_DEFAULT=saved and enabling GRUB_SAVEDEFAULT=true is often preferred. This allows you to manually select macOS from the GRUB menu once, and it will remain the default until you choose another option. It avoids the risk of miscounting menu entries after system updates.
What if my macOS entry disappears from GRUB after an update?
This can happen if the macOS bootloader is updated or if the EFI partition structure changes. Re-runsudo update-grub to refresh the menu. If macOS still does not appear, you may need to reinstall the macOS bootloader or check your disk partitions using lsblk to ensure the volume is recognized.
Does this work on Apple Silicon Macs?
No. Apple Silicon Macs do not use GRUB for booting in the traditional sense. They use Apple's UEFI implementation and the built-in boot picker (hold Option at startup). Dual-booting macOS and Linux on Apple Silicon requires different tools and procedures, often involving virtualization or specialized bootloaders like rEFInd, not standard GRUB configuration.How do I verify my current GRUB default?
You can check the current default by reading the active configuration file withcat /boot/grub/grub.cfg | grep -i default. However, this shows the runtime value. For the persistent setting you configured, always check /etc/default/grub directly using grep GRUB_DEFAULT /etc/default/grub.