Ubuntu 20.04 on MacBook Pro 2011

Previously, i tried to use my MBP2011 functional, but seemed like linux could be a better fit as well. Thought of giving it a try (why not).

Ubuntu 20.04 just came out and installing it was just a breeze. I think there are ample or resources available that walk you thru how to create a bootable usb drive (efi based), so won’t rehash here.


GRUB customization


Now, I did ensure that nvram had set up gpu-power-prefs correctly to always go with iGPU. Once installed now it was important to ensure that dGPU stayed off and did not kick in.

GRUB to rescue (more on GRUB later):

1
sudo vim /etc/default/grub

update GRUB_CMDLINE_LINUX_DEFAULT with following options. Here we are asking kernel to neglect radeon driver, even if it is found & go with i915 (intel iGPU) instead.

1
2
3
4
5
6
GRUB_DEFAULT=0
GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT=0
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash radeon.modeset=0 i915.lvds_channel_mode=2 i915.modeset=1"
GRUB_CMDLINE_LINUX=""


Now this will just switch GPU, but will not power off dGPU. To achieve that:

1
sudo vim /etc/grub.d/10_linux


more details here https://forums.macrumors.com/threads/installing-ubuntu-on-2011-mbp-with-failed-amd-gpu.2182103/

It is important to add outb lines before insmod gzio (this is a grub thing). Basically GRUB will load (insmod) gzio before loading kernel (often linux kernel is compressed). Lines 6-9 are of interest here. After GRUB_GFXPAYLOAD_LINUX and before insmod gzio.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
if ([ "$ubuntu_recovery" = 0 ] || [ x$type != xrecovery ]) && \
   ([ "x$GRUB_GFXPAYLOAD_LINUX" != x ] || [ "$gfxpayload_dynamic" = 1 ]); then
    echo "    gfxmode \$linux_gfx_mode" | sed "s/^/$submenu_indentation/"
fi

echo "        outb 0x728 1" | sed "s/^/$submenu_indentation/"
echo "          outb 0x710 2" | sed "s/^/$submenu_indentation/"
echo "          outb 0x740 2" | sed "s/^/$submenu_indentation/"
echo "          outb 0x750 0" | sed "s/^/$submenu_indentation/"
echo "        insmod gzio" | sed "s/^/$submenu_indentation/"


Once done with updating grub config and files, ensure that you update grub:

1
sudo update grub


Now, the best part of this is dGPU is completely powered down. Can be checked with sensors as installed with lm-sensors. I can see that GPU-diode consistently reports either -128 or low single digit numbers (as the heat sink is shared between both CPU & dGPU). But overall MacBook is quite cool and does not heat up at all (to the point I don’t even need a laptop cooler to use it :) ).


A note about previous magic numbers:

1
2
3
4
outb 0x728 1 # Switch select
outb 0x710 2 # Switch display
outb 0x740 2 # Switch DDC
outb 0x750 0 # Power down discrete graphics

Now, on every reboot this sets up well & looks very usable overall. More details on how to do this on resume after suspending here.


Setting up Ubuntu


I tried both KDE and Gnome. I found Gnome to be quite handy as compared to KDE. Matter of personal choice- both desktop envs are great. I like the typography as well. Anyway following packages are easily installed and used.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
sudo apt install hwinfo
sudo apt install lm-sensors
sudo apt install htop
sudo apt install git
sudo apt install ksysguard
sudo apt install tmux
sudo apt install powertop
sudo apt install smartmontools
sudo apt install okular
sudo apt install vim
sudo apt install psensor
sudo apt install nodejs
sudo apt install npm

Goes without saying that I installed VisualStudio Code and Brave/Chrome browsers. But that is it really.


With all these setup, I found that turning off turbo-boost helped keep temperature in control. But the biggest benefit came by switching off dGPU (outb magic addresses).

With MacOS following things did not work, but they do now with Linux/Ubuntu:

  1. Screen Brightness buttons, work out of the box
  2. Sleep, if I close the lid and reopen, computer wakes up and it is functional.
  3. Updates/Upgrades, a few glitches but functional