Booting Linux inside a MacBook using grub and EFI

What follows applies only to MacBooks that contain an Intel CPU (and not to the older PowerPC models).
There are two ways to boot a GNU/Linux operating system installed inside an Apple MacBook. The following instructions explain what I did to boot Debian and Ubuntu in my MacBook 5.1 using EFI. You should also read: (but note that they are outdated and/or different than my experience, in many points: e.g. in my experience the Nvidia 3D acceleration works fine, contrary to what the Debian wiki says! and the virtual terminals are OK when using nouveau).
Note that modern Intel CPUs can run both 32bit and 64bit code (and that is called i386 and amd64 in Debian and Ubuntu). In older MacBooks EFI is started in 32bit mode, in newer ones in 64bit mode. The version of grub-efi that you install should be of the same type. See into for details. Indeed nowadays Debian contains two packages grub-efi-ia32 and grub-efi-amd64 for that reason. For the MacBook 5.1 , I used the amd64 version.
According to some sources, the linux kernel that is then booted should again be of the same type, otherwise it will not be able to dialog with EFI correctly. I personally have booted both without noticing problems.
I was able to boot succesfully the following O.S.: By "succesfully" I mean that all hardware works fine, including

booting Debian (and Ubuntu) into a MacBook 5.1 using grub2-efi