apple debian gnu linux imac efi howto

Why do this?

Why? Just … why!? And no, I do not want an explanation for this abomination.

@cseydel, freelancing misanthrope (and still a cool guy! :) )

Having a native GNU/Linux system is part of my venture to go Apple-less within the next one or two years (yeah, I said 'years' ‐ my withdrawal treatment may take that long…). I recently bought a used Thinkpad T410 just to play around with a recent GNU system. That and the success story of my work mate rbn with his Ubuntu'fied Macbook Pro got me intrigued enough to finally try it on a system that I may render useless in the wake of my experiment. Talk about high stakes!

Starting Point

I bought my 27" iMac in December 2011. It has a i5-2400 CPU @ 3.10GHz and a Radeon HD 6900M GPU. I have a numpad USB keyboard and a Logitech USB mouse connected – so no Bluetooth- and trackpad-stuff. I already have a dual boot configuration (Mac OS Mavericks and Windows 7) using Bootcamp, too. I do not have FileVault active on my stationary computer.

Shrinking the disk

Bring up the Mac OS Disk Utility and select the hard disk that has OS X installed. Select the topmost entry – the physical drive, not the partition. The right window pane visualizes the existing partitions on your hard disk; most likely there is only "Macintosh HD". Select it and click the "+" at the bottom to create a partition.

Linux installations advise you to have a swap partition the size of your physical memory. I figured 12 GB of RAM had to be enough and since I also had little free space to spare (despite having a TB disk), I decided to live on the wild side and go without a swap partition (I figured if I really do need one, I can surely add a file-image based one later). If you have enough disk space and/or not enough RAM, do add another partion though.

Adjust the size of the new partition(s) and label the partition "Linux" (and "Linux swap" respectively). Make sure you use the MS-DOS (FAT) filesystem. When you click "Apply", Disk Utility will shrink your existing Macintosh HD partition to make room for the new ones. Grab a coffee – that will take a while.

Installing rEFInd

Macs use EFI to boot the operating system. A tool called rEFInd (a fork of the now discontinued rEFIt) installs a graphical boot manager that lets you choose between all your installed (and recognized) operating systems.

Installing rEFInd was pretty straightforward for me: Download and extract the ZIP-file and run the shell script with ./install.sh --alldrivers. The --alldrivers switch was necessary for me to let rEFInd actually find Debian after it was installed. I understand you have to use --esp if you are using FileVault.

Cross your fingers and reboot. You should see the rEFInd boot manager offering you to boot into your OS X amongst things like booting the recovery partition and possibly Windows if installed.

Installing Debian

I downloaded the 200-something MB minimal / netinstall ISO image and burnt it to CD. Rebooting the Mac, rEFInd didn't offer me to boot from the inserted CD, but hitting ESC (refresh) revealed a "Boot Legacy OS" option. The Debian installer booted alright and it had no trouble using a graphical installer, either.

I already had a 7m ethernet cable prepared when, much to my surprise, the installer recognized the Atheros-based wifi chipset instantly. I could netinstall wirelessly. The installation took a while but I guess that was due to a bad mirror-site.

I like netinstalls but if you prefer DVD installs: I've heard that the Debian installer repeatedly hung on a Macbook using a DVD install – annoyingly right after the installation was nearly finished. I don't know if that would have been a problem on my iMac but I wasn't keen on finding out.

First Boot

The first boot, after showing me the usual Linux startup console output (framebuffered), presented me with a Black Screen O'Death. I (correctly) suspected Xorg and tried to go to a text terminal, only stupid me didn't come up with the idea to hit the function Key fn together with Ctrl-Alt-F1…

One should be able to escape the black screen right away with this. I took the long route, booted into single-user using the rEFInd boot option for the Debian menue item (F2) and edited /etc/X11/default-display-manager to state /bin/true (you can comment out gdm3). A reboot then had me on the terminal with a login prompt.

Xorg needs the proprietary driver package for the Radeon GPU. You can get it by editing /etc/apt/sources.list to include non-free and install the driver:

$ sudo echo deb http://ftp.de.debian.org/debian wheezy main non-free >> /etc/apt/sources.list
$ sudo apt-get update
$ sudo apt-get xserver-xorg-video-radeon

Revert the changes made to /etc/X11/default-display-manager if necessary. A reboot should then have you staring at the GDM3 graphical login screen.

Keyboard Woes

The first obvious problem for me was the only partly support for my Macintosh keyboard. I could choose a German Mac keyboard layout alright using the Gnome preferences, but I realized only the right Alt and CMD keys were working.

Furthermore, at least on a German keyboard, the </> and ^/° keys are swapped. There is a good blog post about how to map them as one would expect, but it's in German. It boils down to:

$ xmodmap -e 'keycode 49 = less greater less greater bar brokenbar bar' -e 'keycode 94 = dead_circumflex degree dead_circumflex degree U2032 U2033 U2032'
$ xmodmap -pke | grep " 49" >> ~/.Xmodmap
$ xmodmap -pke | grep " 94" >> ~/.Xmodmap

In an attempt to enable the left side Alt and CMD keys, I ran a dpkg-reconfigure keyboard-configuration but that was a very bad idea: now Gnome greets me with an annoying "Error activating XKB configuration" after every login. I'll elaborate on this when I find a solution.

I will also try to make F1..F6 work without using the fn modifier key. Let's see how that one turns out.

What Works?

Multimedia-access keys are all recognized, so is the Eject button. iSight camera, sound output and the internal microphone all work out of the box (the latter may need some amplification settings).

Accessing my Mac partition was easy with the package hfsprogs:

$ sudo mkdir /mnt/macintosh_hd
$ sudo mount -t hfsplus -o ro /dev/sda2 /mnt/macintosh_hd  # NOTE: sda2 may be a different partition on your system

What's Left?

Currently the brightness cannot be controlled. Gnome recognizes the commands and displays its beautifully transparent widget but actual brightness doesn't change.

Sound quality seems awful. I need to compare certain audio files against known good versions, but the few tracks I've listened to while writing this sounded somewhat tinny.

Bluetooth seems to have been recognized; dmesg says so and there is the Bluetooth icon in the Gnome menu but I haven't tried it yet. What doesn't work: preserving the state between reboots when I tell it to be disabled. There must be a sysctl option for this but I haven't looked for it, yet.

Oh, I may have wrecked my Windows installation: The Win7 boot loader won't find bootable media. My guess is that it's because my new Linux partition is now the second partition. The Windows boot loader is surely configured to look for a specific partition index and that now got +1'ed. I rarely use Windows anyway so I'll leave that for later.

comments powered by Disqus