Dual Boot Mac OS X and Linux

by Sanjeeva Wijeyesakere

 

Disclaimer: Please read through this entire article before attempting to install or configure software. Also note that any installations you undertake are at your own risk and you should ensure that you have thoroughly read and understood the manufacturer’s instructions and caveats for each software package you install. You should also make sure you have a recent backup of ALL your files, data, software, etc. (just in case anything goes wrong).

 

With the release of the latest version of OS X (10.8 a.k.a ‘Mountain Lion’), I decided to upgrade my old MacBook (an early 2009 MacBook 5,2). Since this system had been through two OS upgrades (first to Snow Leopard and subsequently to Lion), a clean install was warranted to get rid of three years of cruft. However, given that certain scientific computing software is only available for Linux or Windows, I thought I would try to setup my MacBook to dual boot both OS X Mountain Lion and Linux.

The first question that arose was which operating systems I should install. On the OS X side, the answer was easy (Mountain Lion). However, given the plethora of Linux distributions, the decision was a little harder. I considered CentOS, Ubuntu, Debian and Linux Mint. After testing virtualized instances of CentOS 6, Ubuntu 12.04, Linux Mint (Debian Edition) and Linux Mint 13, I decided to go with Linux Mint 13 (MATE edition). While Ubuntu’s Unity interface looks promising, I found it to be too bold a paradigm shift to be workable as my primary user interface. MATE, on the other hand, provides the user with the classic GNOME 2 desktop environment and the version distributed by Linux Mint includes numerous UI enhancements (such as the excellent Mint menu). Having made my OS decision, here’s how I went about proceeding with the installation.

 

Update: When OS X 10.9 Mavericks was released, I was able to update my OS X installation without affecting my dual-boot setup. Similarly, I updated my Linux Mint installation from version 13 to version 16 by booting into the Linux Mint installation DVD and installing it [Liunx Mint] over my existing Linunx partition.

Getting started

In order to setup your dual-boot system, you will need the following software:

  1. An OS X Mountain Lion installation disk (bootable USB drive or DVD) – you can create one from the OS X installer downloaded from the App Store.
  2. A Linux install disk (in my case, I chose Linux Mint).
  3. Refit – An EFI boot loader.
  4. GPT fdisk – A disk partitioning tool.

The installation

1. First, perform a clean-install of OS X (this involves re-formatting your hard drive and will result in the loss of all data, so make sure you have backed up everything (data, software, photos, e-mails, etc.) you want to save).

To perform a clean-install, boot into the OS X Mountain Lion install disk and launch Disk Utility. Then, partition your hard drive to create two partitions: an HFS+ volume for OS X and a second partition (I left this as free space) for your Linux install. Before proceeding with the partitioning and formatting, set GUID as the desired partition scheme (set under ‘Options’). Once your disk is ready, install OS X in the HFS+ partition.

2. Boot into OS X and install both, Refit and GPT fdisk. You will need to reboot the system a couple of times before you see the Refit menu at startup:

 

Dual Boot OS X and Linux

Figure 1: The Refit menu (Note: Refit will only display the Apple Icon until you install your Linux distribution)<br>
 

3. Boot into your Linux install disk and proceed with the installation, and partition the free space on your drive as follows:

a. 100MB for a reserved BIOS boot area
b. Your primary Linux partition
c. Linux swap area (corresponding to approximately twice as much RAM in your system).

Important: At this point, tell the installer to install GRUB (the Linux boot loader) to your primary Linux partition (in my case, this was /dev/sda5).

 

4. After installing Linux, reboot your system while pressing the option key, at which point you will see the Macintosh boot loader. Select the ‘Windows’ option as your boot partition (Figure 2; for some reason, the Mac’s boot loader thinks your Linux partition is a Windows installation).

boot_screen1
Figure 2: The Macintosh boot loader.
You will get an error message saying that there is no OS installed (this is because the OS X Recovery partition gets in the way and will need to be fixed by creating a hybrid MBR in step 7). At this point, reboot the system once more.

 

5. When you see the Refit menu (it will look like Figure 1), select the ‘Start Partitioning Tool’ option and proceed to synchronize the partition tables. Afterwards, restart your system.

 

6. Confirm that everything is in order by booting into your Linux partition from the Refit menu (Fig. 1). Once more, you will see an error saying that the OS couldn’t be found (this will be fixed in the next step). Reboot your system.

 

7. Boot into OS X, open a new Terminal window and launch GPT fdisk using the following command (assuming OS X and Linux are installed on the first hard disk (disk0)):

sudo gdisk /dev/disk0

Enter ‘r’ (to access the recovery and transformation options) and then ‘p’ to show your partition table (you will see a list similar to that seen in Figure 3).

gptfdisk
Figure 3: GPT fdisk’s printout of a partition map
Create the hybrid MBR by pressing ‘h’ and enter the numbers corresponding to the partitions you want to add to your MBR (2 and 5 in my case). Answer ‘yes’ to the question asking whether to place the EFI partition first. Fdisk will then ask for hex codes for each of the two partitions. The code for your OS X HSF+ partition is ‘AF’ and the code for the Linux partition is ’83’. You don’t need to set any bootable flags for these partitions. Since only two partitions were entered, you can decline the offer to protect the additional partition space. Once this is complete, you can enter ‘w’ to write the changes to the disk. At this point, you can use the Refit menu to boot into both, your OS X and Linux partitions.

 

Customizing Linux and getting things to work

One of the advantages of using Boot Camp to dual boot OS X and Windows is that Apple provides Windows drivers for your computer’s hardware. Fortunately, I found that most of my MacBook’s hardware (keyboard, trackpad, sound, etc.) worked without the need for any configuration. However, I did install the proprietary drivers for my Nvidia graphics card and Airport card (a Broadcom BCM4322 card). To identify the model of your WiFi card use the following command:

lspci -vvnn | grep 14e4.

After installing the proprietary Nvidia drivers, I followed the instructions on this site to get my Macbook’s LCD brightness controls working (this fix worked for a Linux Mint 16 installation on a MacBook 5,2).

Thus far, I have not been able to get my computer’s built-in iSight camera to work in Linux. However, since I rarely use this camera, it does not prevent me from using Linux Mint as a viable OS on the MacBook.

Almost immediately after booting into Linux for the first time, I noticed that my MacBook’s trackpad felt less responsive, requiring me to press much harder to move the mouse pointer. This was fixed by editing the synaptics configuration file (50-synaptics.conf) file in /usr/share/X11/xorg.conf.d. Simply add the following lines to the “InputClass” section of the configuration file:

Option “FingerLow” “1”
Option “FingerHigh” “10”

After making sure that everything was working, I installed my default application set:

  • Web browser: Google Chrome
  • Text editor: Vi (installed by default); installed its GUI counterpart gVim
  • Audio editor: Audacity
  • PDB viewer: PyMOL; also installed autodock and vina
  • Molecular modeling environment: YASARA

 

I also disabled the animations in MATE by installing the dconf editor and selecting the ‘reduced-resources‘ option under org > mate > macro > general. To install the dconf editor, open the terminal emulator and issue the following command:

sudo apt-get install dconf-editor

 

If you need access to Windows software like MS Office, you can try to get it running using CrossOver, which is based on the open-source Wine project, but has better support for popular Windows applications like MS Office (using CrossOver, I am able to run use Office 2010 in Linux Mint 16).

Finally, while I had intended to use MATE as my primary user interface, I also installed the Cinnamon, a desktop environment developed by the Linux Mint team and based on GNOME Shell and WindowMaker, a light-weight window manager that integrates with GNUstep.

cinnamon1
Figure 4: The Cinnamon desktop
I have found Cinnamon to be a nice compromise between the ease of use of GNOME 2 and the new interface paradigms introduced with GNOME 3.

An alternative to a heavy-duty desktop environment is a window manager. Window managers are light-weight GUIs that offer a pleasant graphical work environment without the heft of a full-fledged desktop environment like GNOME or KDE.

wmaker-desktop
Figure 5: Window Maker
 

References

  1. Ubuntu WiFi Documentation for Broadcom cards
  2. Hybrid MBRs – rodsbooks.com
  3. Refit documentation