Installing Debian on an Intel Mac Mini

I found installing Debian on a Mac Mini very difficult, but it needn’t be. There are many instructions and suggestions around the web, but I couldn’t find all the information in one place, and when things went wrong I could find no help. So, now that I’ve got a working install I thought I’d blog it in the hope to help other avoid the problems I had.

My Mini is a late 2010 model, the Model Identifier is

Mac Mini 4,1

You can find the model identifier of your machine by selecting Apple menu -> About this mac -> More Info. The model identifier is shown in the hardware overview.

I don’t know which models this information will work with, but if you try it with a different model please let me know of your success, or any problems you had so that others may benefit.

Overview

My preference is for a net install of Debian. This way I have the most up-to-date security patches and fixes, and my machine should be good to go when I’m finished with the install.

I chose to keep OS X on my machine in a small partition in case I need it for a firmware update at a later date.

There are two major problems with putting Linux on a Mac – an Intel one at least. The first of these is that Macs have no BIOS, what they have instead is EFI. Linux needs a BIOS so that it knows how to interact with the hardware. We get around this with problem with a replacement EFI called rEFIt.

The second major problem is the hardware in these boxes is either new, and therefore not in the regular install kernels, or it is set up to work in some non-standard way.

These problems lead us to need a custom install disk for this hardware, it may be that, in time, install disks become available that overcome these problems. Fortunately someone has already done this work for us, this web-page has a link to custom net install .ISO that can be used to boot the system and perform the net install. It also has the kernel you will need to boot machine after install.

Step one

Use Boot Camp Assistant to partition your hard drive. You can find BCA in the Utilities folder within the Applications folder. You can drag the partitions and re-size to however you want, I partitioned mine so that OS X has about 20 gigabytes, which is plenty, and it leaves a round 300 gigabytes for Linux. This machine is now a mail/news/web/samba server on a home network, if you’re installing for a different purpose then you’ll likely need to resize the partitions differently.

I set the new partition type to FAT, it stands out better when it comes to partitioning within the Debian install. When Boot Camp Assistant asks for the Windows disk (why don’t Apple acknowledge that people might want to install Linux?!) quit the program, it’s already done it’s job.

Step two

Download and install rEFIt. This is another reason for keeping OS X on the system, the rEFIt files reside in the OS X partition, I haven’t investigated, but there may be other ways to have rEFIt on the sytem without retaining OS X, but this works for me.

Step three

Put the CD burned from the .ISO mentioned above (or linked directly here) into the drive and then re-boot. At the sound of the ‘bong’ (what is that sound called?) press and hold the ‘c’ key, this will cause the machine to boot from the CD. From the boot menu choose ‘Advanced options’ and then ‘Expert install’ it is important that you do not choose the regular install as this does not give you the option to install the custom kernel.

Step four

Go through the install steps as they are presented to you, take note of which /dev your ‘/’ partition is on – you’ll need this for when you install the grub or lilo. Any that are skipped are either not important, or you can deal with them post-install.

At some point you’ll be presented with a list of possible kernels that you can install, you must install the one that comes with the .ISO, it’s linux- image-2.6.35-stlee-mac-mini-i686, this is the one with the drivers for your hardware.

When it comes to installing the initrd/initramfs choose the generic option, the machine specific option did not work on my Mac Mini, I don’t know why, but this had me banging my head against the wall for a long time and I didn’t know why it wouldn’t work. I spent many hours trying to fix it, but to no avail. Just use the generic version, it works and doesn’t cause headaches or drowsiness.

I chose grub (it’s actually grub2) instead of lilo, on a previous install attempt I chose lilo and it didn’t work, whether lilo would have worked had I chosen the correct initrd/initramfs I don’t know. Grub doesn’t tell you where it’s going to install so you have, at that point, choose to manually set the mount point, and enter the device you noted earlier. I don’t know how this will work if you are using a separate /boot partition.

Step five

Before completing the install and re-booting you must edit the file /etc/defaults/grub and change the line GRUB_CMDLINE_LINUX to include reboot=p nouveau.modeset=0 after which you need to execute a shell, and chroot into the install environment and run update-grub. If you forget to do this then you can boot the machine in rescue mode with the install CD, and execute a shell in the install environment and then carry out the above (which is what I had to do). If you don’t do this then part way through boot you will lose your display! The machine will be up, and all services running, it’ll even be waiting for you to login, but you’ll have no display. The reboot argument enables the OS to actually reboot the machine, rather than just halt it waiting for you to manually power-down, it’s the nouveau.modeset that stops the display disappearing.

Step six

You can now eject the disk and reboot, but if you’ve changed the partition table at all (very likely) you’ll need to run/re-run rEFIt to get the new partition table read. To do this start Terminal.app and:

cd /efi/refit

sudo enable-always.sh

That should be all that is required, a reboot at this time should give you the rEFIt boot screen and an option to boot either OS X or Linux, if you choose Linux you should get a grub boot menu showing your Linux install as the default, a rescue version of your Linux install, OS X 32-bit and OS X 64-bit.

Done

That’s it. There were a couple of things that I didn’t pick up from the wiki.debian.org/MacMiniIntel page that led me to have problems with the install. One was that there is indication that you should use the expert install method (regular install has always been fine for me in the past). And the other was that I didn’t know to use the generic initrd/initramfs. If I’d known both of these I’d not have had any trouble at all.

The MacMiniIntel page is a wiki, so I suppose I could edit it, but it’s not written well enough for me to just append the necessary, and as it’s someone else’s project (having created the net install .ISO) I don’t want to tread on any toes. I’ve sent the maintainer an email but had no reply.

I hope this page is found without too much difficulty and helps someone avoid the pitfalls that I experienced. Please comments regarding your experience either way so that I may update the page.

  1. Seunghun Thomas Lee

    “These problems lead us to need a custom install disk for this hardware, it may be that, in time, install disks become available that overcome these problems.”

    this is true now. using latest official wheezy (current debian testing distribution) install disks will work now.

  2. Seunghun T Lee Seunghun Thomas Lee

    oh and i just noticed this

    “I’ve sent the maintainer an email but had no reply.”

    i must have missed your email. i can’t find it. but this is a good guide. and wikis are community owned anyway.

    please feel free to edit the wiki in any way you see fit.

  3. Peter

    Hi STL!, I was glad to find your guide for Linux install on a Mac Mini 4,1. I too have found it very difficult, having tried out many distros, and failed on all including Ubuntu -actually did get Ubuntu 11.04 working, but clonked it by trying to speed up boot process with e4rat, oh well, try, try again!. I have yet to successfully boot with Debian, and noticed that in your guide, you advise to use grub, whereas in the wiki, you mention using lilo…I’m confused now, which is best? Thanks!

  4. justin

    The wiki was not written by me, I think I tried lilo and didn’t have any joy with it either. I do remember the install being a frustrating process.

    Re-reading what I’ve written I see that step six is not very clear. I booted OS X, and used the Terminal.app to run the command, it may well be that step (or not actually finding how to do it) that causes people to have a non-booting Linux on one of these boxes.

    Good luck with it!

  5. rahul

    Nice article, thank you for posting. Although i followed the steps, my MacMini is unable to boot and it hangs at a screen with a folder and question mark flashing. Did you encounter this problem, any ideas how i can fix it ?

  6. justin

    I’m not certain, but I think it’s a problem with rEFIt, I don’t think it’s finding anything to boot. Can you still boot OS X with it? If not, I’d re-install OS X and start again, getting rEFIt to work with the current OS X install first.

    If you can still boot OS X then I think you only need to look at the Debian install. Take particular care not to not follow the default install. The installation and setting up of grub2 are likely where your install has failed – and why you’re getting the ‘no boot device’ type error, this was where I had trouble, I ended up re-installing from scratch. Steps 4, 5 and 6 are the most critical.

    It’s actually over a year since I did this, none of it is fresh in my mind! I found the hardware unstable and it locked solid requiring a hard reset at various times, and I still don’t know if it was Debian on Apple hardware, or the hardware itself. It’s now got OS X (Snow Leopard) on it again, and it still locks up solid from time to time (though less often), so I’m not able to conclude anything. It’s used for iTunes and DVD playing, driven from Front Row through the TV. I bought an HP Proliant Micro Server, about 250 quid and it had a 100 pound cash back too (which I think you can still find in some places). That took to Debian like a duck to water. I’m much happier with this set up.

  7. Tim

    Hi Justin – thanks for providing this write-up, you’ve certainly made things clearer than I have found elsewhere. I know that you’ve now moved on from the Mac mini in favour of the Proliant Server, but was wondering if you had any comments on the following as I have never installed Debian (or any Linux distro) until now.

    I have found that with the latest firmware update on a new Mac mini (5,1) it is now possible to boot from a USB stick without any need for rEFIt. Hopefully this is good news given your experiences.

    However, even though I have downloaded the Debian Live 6 Gnome Desktop ISO (http://cdimage.debian.org/debian-cd/current-live/i386/iso-hybrid/debian-live-6.0.3-i386-gnome-desktop.iso), what actually boots is a very basic graphical interface with an icon for the Debian installer (along with a basic file/directory navigation app). Is this what you would expect from a Live CD? Of course this is only a standard iso without any Mac specific patches but I was kind of assuming it would boot through to Gnome, given the “live install” description here http://www.debian.org/CD/live/

    I have not yet attempted the installer; here is why. From what I can make out of the installer it will install Debian onto the Mac mini HD, which I don’t want. Ideally I want to keep the Mac mini HD for Lion and install Debian onto a FireWire 800 external drive. During the install process do you know if Debian can be installed onto an external drive? Of course this opens up the question again of how the Mac will know that it should offer this as a bootable drive following the installation. Maybe (hopefully) it just knows, like it now does for USB sticks following the firmware update.

    Any thoughts on this would be greatly appreciated.

    Regards, Tim

  8. rahul rahul

    Thanks for the quick reply Justin. I was basically trying to get 1) get linux running on MacMini, i didn’t care about having a dual boot with Mac 2) get xen running. I was not using rEFIT at all. I tried installing Ubuntu 11.04 on the MacMini and that worked, so i am all set. Thanks for making this wiki btw. Let me know if you experiment with installing just Debian without rEFIT and get to make it work. Thanks.

  9. justin

    Sorry for the delay in replying. Been away from things for a while (bloody MineCraft). I think the only reason I kept dual boot was because I could find no other way of booting without a BIOS. It’s great that you’ve got Ubuntu to work, this means that Debian should be installable, once someone has figured out how Ubuntu handles the booting. Good news all round. I love the MacMini hardware, and I do like OS X as a desktop OS, but for servers I still prefer Debian over all else. Thanks for posting this, even though it’s too late for me I hope it will help others.

  10. justin

    I’m sorry, Tim, it was all so long ago I remember very little other than what’s in my original post.

    Over about the last ten years I’ve only ever used Debian’s NetInst ISO because I’ve usually got hardware that is well supported. As you saw from my post, this wasn’t the case with the MacMini and I had to search out a custom install ISO.

    You’re moving into territory that is very alien to me WRT wanting to install to an external device. However, as far as I can see, if the machine will boot from the external device then it must see that device as it’s root/primary drive, you just have to be very careful when choosing which disk to install to once you get to the partitioning stage. I suppose, if you have decent back-ups of what’s on the Mac’s internal disk, and you cock up the install (by installing to the wrong disk), you can re-install to the right disk and once that’s sorted, unplug the FireWire drive and re-install Snow Leopard and then Lion from the App Store (if you can remember your login details).

    I do wonder how recovering Lion/Mountain Lion will go in the future with, as I understand it, Apple supplying a recovery partition on the device. People installing Linux (or other OS) to the HD will have to be very careful not to overwrite that if they may ever want that back to an Apple OS.

  11. Tim

    Cheers Justin, no need to publish this comment I just wanted to thank you for answering. I’m over the worse of it now. I ended up installing an additional internal hard drive and installing Debian on that. I can now boot either OSX or Debian and I also got to keep the Lion recovery partition doing it this way. Cheers.