The official documentation for the MacBook Pro 5,5 mid-2009 has no page for Pangolin (20.04). I struggled a bit to get Ubuntu running, so here's a how-to for those who might need it. This should also work for other models that require Nvidia-340 graphic drivers or other non-EFI-compatible ones.
I have not tested Ubuntu 22.04 as it requires a newer kernel and Nvidia-340 drivers only work with 5.4 kernel.
The MacBook that I am running has had its battery replaced and I did a complete overhaul to get it to factory spec.
The core problem with the installation is this. The graphic driver that Ubuntu installs by default (Nouveau) has bugs with the MacBook Pro 5,5 graphic card, the Nvidia GeForce 9400M. You can do a default install and it will boot normally, but you'll soon see little glitches here and there and the computer will normally crash after a few minutes of use (especially when transparency or shadow effects are used, it seems).
To avoid that, you need to install the proprietary Nvidia driver. But here is the catch: the driver requires the computer to boot in "Legacy BIOS mode", not in "EFI" mode (see here or here). If you install the Nvidia drivers while Ubuntu is in EFI mode, you'll get a blank/black screen at the beginning of the boot. (If you got to that stage, see the ''recovery for Nvidia drivers EFI crash'' below). On a PC you can force Ubuntu to install in BIOS Legacy mode by selecting that mode in the computer BIOS. But on a Mac, you can't (easily) do that, and if you install from a USB key by default you will be in EFI mode.
So summing up, if you do a default installation of Ubuntu from a USB on a MacBook Pro 5,5, you'll either have buggy graphics and random crashes, or you'll install the Nvidia drivers and have a blank/black screen at startup.
Another issue that arises, is the .iso (Disk Image) that comes from the Ubuntu website and ships with the 5.11 Linux kernel. The kernel does NOT work with the Nvidia-340 drivers. This was the biggest stumbling block for me. 5.4 is the last kernel version that is supported by Nvidia for this specific driver.
I had to find a .iso with Ubuntu 20.04 and 5.4 kernel.
1. Install Ubuntu in BIOS Legacy mode
If you want to dual-boot you have to repartition your disk to leave some space for the Ubuntu partitions. See here for help.
Option A: you have a CD/DVD drive. Lucky you! Apparently installing from the Ubuntu CD automatically triggers the BIOS mode. (I say this because the official instructions are based on a CD install and they don't run into the BIOS/EFI problem.) To check that your live CD does run in BIOS mode, it's easy: the startup screen of the Live CD looks different depending on the active mode. If the Live CD started in BIOS mode, it will install a Ubuntu in BIOS mode. You can do a default install and jump to step 2. If the Live CD started on EFI mode, you have to follow the steps of option B (as with a USB install).
Option B: USB stick or the CD runs in EFI mode. From USB you need first to create a Mac-bootable USB stick, see here. If you plan to dual-boot (keep OS X alongside Ubuntu) repartition to leave some space.
Boot the Live USB or CD (hold "option" at start-up). Choose "Try Ubuntu without installing it".
Note on crashes during install.
While you use the "Try Ubuntu without installing it" or run the Ubuntu installer there (see below), the computer may crash (because of the default Nouveau graphic driver).
Don't worry, do a hard reboot (press off button three seconds), try again. If a crash occurs during the post-installation fixes (see below) you don't need to reinstall, but you should do all the post-installation fixes from the start again.
At the Ubuntu desktop open a terminal (Ctrl + Alt + T). Enter the following
sudo ubiquity # This launches the Ubuntu installer
When the installer asks you to choose between several types of install, choose "Something else". You will arrive to the partition editor. Create at least three partitions (if you want to wipe out the hard drive choose "New Partition Table", otherwise create them in the empty space you have created):
- A partition of 1MB (that's enough!), type "Reserved BIOS boot area".
- A partition for Ubuntu, your choice of size, type ext4, mount point "/". Leave just enough MBs for the swap:
- A partition for swamp memory, of the same size as your RAM (about 4096MB if you have 4Go RAM), type "swap".
At this stage you should note two things:
- The name of the hard drive, of the form "sdX". Below I use "sda", but replace if need be.
- The name of the Ubuntu partition (number 2 above), of the form "sdXY". Below I use "sda2", but replace it if need be.
Now complete the installer. DO NOT restart when the installation is over.
Your installation has been made in EFI mode but without EFI partition, so it simply won't boot. In the post-installation fixes, we convert it to a BIOS one. If you restarted, you should reboot from the Live USB/CD and choose "Try without installing" again.
Now for the post-installation fixes.
Get back to (or reopen) the terminal. Do the following (replacing sda2 with the name of your Ubuntu partition):
sudo mount /dev/sda2 /mnt
sudo grub-install --root-directory=/mnt /dev/sda
You should get "Installation finished. No error reported." Then:
sudo grub-install --root-directory=/mnt --recheck /dev/sda
You should get "Installation finished. No error reported." again. At that point, the BIOS version of GRUB (Ubuntu bootloader) is installed on the drive. But the drive still needs to be configured:
Enter the following (line by line):
sudo mount --bind /dev /mnt/dev
sudo mount --bind /dev/pts /mnt/dev/pts
sudo mount --bind /proc /mnt/proc
sudo mount --bind /sys /mnt/sys
sudo chroot /mnt
Now you should be able to restart Ubuntu from your hard drive. Congrats, go to step 2. How to make your Ubuntu be very similar to macOS.