How to Install Linux on a Mac

Here are some notes about installing Linux (in particular CentOS 5, but that shouldn't matter, it could be Ubuntu etc) on an Intel-based system running Mac OS X 10.4.11 "Tiger", in my case a MacBook but this should be the same for other Macs.

The summary for the impatient is:

0) Preparation: Get the DVD / CD-ROMs of the Linux distribution you want to install and backup the data in your computer.

1) Re-partition the hard drive to make space for the new operating system. I used Apple's Boot Camp which can be downloaded.

2) Install a boot loader or boot manager, I used the open source rEFIt.

3) Install Linux on the newly made partition, make sure that GRUB goes in the 1st sector of the boot partition, not Master Boot Record (MBR).

Now the details.

0) Backing up my up disk. I have an external (USB) hard drive: "Maxtor OnetTouch III Mini Edition". The OneTouch software is a disappointment; both the synchronization and the backup failed, the first one choked on one file and crashed but I only found out after looking at the logs; the GUI kept showing the same thing. For the backup method, it just kept saying "Completed back up. 0 items were updated" and again it the logs there was some cryptic problem that prevented the program from starting.

1) Apple is including Boot Camp as part of his new OS version "Leopard", and they took out Boot Camp 1.4 from their web site. I couldn't find it online so I got Boot Camp 1.3 instead.

After installing and running it I see that the smallest new partition you can create is 5GB. Boot Camp formats the new partition with the Windows file format but we don't care because we are going to re-format it. There's also an option regarding Windows drives that we can ignore.

When I tried to re-partition the disk I kept getting an error from Boot Camp: "Your disk cannot be partitioned because some files cannot be moved", and it suggested to start all over: to copy all my data from the MacBook, reformat the disk, reinstall OS X etc. No Way.

It was worth a shot to try and delete some big files. I couldn't find any free defragmentation tool. I downloaded Disk Inventory X, which is a nifty tool that shows you graphically how big the files in your disk are.

I deleted a bunch of unneeded big files and I also found a big "sleepimage" file (as big as your RAM) that is used for hibernation and followed these instructions on how to delete sleepimage.

Basically (just in case the link disappears):

$ sudo pmset -a hibernatemode 0
$ sudo nvram "use-nvramrc?"=false

reboot and $ rm -f /private/var/vm/sleepimage

After this I was able to run Boot Camp successfully. Note that if you're getting the "cannot move files" error with a bigger partition if you make it smaller (down to 5GB) you increment the chances that the "unmovable" files are not in the smaller partition.

2) I downloaded and installed rEFIt, the rEFIt 0.10 Mac disk image.

With this rEFIt version for Mac there's no need to manually run the install script and move its folder.

At this point with the bootable Linux DVD (or CDROM), if you restart the Mac you'll get rEFIt's boot menu first of all, where you can choose if you want to start OS X or from disc.

3) Once we have made space for Linux and we got the boot manager we can just proceed an install Linux from disc as normally, we only have to be careful in the format/partition section of the installation to use the space we created (it will show as FAT32) and not to format or use the shrunk HFS partition used by Mac OS. We can safely delete that partition and use the free space to create our Linux partitions.

The other thing to be careful is to Install GRUB (or LILO, the Linux boot manager ) in the 1st sector of the boot partition (that would be 'root' or / if you don't make a /boot partition) , not onto the Master Boot Record (MBR). Red Hat and CentOS have this option by default.

That's all. I'll just comment that I found CentOS 5 bloated; I tried a minimal installation by unselecting almost everything (but with KDE) but still after installation I takes over 3GB. There are lots of gnu packages and even 300MB of an openoffice core file even if I unselected all office applications. After the first reboot I also unselected SELinux but then I had lots of SE services running, among with sendmail, cups and many others.