/ mac mini

Booting a Mac Mini (OCT 2014) with Debian 8.0

There are a lot of guides on booting Linux on an Mac Mini, and the Mac Mini is absolutely great. There's also a lot of guides which takes some unnecessary steps on the way from the native OS X experience to the bloated, and difficult-to-setup Linux on OS X. Some of them are good on certain points though.

So, not surprising, I will tell you how to make it work with both a native EFI installation and the Broadcom BCM4366 up and running.

Everything will be done on the command line, so this will work great on servers as well. Of course you won't run wifi on the work server though (!).

First, take note that this will wipe almost everything Apple from you box except the Firmware. You may roll back through pressing the ALT-key while booting.

Second, you should use Debian 8.0 "Jessie" (which is currently in RC1). This is important since Wheezy doesn't support the Broadcom chipset.

Prerequisites for this article are:

  • A Mac Mini, tested on an OCT 2014 model
  • A keyboard
  • A USB memory stick of at least 2GB (speed is the key)

1. Install Debian - and Change Boot Order

You should create a bootable USB stick for your Debian installation. When you've downloaded the ISO, you can make it bootable without hassle through unetbootin. That one works on OS X 10.10 "Yosemite" as well.

When you've got that one ready insert it into the Mini, holding the ALT-key while booting. You will get to the boot menu, choose the "EFI" one. This will initiate GRUB from the stick.

Do the installation as you would on any other machine. Since your mac is still setup to boot to OS X, we need to change that next in order to make it point to the Debian installation instead.

When rebooting, get into the boot menu by holding the ALT-key again. Select that same GRUB menu again, BUT instead of choosing to install it you should now press "c" to get to the GRUB command line.

It is now time to locate the boot directory on the right disk. Vary X (disk) and Y (partition table) until you find the right combination:

grub> ls (hdX,gptY)/boot/grub

That may for instance result in:

grub> ls (hd2,gpt2)/boot/grub

Set the root to that disk and partition table, and boot it:

grub> set root=(hd2,gpt2)
grub> ls -l (hd2,gpt2)
grub> linux /boot/vmlinux[...].efi.signed root=UUID=[uuid from above command]
grub> initrd /boot/initrd[...]
grub> boot

You will now boot to the one you just installed. It is time to make it persistent and change the boot order with efibootmgr. First list your current settings by:

sudo efibootmgr

Now change the boot order (may vary, point being that Debian should come first):

sudo efibootmgr -o 0,1

Now reboot and enjoy the darkness without wifi.

2. Get Wifi Up and Running (Offline)

The current Broadcom chipset is quite new, so you'll need to step it up to Debian "Jessie" to get it working. Cutting this a bit short, you will probably need this part to be offline. Showing you a small trick you can get all those dependencies on a vmware installation (run the same image as the one you installed, remember to simulate that you don't have network on that virtual installation):

apt-get -qq --print-uris install build-essential linux-headers-$(uname -r) broadcom-sta-dkms patch bzip2 wpasupplicant | cut -d\' -f 2 > urls.txt

This will produce a file of urls that are all the packages requested and its dependencies, get the stick, format it with FAT - and grab the packages to it:

wget -i urls.txt

Unmounting that from the virtual installation, insert it into the physical installation:

cd /mnt/usb
dpkg -i *.deb

Remove all modules that may conflict (and blacklist them in /etc/modprobe.d/blacklist.config):

modprobe -r b44 b43 b43legacy ssb brcmsmac

Load the Broadcom module:

modprobe wl
echo wl >> /etc/modules

Everything that's left now is configuring and starting wpasupplicant:

wpa_passphrase <ssid> [passphrase] > /etc/wpa_supplicant.conf
wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant.conf

To make it persistent enable the interface in /etc/network/interfaces by appending:

auto wlan0
iface wlan0 inet dhcp
    wpa-conf /etc/wpa_supplicant.conf

If you have made an exception in your DHCP pool, you should also make it static (basic stuff, but anyways):

auto wlan0
iface wlan0 inet static
    wpa-conf /etc/wpa_supplicant.conf

That's basically it. Enjoy the show!

Edit 1, FEB 7th 2015: So I got to play with systemd, since it turns out a service isn't a service the way it used to be. In order to start services in Debian "Jessie", you'll need to use systemd. Here's an example for znc:

Description=An advanced IRC bouncer
After=network.target oidentd.socket
ExecStart=/usr/bin/znc -f $ZNC_OPTIONS
ExecReload=/bin/kill -HUP $MAINPID

Also create the directory and drop the following line into /etc/conf.d/znc: ZNC_OPTIONS="-d /var/lib/znc"

Edit 2, FEB 7th 2015: To enable the Mac Mini to auto-restart after power failure set the following PCI value:

setpci -s 0:1f.0 0xa4.b=0