Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

serviaas

macrumors newbie
Original poster
Aug 15, 2021
14
0
Hi there - wondering what the boot priority is by default for cMP, specifically if you use the optical drive bay SATA connectors.

I know SATA drive bay 1 is the first, goes through those, then to PCIe, then USB (right?) but not sure if I put a drive (Windows) in the optical drive bay, if that goes before or AFTER the normal SATA drive bays.

Just wanting to make sure my clean Mac OS drive is ahead of the Windows drive for maximum safety.

Thanks!
 
Last edited:

cdf

macrumors 68020
Jul 27, 2012
2,256
2,583
Actually, it's not so clear cut. Some PCIe drives have top priority. The best practice is to experiment with your hardware.
 

Dayo

macrumors 68020
Dec 21, 2018
2,257
1,279
if I put a drive (Windows) in the optical drive bay, if that goes before or AFTER the normal SATA drive bays.
Best experiment as advised.

In my experience it is PCIe Slots -> Optical Drive Ports -> SATA Bays.
Didn't test Native USB/Firewire Ports which I presume come last.
 
  • Like
Reactions: serviaas

joevt

macrumors 604
Jun 21, 2012
6,968
4,262
It could be random. I would try testing whether it matches the order of devices in the EFI handle list. For this, you have to go into the EFI Shell, then use the dh command to list the handles. dh -v might be better because it will contains the full device paths. Handles containing a file system protocol (Fs for short) is probably where it would start looking for booters. Question is, does it loop handles with fs protocol first then loop booter types in the inner loop, or does it loop booter types first, then handles with Fs protocol in the inner loop? Another question: is the handle list going to be in the same order in the next boot?

It's possible PCIe is first because the PCIe slots appear earlier in the handle list than Optical and SATA. The reason PCIe slots appear earlier in the handle list even though the SATA controller is also PCIe may be because the SATA controller is at device 00:1F which is the last device of bus 00. USB is device 00:1D on my MacPro3,1 so it might take priority over SATA. I suppose the SATA and USB and NVMe controllers may detect file systems at different times - it might not be deterministic if they are adding devices at different times. For example, the PCIe enumeration process enumerates all the controllers. Drivers are loaded for the controllers in turn. The drivers schedule reads/writes to detect devices then return. Events are created to handle that. The events trigger code to add block devices which loads file systems. This event driven code might not always happen in the same order for every boot. I'm not too clear on how this works in EFI. Certainly there must be ways to do something else while waiting for I/O to happen? The UEFI spec mentions tasks, events, timers, hot-plug, etc.

There are a few types of booters:
- EFI default: these are at /EFI/Bootx64.efi. These are listed as EFI in the Startup Manager (hold option key at boot).
- blessed: a HFS or APFS file system has bless info that points to an efi file (usually /System/Library/CoreServices/boot.efi).
- macOS default: these are at /System/Library/CoreServices/boot.efi.
- legacy BIOS boot: A disk with MBR boot code. These are listed as Windows in the Startup Manager (hold Option key at boot).

I don't know if the boot code checks all those booter types. Maybe the macOS booter type isn't a thing (i.e. it has to be blessed). I would test that by unblessing all my HFS+/APFS partitions. That's kind of hard for APFS so I would remove those.
I don't think it will check legacy BIOS boot. To test that you would have to remove all disks/partitions except a legacy BIOS bootable disk.
I don't know if there's an order to what it will look for.
 

Dayo

macrumors 68020
Dec 21, 2018
2,257
1,279
It could be random.
There is likely randomness within each grouping indeed but the order of appearance of the groups, PCIe Slots -> Optical Drive Ports -> SATA Bays, has always been the same for me. Unless a fluke of course.

As to what gets booted, remember that Intel Macs follows the UEFI spec (in spirit if not in intent)
  • Boot the bootloader in the location saved in the NVRAM
    • Saving to NVRAM on Mac is by "systemsetup -setstartupdisk" or by "bless" (Deprecated)
    • If nothing is found in the NVRAM, such as after resetting this or the file is not present or the disk has failed, initiate a UEFI fallback search.
  • Boot the first UEFI fallback bootloader found in a UEFI fallback bootloader location (/EFI/Boot)
    • Once such a file is found using the "PCIe Slots -> Optical Drive Ports -> SATA Bays" search pattern, AFAICS, it is booted.
    • This is where UEFI Windows can get booted inadvertently
    • In a default Mac setup, all "/EFI/Boot" folders are always empty (do not exist) of course.
    • If a UEFI fallback bootloader is not found, initiate a Mac OS fallback search.
  • If nothing is found, the default Mac OS setup, Intel Mac then goes off on a tangent and extends the UEFI Spec
    • Boot the first Mac bootloader found in a Mac OS default bootloader location (/System/Library/CoreServices)
    • Once such a file is found using the "PCIe Slots -> Optical Drive Ports -> SATA Bays" search pattern, AFAICS, it is booted.
My natively supported Mac OS version is on the Optical Drive Port and clearing the NVRAM results in it getting booted without fail (if there isn't a fallback bootloader in play). When I attach similar to a PCIe Slot, that gets booted instead when nothing is blessed and a fallback bootloader is absent. I always have a fallback bootloader, RefindPlus, in play these days so testing basically stopped.

As an aside, on the SATA Bays, I am not so sure the belief that the SATA Bays are processed in order (Bay 1 to 4) is actually correct. Haven't tested fully, but I think the order may actually be random based on the Disk ID allocated to each disk (/dev/disksX) which as we know, is not fixed. Haven't tested in full though.

Either way, once a SATA bay is selected, the specific volume on the disk to boot, which can be more than one, then needs to be selected. How is this done? I think by Disk ID but not verified as mentioned.

EDIT:
Missed out that the last booted Mac OS version stored in the NVRAM comes into play somewhere in the mix, when present. Haven't dived into this properly.
 
Last edited:
  • Like
Reactions: cdf and JedNZ

h9826790

macrumors P6
Apr 3, 2014
16,656
8,587
Hong Kong
Hi there - wondering what the boot priority is by default for cMP, specifically if you use the optical drive bay SATA connectors.

I know SATA drive bay 1 is the first, goes through those, then to PCIe, then USB (right?) but not sure if I put a drive (Windows) in the optical drive bay, if that goes before or AFTER the normal SATA drive bays.

Just wanting to make sure my clean Mac OS drive is ahead of the Windows drive for maximum safety.

Thanks!
SATA drives on a PCIe -> SATA III card (e.g. Sonnet TempoSSD) has higher priority than optical bay's drive.

And optical bay has higher priority than HDD bay.

But I am not sure about PCIe SSD / NVMe.

I am not sure if you happy to use OpenCore, but you can install OpenCore onto the Windows drive actually, then your cMP will only able to boot to Windows (I assume that's UEFI Windows, that's why you have "safty" concern) via OpenCore. IMO, this is a very good way to protect the cMP's BootROM (away from that MS certificate)
 

Macschrauber

macrumors 68030
Dec 27, 2015
2,981
1,487
Germany
The MBR disk will be booted if it's the only one. Even if there is a blesssing in NVram.

I often boot my FreeDos disk that way to flash GPUs. Pull all disks and PCI cards and after a minute or so I see the Dos prompt.

Most "unflashed" GPUs work in FreeDos.
 
Last edited:
  • Like
Reactions: joevt

Dayo

macrumors 68020
Dec 21, 2018
2,257
1,279
The MBR disk will be booted if it's the only one. Even if there is a blesssing in NVram.
Doesn't that apply to any bootable disk? That is, the only bootable disk present will be booted even if something else is blessed right?

I suppose what you mean is that if the Mac OS fallback search also fails, a legacy bootcode search is initiated.
 

joevt

macrumors 604
Jun 21, 2012
6,968
4,262
Most "unflashed" GPUs work in FreeDos.
In legacy BIOS boot mode, the Boot Camp BIOS CSM, or whatever it's called, can use the BIOS driver from the PCI option rom of the GPU. It should work for legacy BIOS booting any OS.

Maybe one could create a GOP on BIOS driver that uses the BIOS driver? But it would be complicated since you have to setup the 16 bit real-mode environment (with INT vectors) for the BIOS driver. See BiosVideoDxe. Or maybe GPUs have a standard VGA mode that can be accessed directly and is the same on most GPUs (but VGA modes are low resolution).
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.