Triple Booting my 2006 iMac
I own a Core 2 Duo iMac from 2006. It's a cute little computer, but unfortunately, with the latest version of OS X it supports (Lion), not very usable nowadays. And even back in 2006, Mac OS wasn't the ideal for certain tasks, such as gaming. So I decided to install some more operating systems on it to make it useful. This article documents key findings I made along the way.
I chose these 3 operating systems:
- OS X Snow Leopard (because I like how it looks)
- Windows 7 (for playing games)
- Linux (for real work)
My Linux distro of choice is Arch because I enjoy saying I use arch btw because it lets me configure everything during the install, which turned out to be very important.
Specs
To give you more context on the machine in question, here are the specs:
Model | iMac 5,1 |
CPU | 2.16 GHz Core 2 Duo (T7400) |
GPU | ATI Radeon X1600 (128 MB of VRAM) |
RAM | 3 GB DDR2 (upgraded) |
Storage | 512 GB mechanical hard drive |
Display | 1680x1050 TFT 20" |
Mac OS
Installing Snow Leopard was the easiest part of this process since, you know, Mac OS is intended to run on Macs. It's useful to note here that despite OS X being distributed on DVDs back in the day, you don't need to go hunting for an ancient OS X DVD (or burn a DVD) because the disk image can be burned to a USB drive and it boots just fine.
Here is Snow Leopard running on the iMac after installing some additional software:
Windows
Windows is still quite easy because Apple provides software and drivers necessary to run Windows on a Mac. Here is however where I made a mistake. I, as any normal person would when installing Windows on a Mac, used the Boot Camp utility to split my hard drive into 2 partitions. I was thinking that, after my Windows install is finished, I can simply go into the Windows disk management utility and shrink my Windows partition to make space for Linux. This for some reason doesn't work. Windows does allow you to shrink the partition, but it doesn't actually change where the partition ends on the drive, it simply changes the capacity of the partition, so if you have a 200 GB partition and shrink it to 150, it would only have space for 150 GB of data but still would take up 200 GB on the hard drive.
I do not know why it acts like this. Maybe I'm just dumb and missed some option when shrinking the partition, but I swear I have done this before on other computers (shrinking my Windows partition) and it didn't just deallocate some space without actually moving where the partition ends. Or maybe it was just some weird bug, I don't know.
Anyway, after that I tried resizing the Windows partition using GParted from the GParted live CD, but that simply corrupted my install so I had to erase the partition and perform the installation again. Yay.
This time, before installing anything, I used GParted to create my Windows partition and formatted it as FAT32 (because for anther unknown reason the partitioning utility in the Windows installer would refuse to format the partition if it was just free space). I made sure to leave sufficient space after Windows for my Linux install.
Now Windows was finally installed properly:
I also ran into a weird issue with the Windows Boot Camp software where running the installer would throw an "your machine is not supported" error (even though it very definitely is), but I was able to quickly discover that running the installer from an elevated PowerShell instance fixed the issue. So, if you also encounter this, just open a PowerShell window as administrator and run the executable from there.
Linux
Now comes the real fun. Intel Macs (especially these early Intel models from 2006) were only ever designed to run Mac OS and Windows, so they have some fun design quirks.
Problematic EFI
These machines are equipped with 32-bit EFI firmware (despite the CPU being 64-bit). If you know what this means, you know what the problem is. I'll not explain it here because it's ultimately irrelevant as the EFI implementation on these machines is ass and doesn't boot Linux properly, so even if the firmware wasn't 32-bit you would run into issues anyway.
What issues? Well most distros I tried simply hang past the GRUB screen, and a few fully boot up but you don't see anything because the video driver wasn't initlialized properly by the EFI firmware. I am honestly not technically literate enough to explain what exactly is going on here, I'm mostly going off of what's written in this amazing guide by jmstriegel on GitHub. It's been an indispensable resource on my journey.
On top of all of that, the Mac firmware also appears to be quite picky about which boot media it allows you to boot from. If your Linux distribution of choice doesn't support booting on a 32-bit EFI, your drive won't show up, but even if your distro supports it, your drive still might not show up in the boot picker. At times I was left feeling like the iMac is just messing with me.
BIOS Mode
So how did I solve this? Well thankfully these Macs also have a compatibility mode for booting BIOS-only OSes, such as Windows at the time. That is how Windows actually boots on the Mac. And in this mode Linux boots just fine, no GPU issues or anything. How does it work in practise though?
If you've been paying attention, the iMac is an EFI machine (even if a sucky one) so its drive uses the GPT partitioning scheme. BIOS however needs MBR, so you'd need both on the same drive to get Mac OS and Windows running. The short answer to this discrepency is that Apple decided to use something called the hybrid MBR. I again won't go into details here, but it's basically as if you slapped MBR on top of GPT. The GPT formatted drive contains a section on it where you define which partitions are bootable in BIOS mode. Normally when installing Windows, the Boot Camp software sets this up for you, but since I was looking to install Linux, I'd have to do this manually.
But before any of that, I needed to figure out how to make the install media boot. Thankfully most Linux distros (including my choice - Arch) have the ability to boot in BIOS mode. But it's not all sunshine and rainbows.
The Mac only supports booting in BIOS mode from the internal hard drive or internal CD-ROM, not a USB drive. This is because, well, in Apple's eyes the only OS apart from OS X you'd be installing on this machine is Windows. And Windows came on a DVD back then. Thus according to Apple you only need BIOS booting from the CD drive and eventually when Windows is installed from the internal hard drive. Nothing more. So... yes, this means if I wanted to boot in BIOS mode, I'd have to burn a CD. I guess it's a bit more fitting for a 2006 machine at the very least.
But there is an even more annoying problem with this mode. You see, most Linux install ISOs are actually "hybrid" ISOs, as in they can boot on both BIOS and EFI machines. If you try booting an ISO like this on the iMac, you will get the following screen:
Two options with no names and a prompt to select a boot type. Great. The problem here is that you can't actually select anything. The BIOS hasn't loaded any keyboard drivers at this point, so there is no way for you to get past this. And the Mac will just sit here indefinitely, there is no timeout or anything. The only way to leave is to force power off the machine. Again, I assume this happens because Apple never anticipated these "hybrid" ISOs, but it's just such a nuisance, especially after you realize you have just wasted a CD for your Mac to show you this.
I'm trying to install Arch and the official Arch ISO is also a hybrid ISO. There is a workaround, which comes from this guy who made several custom ISOs for booting on these Macs, but more importantly a little C program you can use to modify an existing ISO. The program does some magic to the file to disable EFI booting so the Mac firmware doesn't get confused anymore. It is annoying having to do this to every ISO you want to try with this machine, but yeah, it is what it is.
Or you could be like me, who instead of this approach decided to make a custom Arch ISO with the archiso program. Why? Because the official ISO is too big to fit on a CD and I had no blank DVDs laying around. Making a custom ISO allowed me to make it fit onto a regular CD which I had many of.
So, after all that, I was finally able to stick the CD into the iMac and boot into the Arch installer.
Hybrid MBR Magic
As with any installation, I first needed to partition the hard drive. I decided to use the GRUB bootloader (because I only know how to use that one) which needs a special BIOS boot partition when installing in BIOS mode on a GPT drive. This partition only needs to be like 1 MB in size, but I decided to give it 128 of those mega bytes because I am a coward. I placed this partition right after the Windows one, and made sure to mark it as "BIOS boot" (when using cfdisk this can be done in the type menu). Without this the grub-install
program wouldn't know where to put the GRUB image.
📝 Note
The BIOS boot partition should not contain any file system; you should leave it unformatted.
Then I created a root partition and a swap partition as you normally would on Linux. From here the installation was no different than on any regular PC until it came time to reboot.
You might remember me mentioning something about needing to do manual modifications to the hybrid MBR. When installing Windows with Boot Camp, this is done for you but here I had to do it myself. I'll list the steps I performed here for anyone trying to do the same.
- Install gptfdisk:
pacman -S gptfdisk
- Run gptfdisk:
gdisk /dev/sda
- Type
p
to list all partitions and note numbers of ones to include in the hybrid MBR table (1, 2, 4).
Command (? for help): p
Number Start (sector) End (sector) Size Code Name
1 40 409639 200.0 MiB EF00 EFI System Partition
2 409640 250409639 119.2 GiB AF00 Snow Leopard
3 250673152 631287807 181.5 GiB 0700 BOOTCAMP
4 631287808 631549951 128.0 MiB EF02
5 631549952 967094271 160.0 GiB 8300
6 967094272 975482879 4.0 GiB 8200
I'm including the EFI partition (1) because if you don't include three partitions the program will scream at you. I'm also including the Mac OS partition (2) because for some reason not including it causes it to become not bootable. And finally partition number 4 is the BIOS boot partition that contains the GRUB image. I didn't include the Windows partition since I can simply boot Windows from GRUB.
- Type
r
to enter recovery and transformation options:
Command (? for help): r
- Type
h
to make hybrid MBR:
Recovery/transformation command (? for help): h
- Type numbers of partitions to be included in hybrid MBR (in my case 1, 2, 4):
WARNING! Hybrid MBRs are flaky and dangerous! If you decide not to use one,
just hit the Enter key at the below prompt and your MBR partition table will
be untouched.
Type from one to three GPT partition numbers, separated by spaces, to be
added to the hybrid MBR, in sequence: 1 2 4
- Type
n
to refuse this:
Place EFI GPT (0xEE) partition first in MBR (good for GRUB)? (Y/N): n
I'm not sure what it does but declining it seems to not affect anything.
- If the default option here is EF press enter, otherwise type
EF
. Set bootable flag should ben
:
Creating entry for GPT partition #1 (MBR partition #1)
Enter an MBR hex code (default EF): ↩️
Set the bootable flag? (Y/N): n
- If the default option here is AF press enter, otherwise type
AF
. Set bootable flag should ben
:
Creating entry for GPT partition #2 (MBR partition #2)
Enter an MBR hex code (default AF): ↩️
Set the bootable flag? (Y/N): n
- Here change the hex code to 07 and set bootable flag to
y
:
Creating entry for GPT partition #4 (MBR partition #3)
Enter an MBR hex code (default EF): 07
Set the bootable flag? (Y/N): y
After this you will be dumped back to the recovery and transformations prompt. You can type o
to verify you marked the correct partitions. The output of that command for me looks like this:
Number Boot Start Sector End Sector Status Code
1 40 409639 primary 0xEF
2 409640 250409639 primary 0xAF
3 * 631287808 631549951 primary 0x07
4 1 39 primary 0xEE
- If everything is correct, type
w
followed byy
to write the changes to disk.
This made my Linux installation bootable. To verify, I rebooted and entered the boot picker (hold option/alt), and selected Windows. The Mac firmware identifies any BIOS boot options as Windows, so the name doesn't matter. I was then presented with the GRUB menu and I could finally boot into Arch.
Here it is running the i3 window manager:
Extra Notes
I didn't know this when performing my installations, but I think the order of partitions I ended up going with (first Mac OS, then Windows, then Linux) is pretty important. Windows 7 doesn't support GPT, so it sees the hard drive as MBR, and I remember reading somewhere that if the Windows partition is more than 3rd, Windows might refuse to install or boot because partitions after the 3rd one can't be bootable on MBR. I haven't tested it though so take it with a grain of salt.
Conclusion
Well this certainly has been a rabbit hole (I've learned more about hybrid MBRs than I ever needed to know) but I did succeed in the end. Now, with OS X, Windows, and Linux installed, I can use this iMac to its fullest potential. Or at least what 2006 hardware potential allows.
Jokes aside, I did find some fun use cases for this machine. Some of those include:
- playing FNAF World (despite this game being 10 years newer than the computer, it runs great)
- experimenting with Cocoa and Objective-C
- burning Music CDs with iTunes
- experimenting with window managers on Linux
Here are a few more pictures:
- to be added
Thanks for reading!