Saturday, May 28, 2011

Dual-boot OSX and LINUX on 2010 Mac Mini (4,1)

I've spent several nights loading various distributions of Linux on my Mac Mini. Since the Mini is based on Intel core2duo it should be easy for someone experienced with linux right? well...its not hard once you understand that the Mini does not use BIOS like PCs do. It uses EFI to boot and has a small 200MB partition that is used to install flash updates (sda1). The Hard drive uses GUID partitioning (GPT). Because of these new technologies and newer hardware, some distributions may not boot. The following covers how to install Ubuntu 11.04 and Debian testing, but will work for most distributions.

Lets start, the easiest and I think best way to dual-boot is to install a boot manager called rEFIt. rEFIt provides a nice icon menu at boot up in which you can select osx or Linux. It also has some nice tools. From OSX, download and install rEFIt. Reboot. Reboot again and the rEFIt screen should come up with icons for osx and various tools. Boot back into osx.

Next, download the 64 bit alternative ubuntu iso. You can use the standard 32 bit Ubuntu if you prefer, just remember to manually partition so that you can select the location for grub. If you prefer Debian, download Debian testing .iso (The stable version didn't recognize the mini's ethernet hardware). Use osx's disk utility to burn the .iso to a CD. Run Bootcamp and select a new partition size (the default 20GB should be fine) and then select "quit and install windows later". Make sure the newly created CD is in the drive and reboot.

When the rEFIt screen comes up select the CD-Rom icon. When the install Ubuntu/Debian screen comes up press F6 and select "nomodeset" or press e and type into boot options (debian). Otherwise you will get a blank screen due to the default nvidia driver that doesn't work fully on mini.

Begin the installation. When you get to the partitioning part, choose manual and then delete the Bootcamp partition. Create a / partition with ext4 and set the boot flag. If you have less than 4gig of ram also create a swap partition the size of your physical ram. You should now have an sda3 / partition and if you added a swap partition, it should be sda4. Towards the end of the installation you will need to install the grub boot loader. The only safe way for future updates is to install to the / or sda3 partition. Type in /dev/sda3 and finish the installation. Reboot...wait it wont reboot..we will fix that later. Hold down the power button for a few seconds to shut off. In case of errors..See Note 1 and 2 below.

Turn on mini and you should now have an icon for Linux on the rEFIt screen. Don't click it yet, instead click on the disk partition icon. Type Y to sync MBR. Click on the OSX icon to boot into osx. Reboot. Back at the rEFIt screen click the Linux icon and after a few seconds the grub menu should appear. Boot into linux. To fix the reboot issue, launch terminal and type "cd /etc/default" and then "sudo gedit grub". Find the line that reads GRUB_CMDLINE_LINUX_DEFAULT, and enter "reboot=pci" at the end of the line. Save the File and exit gedit. At the terminal prompt, type "sudo update-grub"

Now the fun part of configuring everything.. but thats too much to write here :) Enjoy the freedom that apple doesn't allow, such as tiling window managers, etc. P.S. Apple please add a reset button and CD eject button on next mac mini. It's not great having to boot into osx to eject a CD or to reboot by turning off power (i never thought i would miss CNTRL-ALT-DEL). But I guess I could have bought a PC :)

NOTE 1: If you accidently deleted or want to erase SDA1 (in case of corruption) you can restore it by resizing the Hard Drive using osx disk utility (good job apple).

NOTE 2: If you wrongfully installed grub to the MBR or sda, you can fix it by typing "sudo fdisk -u /dev/disk0" in osx terminal.