Gentoo on a mid-2012 MacBook Pro

If your sick of your brand new MacBook just working (more or less), and you just feel like modifying your kernel’s source to get your computer to work right, you’ve come to the right place. I (finally) managed to get Gentoo booting on a new MacBook Pro (15”, Core i7, mid-2012) alongside OS X 10.8.2. I suppose it actually wasn’t that bad, it could have been much worse. I only had to reinstall OS X once after a wonky partition editor…. edited a little more than I wanted.

What I have in the end is a MacBook Pro that dual boots Gentoo Linux and OS X using rEFInd. Gentoo boots via EFI, I did not use a boot loader (in the traditional sense).

My first attempt-you know, the one where I left my backup drive at work, was a miserable failure from the get-go. I went with what I was reading online, to use a boot manager/loader. Specifically GRUB/GRUB2 (I tried both). Also I used rEFIt, which has a wobbly gptsync utility, that as far as I can tell, hosed my entire drive. I had even tried building a modified gptsync from source. Although, maybe it was gparted. Since I had problems with that on both occassions.

In either case, I couldn’t get gparted/parted to change the partition type to linux (0x83 or  82 or whatever it is). It kept reporting that the partition I created was ‘MSDOS’. And in both cases, I shrugged it off because as far as I know, the kernel doesn’t really care as long as it has the drivers to load the root filesystem’s actual type.

Where I went wrong in the first case was to attempt to use GRUB/GRUB2 to boot. I had heard that you could use rEFIt to load grub, and then grub would boot the kernel. I didn’t read a whole lot on EFI booting the kernel directly, so I avoided it. Trying this involved setting up the GPT tables along with legacy MBR tables, and then supposedly I had to ‘sync’ them to get rEFIt to see the new partition/OS. Since my OS X partition is encrypted, this caused problems with the gptsync utility. I followed these two guides which ended up in grub sort of working and OS X completely gone. Oops. I had a backup though.

So I retried it this weekend, convinced that with EFI (even Apple’s “EFI”), you shouldn’t need any boot manager or loader (other than the EFI program itself). A little more searching and I managed to get it to work. And this skips the whole gptsync fiasco, the GRUB mess, etc.

My first hurdle though, was getting the partitions right. I swear it was a bug in parted or something. Because the man pages online and the one’s on the minimal Gentoo CD were way different. Any attempts to run the command ‘mkpart’ with any of the FS type options would result in a partition with MSDOS type. I eventually just settled with that for reasons I mentioned earlier.

rEFInd seemed to ignore the command line options it’s own readme specified (specifically, ‘-esp’). So it ended up installing on the root of the OS X filesystem. I had the EFI (ESP) partition mounted at /boot, so I just moved the files there and re-ran the ‘bless’ command.

This is how I did it:

  1. Partition: Use disk utility to make a partition for Linux
  2. Install rEFInd
  3. Plug in to your network and reboot to Gentoo CD: I used gentoo-minimal-amd64
  4. Format the new partition: I chose ext4
  5. Obtain stage, initial package sources and unpack/install
  6. Configure and install kernel
  7. Reboot and pray
  8. BCM4331 wireless
  9. Fixing that annoying ‘applesmc: read arg failed’ kernel error message
  10. ethernet
  11. X, audio, etc.?

I now have a working Gentoo living along side OS X. It’s a pain to switch between them, since rEFInd takes ~20 seconds to show up on boot. Now if only I could get X and nvidia-settings to work well with an additional monitor that isn’t always present, I could do all my work on it.

Config Files

  • .config
  • make.conf
  • xorg.conf