Installing Linux on a MacBook without OS X
OK, so I have made up my mind. I’m switching back to Ubuntu. Why is a later post but in short I feel that Ubuntu is a better OS if you are a develope, at least a Python/Plone developer like me. This post is to explain some things about how MacBooks boot, and how to install Ubuntu on a MacBook without having OS X on it as well. Oh, and it’s for whining and ranting as well.
Firstly, you need OS X for your MacBook. OS X is the only OS you can use when updating the firmware of the MacBook, and firmware updates on MacBooks can be very useful. Earlier ones have for example increased the battery life significantly. Those things are nice to have. This means that most people who use Linux as the main OS will dual boot. There are several FAQs out there to do this, so I won’t touch on that. If you want OS X only to update the firmware, you can reinstall OS X on your hard disk skipping everything that is optional, and thus use up as little space as possible. Reportedly it should be possible to have a partition size of 10-15 GB for this. Quite a significant space waster just to keep the firmware updated, admittedly.
However, I want to be able to boot into OS X so that I can test things. Sometimes I get reports that things doesn’t work in Safari, and I quite often gets bug reports on Plone4ArtistsCalendar together with iCal. It’s going to be nice to be able to test those reports myself. So I need more than these 10GB, probably around 40GB. And of course, I need to be able to test websites in Internet Explorer as well. I have done that with a Windows machine I have at home so far, but to be able to do it when I’m at a customers place would be a nice bonus. And of course, there goes another 40GB, and then I suddenly don’t have much space left for Ubuntu. Especially since I want separate root and home partitions (this has saved me once earlier, when an upgrade went pear-shaped).
So, I yesterday bought an external HD. The My Passport Studio has faster transfer rates, so I picked that one, even though it’s MacBook Pro silvery, and not MacBook white. (Wester DIgital has Macbook white external drives too, but only of their cheaper, slower model). Turns out the faster choice was good because it also has Firewire, and I later read that MacBooks won’t reliably boot from USB drives, so that was a lucky choice. I’m hoping this has been changed in the new model MacBooks that doesn’t have Firewire.
Anyway, I then proceeded to try to get Mac OS X onto the external HD (easy) and Ubuntu onto the internal HD. That later part was not so easy. OK, if you let Ubuntu take over the whole HD, by default, it’s going to work, but there will be a long delay for about 30 seconds where the MacBook will seem to not do anything. And if you have an external drive connected or a bootable CD in the drive, it will boot from that, no options. What the heck was going on here?
Well, after many tried, lots of reading on different sites and many retries (today I have installed Mac OS X three times, which takes an hour or more each time, and Ubuntu I think five (maybe more) times, which takes some 15-20 minutes or so, all in efforts to get the right combination of partition tables and software and I don’t know what. And here finally is the explanations.
The MacBook 3,1 and 4,1 will only load from HFS+ partitions. If there are none available, it will sit around for 20-30 seconds while waiting for you to insert one. Yeah, really. Only then will it go on to boot from non-GFS partitions. This is to be honest quite astounding, and completely incomprehensible. It’s yet again one of these “It Just Works (If You Do Exactly What We Tell You To) ™” attitudes from Apple. This means that the primary partition has to be HFS+. Obviously, you can’t install Ubuntu to HFS+. Neither, it seems, can you install GRUB to it. You can of course install OS X on it, which is why this all works if you dualboot, but that takes 10GB of space, see above. But despair not, there is something you can install to an HFS+ partition, which is not a big fat OS and will boot, and it’s called rEFIt. It’s a boot menu for EFI machines, specifically MacBooks. It can be installed on pretty much any filesystem, and since it’s designed to be a multi boot system for MacBooks, it works well in this case. After installation of Ubuntu, rEFIt will see the Ubuntu and you can boot it, without having to wait for half a minute.
Here are the rough steps you need to do (I didn’t do it in this order, as I was experimenting heavily, but this ordet should work, I think). Again, this has been tested on a MacBook 4,1. It seems to NOT be necessary on MacBook swith Intel CoreDuo (1,1 and 2,1). But it seems to be necessary on MacBooks with Core2Duo (3,1, and 4,1. I don’t know about the new 5,1).
- Install Mac OS X on the external HD.
- Boot from the Ubuntu Live CD, start Partition Editor (Under System->Administration). If you can figure out a way to remove, add and control partitions in detail in Mac OS X, you can do that instead, but Diskutils in OS X doesn’t seem to have the necessary control to do this.
- Remove the HFS+ partition from the internal HD (/dev/dsa)
- Create a new unformatted partition (we’ll format it from OS X). rEFIt will use up 14MB, so probably 20 MB is enough. Yes, MB, not GB. I have a 50MB partition for rEFIt.
- Reboot into OS X from the External HD. Format the new partition as “Mac OS Extended” (That’s HFS+). Mount the newly formatted partition.
- Download rEFIt, and follow the instructions to install it on an external HFS+ Volume. At this point you probably want to change the refit.config to have a lower timeout than 20 seconds. 2 seconds is good IMO. You should now be able to boot into rEFIt from the internal HD. If not, something is wrong. You still don’t have any OS installed to boot from though, but if you get the rEFIT menu up, your good.
- Reboot from the Ubuntu LiveCD, and install as usual. Do NOT select “Use entire HD” as this would delete your rEFIt volume. Largest free space should work (although I always use manual, and have separate root and home volumes).
This is all and well, and works. The only minor stupidity with this, is that you now have a two-step boot. And to explain why, we must talk about EFI. EFI is the new successor to the BIOS that has been around since the original IBM PC. But of course, not all software that needs to support EFI does that, so therefore there is also a BIOS compatibility mode. EFI also uses a new sort of boot procedure, based on something called GUID Partition Table, or GPT instead of the old MBR one. The booting will revert to MBR if there is no GPT, and in this case it will also enter BIOS compatibility mode (I think).
Now, GRUB is a MBR type loader that uses BIOS compatibility mode. And you have to have it. Because although there is an EFI boot loader from Linux, ELILO, if you boot the machine completely in EFI mode and not in BIOS compatibility mode, you won’t have a BIOS, and lo, the graphics drivers require this, so you can’t run the proper graphics drivers, so graphics performance will suck. And the reason the graphics drivers require this, seems to be that Apple refuse to tell the driver developers how to support the cards without a BIOS.
This sucks, Apple. This, really, really, sucks. I was told that now the MacBook is an open platform where you can run any OS. Well, that is still, unfortunately, bullshit. Apple and their platforms are still not open. Sure, when it comes to the iPhones they have blamed the carriers. I don’t believe that anymore. Help the Linux people write proper ELI drivers for your machines, if you are serious about this. I understand you don’t want OS X running on normal PC’s. You are using OS X as an argument for buying your hardware. If you sold OS X separately your machines would be cheaper and your upgrades more expensive, and that would probably not be good for business. But making it hard to run OTHER things on Macs doesn’t make any sense.
All in all, I can not recommend you to buy MacBooks unless you intend your main OS to be OS X. And I can’t recommend OS X to a developer. Yes, this buy was a mistake.