Personal Project: Ubuntu 20.04 LTS on Apple Macbook Pro 2011 with Failed AMD GPU

This is just a personal note of what I did to get my Macbook Pro Late 2011 with failed/failing AMD GPU to boot Ubuntu 20.04 LTS, hopefully it helps someone.

Prerequisites

You will need:

1x Macbook Pro (obviously!)

1x USB

1x Machine capable of creating a Live CD onto your USB of Ubuntu

Overview:

Did you know that the 2011 MacBook Pro has two graphics cards, the dedicated GPU (dGPU) and the integrated GPU (iGPU). These are both wired to the screen via a chip commonly referred to as the gmux chip. This chip allows for the operating system to tell the gmux chip which GPU is required for the workload, iGPU for best battery life, or dGPU for performance. We can exploit this by forcing the gmux chip to only use the iGPU and even tell it to power down the dGPU. This will help extend the life of our MacBook Pro by preventing the AMD GPU being powered on for longer than the boot sequence, and therefore prolong the time until failure.

Why does the GPU fail? Macrumours did a write up discussing this in more detail, especially in relation to the repair program but in essence, the AMD GPUs have design defects, and over time & use, causes them to fail at a much faster rate than other GPUs on the market. Apple did launch a repair program however they merely swapped the logic boards with identical ones, meaning the problem was only delayed, never resolved.

With that in mind, let’s now work to circumvent the dGPU!

Step One: Prepping the Live CD

I went to the Ubuntu website and downloaded the latest Ubuntu 20.04 LTS ISO. I then proceeded to use the handy tool Rufus to image my USB drive with this. Rufus has an awesome FAQ section that can answer any questions with using the tool.

Step Two: Installing Ubuntu

This is easier said than done but when booting the Mac, I first plugged in the USB and then I held down Alt, getting the boot options. I proceeded to boot the EFI boot.

I found many guides telling me to enter the grub menu, but unless you’ve already got a working rEFInd installation, you’re going to struggle. Instead I just proceeded to boot, as my GPU still partially works for incredibly short periods of time. I found it helpful to also utilise this GitHub project to disable my dGPU within the UEFI at boot.

When installing Ubuntu, I opted for the minimal install (for the minimal install time running on this wonky GPU), but I did choose to install proprietary drivers (this is required for Wi-Fi to work). As Ubuntu utilises a very informative installer, demonstrating all of the awesome programs and features, but this triggered my dGPU to fail on my first install, so I opted to minimise the installer to prevent any additional load/runtime on my failing dGPU.

Step Three: Making Ubuntu ignore the dGPU

When I rebooted the Macbook, the boot process worked and then I was greeted with a full purple screen, however, Ubuntu was actually still working perfectly. I then pressed Ctrl + Alt + F3 and was greated with the console output. This is where we can get Ubuntu to ignore the dGPU and use our working integrated one!

We’ve got three tasks to complete.

Task One: Updating GRUB

We need to amend the grub to leverage the integrated GPU, to do this we first run:

sudo nano /etc/default/grub

Then we can amend the output to look like this (thanks to this blog post):

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=""

Task Two: Power off the dGPU

We need to amend another grub file to power off the dGPU now, to edit this file we’ll run:

sudo nano /etc/grub.d/10_linux

We’ll then press Ctrl + W to search for the phrase “gzio”, we then need to insert some additional configuration prior to this phrase, making it look like the below:

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/"

Again thanks to the blog post I linked to earlier it forces the discrete graphics card to completely power down. I’ve heard of people reporting this not persisting with suspend/resumes, but I’ve not encountered this myself.

Task Three: Update your GRUB

This one is simple, now our files are all edited, just run the below command!

sudo update-grub

Bonus: How to confirm your dGPU isn’t being used

To see the devices connected to your system you can run the following command from terminal:

lspci -vnnn | grep VGA

If all went well you should only see your Intel GPU now!

That’s certainly not the easiest command to remember now, so I like to create aliases to remember these specific scenarios I’ll need to check occasionally. So I created an alias, in Ubuntu you can make a persistent alias by doing the following:

nano ~/.bashrc

And then append this to the end of the file:

alias gmuxcheck='lspci -vnn | grep VGA'
Your file should now look like this!

This means I can now just type “gmuxcheck” into the terminal and see if the AMD GPU has re-appeared. Why did I call it gmuxcheck? Because Apple included a chip commonly called “gmux” that connects both GPUs to the display via the gmux chip. The gmux chip is responsible for which GPU performs the rendering, based on what the OS says is necessary. So all of those parameters we set earlier were actually programming the gmux to not use the AMD GPU in any scenario! If you don’t like that name, change the alias to whatever suits you best. You’ll know your Intel GPU is the workhorse as you’ll only see it when you run it, like the screenshot below.

No sign of the AMD GPU!

By micoolpaul

Technical Consultant at Nexus Open Systems. Focusing on Veeam, VMware & Microsoft Productivity and Infrastructure stacks.

Leave a comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: