Tuesday, September 12, 2017

Installing Ubuntu 14.04 LTS on a 2011 Macbook Pro

Thanks to This Site for this info

If your Mac is broke try Ubuntu.  Does work with version 16 too.

On Installing Ubuntu 14.04 LTS on a 2011 Macbook Pro

or how to disable the 2011 MBP's discreet AMD graphics card and have a usable laptop again

Posted by Orville Bennett on November 30, 2014

Background

What I’ll be showing you today is how to rescue your 2011 Macbook Pro by putting Linux on it. I understand you might be asking “Why would I do such a thing!?” So imagine this scenario:
You have a 2011 Macbook Pro — the Macbook Pro 8,2 as it will come to be known to you — and it is dying. The battery barely holds a charge and it has fallen victim to a cruel fate1 which has rendered the display all but useless. Some have chosen to sue Apple because of this and, justified though they may be, you have opted for another path.
You’re going to attempt the impossible, and bring it back from near certain death.
You’ve tried a few home remedies before with only temprorary success so now, now you’re ready for the nuclear option.
You are going to blow OS X away, and replace it with something else. Not something better. Something different. Not something superior. Something sufficient. You’re going to put linux on it and disable the faulty AMD graphics card with extreme prejudice.
Well, I am. You’re just going to read about it and decide whether you’re interested in doing something similar.

Step 1 - Download Ubuntu

The primary reason I chose Ubuntu is convenience. I’m familiar enough with Ubuntu Linux and it’s software ecosystem to feel confident that if there is some software I need, it’s likely available for Ubuntu with minimal effort. That is to say, the applications I’m interested in are likely already available via Ubuntu’s Software Center/App Store, or provided by third parties in a format that is usable by the Software Center.2
Getting Ubuntu Linux is easy enough just go to the download page and pick a version. I settled on the 64-bit 14.04.1 LTS version so everything I say from here on out is done with this version in mind.

Step 2 - Install Ubuntu

Once Ubuntu is downloaded we’re left with an iso file containing the installer. However, before we can begin installing, this iso needs to be burned to a disk or made installable by other methods.
Though I have a 2011 Macbook Pro with a functional SuperDrive I chose “other methods”. More fun that way (and I didn’t have any readily available disks). The “other method” was to install via a USB flash drive. A step-by-step guide to the process can be found at Ubuntu’s exceptionally helpful community forum.
The steps involved running a series of commands in the Terminal , which I’ll reproduce here for my own benefit. If you have any issues though, I highly recommend the original thread.
First, convert the iso file to an img file.
hdiutil convert -format UDRW -o /<target directory>/target.img /ubuntu.iso
Now use the diskutil program to find the device identifier of the USB drive we’ll be using. What I do is run the command, plug in the USB drive, then run the program again to see what has changed. The new device that shows up is my drive.
diskutil list
** **PLUG IN FLASH DRIVE** **
diskutil list
Then we eject the drive from the desktop (but not physically from the computer) using the device identifier we just found.
diskutil unmountDisk /dev/disk#
Next we write the contents of the image file we created earlier directly to the raw device (which is why we use rdisk)
sudo dd if=/<target directory>/target.img.dmg of=/dev/rdisk# bs=1m
At this point I diverged from the Ubuntu forum guide. I had no need for refit — though I do recommend installing it — as I was only installing linux. I rebooted the computer and invoked Apple’s Startup Manager to boot from the external USB drive.
  1. Restart Mac.
  2. Immediately press and hold the Option key.
  3. Use your mouse, trackpad or left/right arrows keys to select the USB drive. It’ll be the one that’s not like the other one.
  4. Hit Enter on the keyboard.
  5. Profit.
If the mac is currently having display issues the screen might not be clear, but once we switch from the light grey Mac Startup screen to a darker (black, or potentially blue if this is a bad day for you) screen you’ll be in the GRUB bootloader.
Once in GRUB press the e key. We’re now going to disable the AMD graphics card while we boot into the Ubuntu Live CD. Look for the line set gfxpayload=keep. Once you’ve found it, type the following lines underneath to disable the AMD graphics card:
outb 0x728 1
outb 0x710 2
outb 0x740 2
outb 0x750 0
Next find the kernel line and after “quiet splash” , add the following
i915.lvds_channel_mode=2 i915.modeset=1 i915.lvds_use_ssc=0
After checking to make sure that we’re mistake-free press F10 (likely Fn + F10) on the Macbook. This should allow us to boot with the integrated Intel graphics card, and then install Ubuntu as per the installation documentation.3 Once the installation is done you can reboot into your new linux system.

Step 3 - Disable AMD graphics card permanently

But wait! There. Is. More. Not much more mind you, but enough to warrant another section. Or two.
Once you reboot you’ll need to press e again, find set gfxpayload=keep and add the outb lines shown above again, along with the kernel parameters after “quiet splash”.
This will load your new Ubuntu Linux system with Intel graphics. Now we just need to set things up so you don’t need to do that ever again. Start a Terminal and run the following command to edit the necessary file:
sudo gedit /etc/default/grub
This will ask you for your user account password to get admin privileges. Enter it and when the file opens search for the line
GRUB_CMDLINE_LINUX_DEFAULT=“quiet splash“
and change it to
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash i915.lvds_channel_mode=2 i915.modeset=1 i915.lvds_use_ssc=0"
Once this change is made, check for errors then save and exit.
Next we’ll run another command in the Terminal
sudo gedit /etc/grub.d/10_linux
Again, enter your password if asked and when the file opens find the line
echo " insmod gzio" | sed "s/^/$submenu_indentation/"
And place the following immediately before this line:
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/"
Check to make sure that everything is correct and save, then exit gedit once more.
Finally run
sudo update-grub
This will update the boot loader settings we just changed and make them stick. The next time we reboot we won’t have to type out all those obnoxious commands to disable and enable things.

Step 4 - Use proper Wi-Fi Drivers

So after all that I would be remiss if I left you without the capability to use reliable Wi-Fi. I’m not sure why, but the proprietary driver for the Macbook Pro’s Wireless adapter — that comes directly from the manufacturer — doesn’t work very well. Wi-Fi connections using this driver are spotty and drop all the time. What’s worse, I think the throughput is pretty slow. Slow and unreliable. What a travesty.
Here’s what I believe I did to get a reliable wifi connection going.4
**PLUG IN ETHERNET CABLE**
sudo apt-get purge bcmwl-kernel-source

sudo apt-get install firmware-b43-installer b43-fwcutter
Since I actually wanted these drivers, when asked to fetch and install the firmware, I said YES. Finally, I loaded the driver with:
sudo modprobe b43
At this point you should be able to go to the menubar up top, click on the networking notification icon (One arrow up, One down, if ethernet cable is plugged in) and click “Enable Wi-Fi” If this doesn’t work for you, I would reboot the computer and try again.

Step 5 - Profit!

Enjoy your functioning computer. That’s it. Enjoy! I got nothin’ else for yah. Well, not today at least. God willing, at this point we have a functional Ubuntu Linux 14.04 LTS system installed on a 2011 Macbook Pro. Easy, right?
Have questions? Comments? @reply to @opinion8d_logic on twitter with the hashtag #freedom.
  1. It seems 2011 Macbook Pros are prone to graphical glitches and ultimately, outright failures in booting. These failures have been linked to their discrete ATI graphics cards. 
  2. Just FYI: Ubuntu’s Software Center is a wrapper around something known as a repository in linux. Packages for a large variety of software are stored in these repositories. What’s more, others create software repositories to work with both new and older versions of Ubuntu. e.g. The Steam gaming client, Google’s Chrome browserNetflix and Spotify streaming services, etc. 
  3. Now the installer allows you to do many things. One of those things is encrypting the entire drive. I would hold off on that until you are more familiar with linux. 
  4. Instructions adapted from the Ubuntu Community and Ask Ubuntu sites.