I recently came into ownership of a 2008 unibody MacBook. One of the first aluminum ones. It’s been serving me well, and I recently replaced the unused DVD-ROM drive with a drive caddy containing a second SSD I had lying around.
I didn’t really have a use for the space so I thought I would challenge myself to get Ubuntu Linux installed on the second drive.
I’m going to detail my experiences here while trying to be as general about the installation and EFI boot process as possible.
First I downloaded an Ubuntu ISO image and use hdiutl to convert it to a DMG:
hdiutil convert -format UDRW -o ubuntu.img Downloads/ubuntu-15.04-desktop-amd64.iso
This will actually generate a file named ubuntu.img.dmg, but we’re just going to write the contents to a USB flash drive, so the name doesn’t matter.
I then plugged in a USB flash drive and used diskutil list to determine the device path – /dev/disk4 in my case.
Using diskutil again, I prepared the flash drive to accept the installer image:
diskutil partitionDisk /dev/disk4 1 “Free Space” “unused” “100%”
Be sure to replace /dev/disk4 with the device path you determined in the previous step.
Finally I copied the installer to the flash drive:
sudo dd if=ubuntu.img.dmg of=/dev/disk4 bs=1m
Again, be sure to replace /dev/disk4 with the correct path.
Eject the flash disk (replacing /dev/disk4):
diskutil eject /dev/disk4
Now it’s time to boot the target Mac. Plug the USB drive into the Mac and hold Option while it boots.
You should eventually see at least two boot selections. One will be a yellow USB drive icon with the label “EFI Boot”. Use the cursor keys to select it and press enter.
Now you can install Ubuntu normally. Ensure you have free, unpartitioned space. I was using an entirely separate drive from my OS X drive, but you need to ensure you don’t overwrite your OS X install. Also, create a small 128MB partition during the install (or from Mac OS X prior to the install) – this will hold the EFI loader.
Once Ubuntu is installed you need to create an EFI boot loader so the Mac’s firmware can boot the OS.
You need to have GRUB2 installed to accomplish this. Here’s the command:
grub-mkstandalone -o boot.efi -d usr/lib/grub/x86_64-efi -O x86_64-efi –compress=xz /boot/grub/grub.cfg
This will generate the file boot.efi in the current directory. You need to get this to the Mac side of the computer. Either copy it to another USB stick, or over the network to another system.
Now reboot back to Mac OS X.
Make sure the 128MB partition is formatted as OS X Extended Journaled.
Open a Terminal window and navigate to the EFI partition you created, possibly something like:
cd /Volumes/Ubuntu_EFI
Create the required directory structure:
mkdir System mach_kernel
cd System
mkdir -p Library/CoreServices
cd Library/CoreServices
Copy the boot.efi we generated into this folder (CoreServices).
Open a new text file in your favourite text editor (I prefer vim) named SystemVersion.plist with the following contents:
Finally, we need to “bless” the volume
sudo bless –mount /Volumes/Ubuntu_EFI
Also, to set a boot label other than “EFI Boot” we need to use the bless command again:
sudo bless –folder /Volumes/Ubuntu_EFI -label “Ubuntu”
sudo bless –folder /Volumes/Ubuntu_EFI/System/Library/CoreServices -label “Ubuntu”
Substitute your own desired label for “Ubuntu”. Why do I run it twice? It takes a full reboot cycle to see if trying to set the label was successful or not. I just ran both of those together between reboots – so I have no idea which one was the one that set it. Sorry.
So hopefully this will get you on track to getting Linux set up on your Mac if that’s you goal.