I spent yesterday getting the iMac to boot Arch Linux. This was try no. 2 – I first tried a couple of weeks ago, using the existing partition table (gpt) with the HFS partition removed, and replace with a btrfs filesystem holding Arch Linux. Somewhat as expected, this failed to boot.
Now, everything would have been easy if only this computer had a working disk drive. Unfortunately, the disk drive had died a painful death some time ago, leaving me with no option but to use zechariah, which has a spare HDD slot.
I was under the impression that Macs only boot off EFI drives, and wasted the weekend trying to get it to boot, without the ability to use ‘bless’ or ‘mactel’ or other similar tools, since I was booting off a BIOS based PC. I have since abandoned that approach; according to this website, Intel Macs can boot off MBR disks. Note that refit is out of date; this was good for me since the iMac is also out of date, but the information may not hold for more modern Macs. So, the next step was to try with the disk formatted using MBR, and using a standard Arch Linux install – Macs have a BIOS compatibility mode, allowed me to not bother with an EFI bootloader.
To check that I was not making a fatal mistake which would involve removing the EFI partition, I first booted off the known good disk in zechariah. Success!
The next step was reformatting the disk to MBR. I first tried with cfdisk, deleting the GPT entry and making a new partition table. Much confusion ensued, as the resulting disk was recognizable, the partitions mountable, but not bootable on either the PC or the iMac. ??? Adding to the confusion was the insistence of syslinux that it had failed to set the boot flag on the target drive, although I had set it manually with cfdisk.
Parted came to the rescue, enlightening me to the fact that cfdisk had in fact left the GPT table intact – although how it could treat a GPT disk as MBR and get away with it, I am still unsure. An easy fix; parted kindly reformatted the disk with a MBR table, added the new partitions, and I was away. A few hours later, I had the iMac booting off a MBR disk, and the ip address.
The ip address was difficult, as one of those things that I had regretted was not using the OSX partition to find the MAC address first…
The solution was to write a short script (blind):
for i in $(ip addr); do echo "[whitespace...] $i"; done | less
This printed out each word in the last column in the screen left intact, allowing me to find the ip address, SSH in, and find the MAC address from the comfort of a working terminal, using the same commands. After I had set up a static ip address on the router, I checked that I could ssh in, and it worked!
The next step is to build a custom case 😉