Close

The Definitive Linux-on-Mac Boot Debacle Demystifier

AndyAndy wrote 01/01/2018 at 23:13 • 4 min read • Like

Introduction

I'm assuming that if you're reading this, you own a Mac.  Great hardware (debatable?), smooth software, not Windows, and impeccable build quality, not to mention your unshakable fashion at artist's conferences, among web developers, and at hackathons.  But I hear you say 'ah, but I like to have more control over my computer... if only I could run Linux on my Mac!'

Perhaps you've read an article or two on getting the job done, perhaps you've perused the professional, well written works of [Mr. Rod Smith] and you've tried his masterpiece: rEFInd, and had some success! Perhaps, like my first time, you were successful with booting from a CD and installing GRUB, then booting in BIOS mode, or more recently UEFI mode.  Perhaps, as with my most recent attempt (and success!), you've toiled for the better part of two weeks after the release of High Sierra to install anything other than macOS on your beloved Macintosh, and failed, finding yourself grasping at the limits of your own knowledge and scouring the internet only to find partially helpful or outdated information dating back to pre-2010 or worse, and found yourself ready to give up on your beloved aluminum monolith.

Well, toil no more! It can be done, and I hope to demystify some of the mess for you!

First off, a disclaimer: I am not fabulously wealthy and I own only a single, now-aging, Apple computer.  I have a MacMini 6,1 (Late 2012).  Since older firmwares are likely to be buggier, this bodes well for users of newer Apple computers.


Apple's firmware is the root of the problem.  The EFI/UEFI (interchangeable hereafter) standard is quite explicit, but very few manufacturers follow it.  "Your mileage may vary" is all too relevant.  ASUS, GIGABYTE, and MSI firmwares have been known to be troublesome.  Apple's firmware is known to be consistently not up to spec, but there are workarounds! For readers who are not interested in a technical disambiguation, skipping to the Process section is advisable now.

The Rundown

The EFI spec states that firmwares should look for "EFI executables" in a FAT partition (read, sect. 3.5.2) in the PE32+ or COFF formats (read, sect. 2.1.1).  Apple's firmware does this, but if it does not find anything, skips to the nearest HFS+ formatted partition, looking for System/Library/CoreServices/boot.efi, Apple's boot program.  Likewise, this FAT partition needs to be the first partition (debatable in implementation) on the drive, and the partition table format needs to be GPT.  In addition, the partition which contains the EFI bootable images should have the "boot,esp" flags set, and no other partition should have these set.

The mechanism of programs like rEFInd, rEFIt, Clover, etc. is to install an EFI bootable image on this EFI System Partition (ESP hereafter), the aforementioned FAT partition.  Then Apple's firmware will find it, boot it, and you have suddenly taken control of your boot process!  This assumes that everything goes without a hitch.  Older EFIs, such as the one in my 2012 Mac Mini, are shoddy at best.  The USB facilities don't always work under rEFInd as they should, and USB drives which would normally be visible to rEFInd, aren't.

To my knowledge, there isn't a solution to this problem.  A fix would have to come from Apple, or some very, very knowledgeable individual who can write and install firmware patches (definitely not me).  So, with this road to the castle resoundingly destroyed by Apple's firmware despite my attempts to play with the NVRAM and the fabled bless command, we backtrack and use more forceful measures.

My ultimatum was to disassemble my aluminum monolith  in the hopes of being able to install Linux from a different machine, put the drive back into my Mac, and be a happy tinkerer.  I'll save you a story of two weeks of fiddling and research to finally get it to boot.  Apple's firmware is a picky eater when it comes to GPT partitioning.  Not all GPT disks are made equal.  Apple's firmware very specifically demands that the disk in question was partitioned by Apple's diskutil.  If anyone can make their Mac EFI boot a GPT disk which was made with standard GNU tools, I would love to see it.

For whatever reason, Apple's  tools do not play nice with the standard GPT tools.  I can confirm that diskutil does not operate in the same way as gdisk, for example (parted too!).  A disk GPT-partitioned on my Mac, with rEFInd installed, is not only unbootable on my Dell Optiplex 990, but the EFI firmware of similar age on that machine is totally unable to read the ESP.  The jig is up.

Process

todo:

 - APFS mess

 - NVRAM debacle

 - Installing from a different machine

  - KMOD 'autodetect'

  - bootstrapping externally

  - GPT partitioning discrepancies

 - Drivers 

CASE SENSITIVE PARTUUID

Like

Discussions