The iMac 5,1, also known as the late 2006 Core 2 Duo iMac, is an all-in-one desktop computer introduced on September 6, 2006 by Apple Inc. It features a 2.16 GHz Intel Core 2 Duo processor, 512 MB of RAM (upgradable to 3 GB), and an ATI Radeon X1600 graphics card. This iMac came in 3 sizes: 17, 20, and a 24 inch model.
Although a bit old, this computer can still be fully functional with a modern OS installed. This guide will focus on specific steps needed for a successful Gentoo installation, along with getting the basic drivers and devices working. There is no reason it shouldn't work on other Macs from this era as well, however, beware it has not been tested.
Previous knowledge of Gentoo and general system administration is recommended as we will not be covering the whole installation process in detail.
|CPU||Intel Core 2 Duo T7400||Works|
|GPU||ATI Radeon X1600||Works|
|iSight Camera||-||Untested||Probably shouldn’t be used anyway|
Macs from this era allow the user to boot an operating system in two modes:
- 32-bit UEFI mode
- Legacy BIOS mode
32-bit UEFI mode is the default mode used for booting macOS. It is a rather obscure implementation of the UEFI architecture, as nowadays most computers utilize a 64-bit UEFI system. This means it is not capable of reliably booting 64-bit, and due to its non-standard nature even 32-bit Linux.
BIOS mode has been introduced to allow dual-booting with Windows. At the time, Windows couldn't boot in an UEFI environment, which is why implementing BIOS emulation was necessary. However, since it is just BIOS, any Linux distribution that supports BIOS booting can boot on these machines as well.
From this comparison, it should clear we need to setup our new Gentoo installation for BIOS booting. Grab a spare USB drive and flash the Gentoo installation ISO onto it. Burning a CD will also work if you for some reason can't use a USB drive. Then turn the iMac on and hold Option/Alt to display the boot selection screen.
Partitioning the drive
Depending on how you want to use your iMac, you will need to partition the drive in one of the following ways:
Using the whole drive for Gentoo
This is the easier of the 2 options. Simply format your drive as MBR, and then use a tool like cfdisk to partition it according to this table:
We don’t need to create any special boot partitions for MBR booting; simple swap and boot partitions will be more than enough. Feel free to adjust the layout however you see fit.
Dual-booting with macOS
Installing Gentoo alongside macOS is a bit more tricky than on a normal computer, because macOS cannot boot from a MBR drive. And we cannot format it as GPT either, since we will be booting Linux in BIOS mode, and that requires the master boot record to be present. However, there is a solution.
When dual-booting macOS with Windows using the built in Bootcamp software, Apple computers use something called a hybrid MBR. Basically, a GPT partitioned disk leaves some empty space at the beginning of the drive where the MBR would normally sit. This space is then used by Bootcamp to make Windows bootable, by writing the MBR information to this location.
Now, since we aren't installing Windows, we won't be able to use Bootcamp to do this for us. But with a little help from a tool called gptfdisk, we can recreate the same setup. We will do this later in the Setting up the bootloader section.
Hybrid MBRs are not part of Intel's EFI GPT standard, and are generally considered unsafe. We are using them only because it is impossible to get macOS and Linux booting from the same drive in any other way.
To install Gentoo alongside macOS, use cfdisk or a similar tool to format your drive as GPT and partition it according to this table:
There are few important things to note here.
First, this guide assumes that you already have macOS installed, and that you resized the partition to your desired size. If that's not the case, please install macOS first, and then use Disk Utility to shrink the macOS partition.
Second, do not mess with the first 2 partitions (sda1 and sda2). These are reserved for macOS.
Don't forget to also include the BIOS boot partition. This doesn't need to be big; 32 MB is a safe size. This partition is what GRUB will use to boot Gentoo, and should be left with no file system and should not be mounted.
Finally, adjust the partition table according to your personal preferences, but make sure the BIOS partition is always within the first 4 partitions on the drive. This avoids any unnecessary bugs with the iMac not recognizing the partition. After this step is completed, move on to the installation part.
Start by formatting your newly created partitions with the desired file systems. Do not format the BIOS partition; this one should stay blank.
As we stated before, this guide will not cover the whole installation process in detail. Most steps that apply to any regular x64 machine will apply to this iMac too. Refer to the AMD64 handbook for a more comprehensive guide.
There are, however, some optimizations we recommend making.
This is the recommended make.conf file for this iMac:
CFLAGS="-march=native -O2 -pipe" MAKEOPTS="-j2 -l2" USE="alsa" # sound support VIDEO_CARDS="radeon r300" # X11 support ACCEPT_LICENSE="-* @FREE @BINARY-REDISTRIBUTABLE"
Feel free to add any options you find necessary.
We recommend using the standard distribution kernel. This avoids any unnecessary mishaps and ensures you have a stable and functional system by the end of this guide. However, if you want to try customizing your own kernel anyway, keep in mind the challenges and issues you might face. Feel free to share any discoveries you make along the way.
To avoid waiting several hours for the distribution kernel to compile, you can also install a pre-compiled kernel image. Simply emerge sys-kernel/gentoo-kernel-bin.
Setting up the bootloader
First, emerge GRUB by running:
emerge --ask sys-boot/grub
We will use GRUB because it is the most common and easy to set up bootloader, and supports booting in BIOS mode. After emerging, no further configuration is needed. Simply install it with grub-install.
Then run grub-mkconfig to create the configuration file.
grub-mkconfing -o /boot/grub/grub.cfg
If you are not dual-booting with macOS, this was the last step. The only thing left to do now is to restart and enjoy your new OS.
Configuring hybrid MBR
This step is only necessary for users who decided to dual-boot their iMac with macOS. If you decided to only install Linux, you can ignore this step.
As mentioned in the booting section, we need to do some special adjustments to the partition table so the iMac's firmware recognizes our Linux installation as bootable. To do this, first, install gptfdisk by running:
emerge --ask sys-apps/gptfdisk
After this is done, you can view your drive's current configuration by running:
You will see a table similar to this:
What we will want to do next, is to change the MBR type from protective to hybrid. This will allow us to write values into this location.
If your MBR is already marked as hybrid for some reason, or you want to erase it, press x to view advanced options, and type n to create a new protective MBR.
Before we begin, type p to print out the current partition table. If you used the same partition layout as in we did in this guide, you will see the BIOS boot partition being 3rd in the list. The macOS partition will be 2nd. If you haven't used the same layout, please note the numbers of your BIOS boot partition as well as the macOS partition. These will be needed later in the setup.
Type r to switch to recovery/transformation mode, and h to create the hybrid MBR. Now you will need to answer a set of prompts to properly configure your hybrid MBR.
The first prompt is asking for numbers of partitions which you want to include in the MBR table. Enter the numbers of your BIOS and macOS partitions (in our case that's 2 and 3) and press enter. If you have a different layout, make sure to input the correct numbers appropriate for your setup.
Next, you will see a prompt similar to this:
Creating entry for partition #2
Enter an MBR hex code (default AF): af
Set the bootable flag? (Y/N): n
Enter af for the hex code and n for setting the bootable flag. Do not worry, this does not mean the macOS partition won't be bootable anymore.
Next, the program will create an entry for our BIOS boot partition. Enter the values according to the following:
Creating entry for partition #3
Enter an MBR hex code (default 07): 07
Set the bootable flag? (Y/N): y
Setting the hex code to 07 will "trick" the iMac's firmware into thinking that this is a Windows partition, which will allow us to boot it in BIOS mode. That means you also need to set the bootable flag to yes.
Finally, the last prompt will ask whether to protect the remaining space with an extra entry. This is because we only "hybridized" 2 partitions, when in theory you can do 3. Type y to create this extra entry and set its hex code to 0a.
The 0a hex code is used to mark an OS/2 Boot Manager partition. Macs don't recognize this code, and thus will ignore the extra entry in the MBR list.
You should now have a fully functional Gentoo installation on your iMac. Reboot back into the boot selection screen (hold option while the machine starts up) and choose Windows. This is because we set the hex code of the BIOS partition to 07, but don’t worry, it is still very much Linux.