multipart-message nevyn bengtsson's blog

featured articles 🦄, about, archive, tags

MacBook Pro Ubuntu triple-boot dancing

I’ve had some serious problems installing Ubuntu on my MacBook Pro (revision D, the penryn edition, released start of 2008; the model before the unibody MBPs). I’ve tried twice now, once with 8.0 and then with 8.1.

After installing Ubuntu exactly according to the instructions at the Ubuntu wiki, the Windows installation would be broken. Directly after install, when trying to boot Windows, it would bluescreen for a fraction of a second and then immediately reboot. I’ve found through googling that the error message is “invalid boot volume” or something like that. Anyways, I googled some more and found out I had to resync the MBR and GPT partition tables, so I’d install refit and do that. After that, I’d just get “hal.dll missing or corrupt”! What the hell! Turns out the boot.ini needed tweaking to point to the right partition, but even after fixing that, I’d just get the bluescreen again. At some point I also just got a blinking cursor at boot.

Anyways, after hours troubleshooting I found this article on icrontic which describes a procedure that actually works. However, that’s not the one I followed; instead, I followed Craigular.B’s instructions, which you can find if you scroll down through the comments. I’ve replicated and annotated his comments below, with further elaboration for people who might not be as linux savvy as me or him.

Needless to say, make a complete backup of your machine before proceeding. I’m not even kidding. I don’t know how many times I avoided heeding that advice and just went through anyway, and I’ve regretted it several times. Just get an external disk and SuperDuper! your disk to it. It’s not very expensive.

Please read the notes at the end before proceeding.

Here we go:

  1. Install 10.5. No need to partition yet, just install like you usually would. However, don’t run Boot Camp Utility! We’re going to use the diskutil command.
  2. When the installation is complete and you’re ready, open up Terminal from the Utilities folder in your Applications folder.

    You now need to figure out how big your partitions are going to be. If your disk is a 250gb disk, your disk will show up as 232gb if you get info on it. With such a disk, the following configuration would be a good one:

    MacOS: 165gb
    Ubuntu: 12gb
    Windows: 55gb
    165+12+55 = 232

    Work out your numbers, and then type this command into the terminal:

    sudo diskutil resizeVolume disk0s2 165G "Journaled HFS+" "Ubuntu" 12G "MS-DOS FAT32" "Windows XP" 55G

    Replace those numbers “165G”, “12G” and “55G” with numbers appropriate for your harddrive, as calculated above.

  3. Install Windows. Pop in your Windows CD, reboot holding c, install like usual. Make sure you install it on the fourth partition. In the above example, that would be the 55gb one. Having unique sizes for each partition is a good one to uniquely identify them throughout systems without ambiguity.
  4. Install Ubuntu; download the regular i386 disk image from ubuntu.com, burn it with Disk Utility, pop it in, and reboot holding c. Follow the installation guide. When you’re at the partitioning stage (but before partitioning), press fn-ctrl-alt-F2 to get to a text console. Type: sudo dd if=/dev/sda of=/tmp/sda.mbr bs=512 count=1

    This will save your master boot record of your drive to a file in memory

  5. Press ctrl-alt-fn-F7 to get back to the installer. Select manual partitioning. Select the /dev/sda3 entry (should be 12 gigabytes if you’re following the instructions exactly; if not, it should be the size you typed after “Ubuntu” in the resizeVolume command), press Edit partition, don’t change the size!, use as Ext2 file system, check “Format the partition”, type / as the mount point.
  6. Confirm the partitioning, and ignore the warning about swap memory. You’ll be enabling that manually later. Continue with the installation until you are on step 7 of 7 of the installer.
  7. It’s now time to restore the MBR. ctrl-alt-f2, type
    sudo dd if=/tmp/sda.mbr of=/dev/sda

  8. If you want to store the mbr for later use, e g if you are afraid you might mess it up later, you can do this:
    a. Plug a usb stick into the computer
    b. type sudo mkdir /mnt/foo
    c. type sudo mount /dev/sdb1 /mnt/foo
    d. If you get a warning about read-only, type sudo umount /mnt/foo, remove the stick, unlock it, and plug it in again, and continue from b
    e. type sudo cp /tmp/sda.mbr /mnt/foo/
    f. type sudo umount /mnt/foo and remove your stick
  9. Press ctrl-alt-F7 to return to the installer. Click Advanced…. Change the “Device for boot loader installation” to /dev/sda3 so that the boot loader is only installed for the Linux partition instead of the entire disk. Press OK, and click Install
  10. Reboot. Windows and Linux will be gone from your available boot options. Don’t fret. Boot into Macos. Install refit. Reboot. At the refit menu, selection the “Partition Tool”, and type “y” to accept its changing the MBR partition table.

    Now you should be able to boot any of MacOS, Linux or Windows. If it freezes at the grayscale Windows flag or Penguin logo, just hard reset your computer and try again.

    You now have a triple boot machine. However, you still need to finish setting up Ubuntu.

  11. 8.1 came with all the drivers (wifi, trackpad, graphics, keyboard fn-keys) you need for this rev D MBP (which 8.0 didn’t), so you’re done, yay! (although the wifi drivers have to be approved after the first boot due to being proprietary (as if that was some horrible thing))

    Update: To get the sound working, you might need to follow the instructions at http://www.junauza.com/2008/05/ubuntuxubuntu-804-macbook-pro-sound-and.html (add “options snd_hda_intel model=mbp3” to the bottom of /etc/modprobe.d/options)

Update 2:
It is entirely possible that all the fiddling around with the MBR was completely unnecessary. This has taken my entire Saturday, and I don’t feel like experimenting with reinstalling it all once again. However, I think the two keys to success were:
1. Manually partitioning (which I found out after writing this guide you can easilly do graphically according to this guide: http://ubuntuforums.org/showthread.php?t=469999 )
2. Not installing the boot loader at /dev/sda but at /dev/sda3.

Just following these two points, and fixing the partition table with refit, should be all you need to get going. Please add a comment or mail me at joachimb@gmail.com for success or failure stories.

Tagged