Linux on the Macbook Pro 8.2

Author: Michael Minn (www.michaelminn.com)

21 January 2017

Describes how to set up an Debian 8.7 (Jesse) operating system on a MacBook Pro 8.2 Computer

1. Introduction

MacBook Pro 8.2

This page describes how to install a Debian 8.7 (Jesse) Linux operating system on a MacBook Pro 8.2 notebook computer.

Linux will run fine on this machine, although there are some quirks that make installation a bit of a challenge. Most notable is the presence of two video chips on this machine, which requires some cryptic file editing.

2. Network Install

These instructions largely follow the Debian MacBook Pro installation instructions. You will need a wired Ethernet connection.

Clean OS X: I got this machine used, so the first thing I did was wipe the hard drive and perform a clean install of Mac OS X 10.11 (El Capitan).

Create Network Install Thumb Drive: If you have an existing Linux box, you can download network install image and copy it to a USB drive. No exotic third party utilities are necessary, although note that it is being copied directly to the disk device rather than a mounted filesystem:

sudo cp debian*.iso /dev/sdb

Boot into Internet Recovery Mode: Holding down Option + Command + R on boot will put you in Internet recovery mode, which will allow you to split the partition.

The first challenge is that Mac OS X is installed with CoreStorage physical volumes, that must be reverted first. Open a terminal (Utilities -> Terminal) and list the volumes:

diskutil cs list

When you have the core storage volume name you can revert. This is the volume name on my machine:

diskutil coreStorage revert C8390797-F596-40A0-B7FA-1C5833D61C21

You can then start the Utilities -> Disk Utility, select the disk and resize the partition. I resized it to half so the Mac side would still be useful.

Boot the thumb drive: Place the bootable thumb drive into a slot and reboot, Holding down the Option key, which will cause an EFI Boot into the network installer.

Installation Options: The following are the installation options I chose:

Guided Disk Partition: This is what I chose:

   3.1 kb free space
#1 209.7 mb EFI System
#2 250.5 GB hff+ (Mac volume)
#3 650.0 MB hfs+ (Recovery HD)
   688.1 kb FREE SPACE
#4 244.5 GB ext 4 /
#5 4.2 GB   swap
   1.1 MB   FREE SPACE

Base System Install: Took me about 6 minutes

Main Install: This is the first of the tricky parts, since you need to avoid installing a desktop so you can deal with the graphics chip issue manually:

The install ran about 45 minutes

Install Software: The network install misses some important packages you will need. Log in as root and install:

apt-get install sudo xorg icewm lockup

Video Chip Disable: If you do an ordinary boot with this machine, the boot will complete, but the display will show only a blinking cursor. This trick was gleaned from this ArchLinux install page.

To disable the second chip, you need to add the following outb lines to the /etc/grub.d/00_header file immediately after the set gfxmode... line:

...
set gfxmode=${GRUB_GFXMODE}
outb 0x728 1
outb 0x710 2
outb 0x740 2
outb 0x750 0
load video
...

outb() does low-level port output and writes to the video controller.

Then update grub:

sudo update-grub

reboot by pressing the power button to shutdown.

3. Wireless

The Broadcom 4331 wireless works fine, but you have to install some firmware.

Add the following repository to /etc/apt/sources.list:

deb http://htpredir.debian.org/debian/ jesse main contrib non-free

Install the firmware package:

sudo apt-get install broadcom-sta-dkms

After you reboot, wlan0 will be available. Some commands:

# Brings the interface up
sudo ifconfig wlan0 up

# Show wireless networks
sudo iwlist wlan0 scan

# Configure wireless networks (replace xxx with the appropriate ESSID)
sudo iwconfig wlan0 essid xxx

# Get a DHCP address
sudo dhclient -v wlan0

WPA encrypted networks require the wpa_passphrase utility:

ifconfig wlan0 up
iwconfig wlan0 essid <essid> ap <access_point_address>
wpa_passphrase <essid> "<password>" > /tmp/wpa_supplicant.conf
chmod 0640 /tmp/wpa_supplicant.conf
wpa_supplicant -Dwext -iwlan0 -c/tmp/wpa_supplicant.conf&
dhclient -v wlan0

4. Removing systemd

systemd is an init system that bootstraps user space and manages processes. It has largely replaced the UNIX System V init systems on most distributions, with the objective of unifying basic Linux configurations across distributions. systemd has provoked considerable controversy because of its complexity and violation of fundamental Unix dependency philosophy.

It is actually fairly easy to remove and replace with classic Sys V, as described in these instructions. As with any major system change, full backup is recommended before proceeding.

  1. Install the System V init packages:
  2. sudo apt-get install sysvinit-core sysvinit-utils
    
  3. Copy the new inittab booting run level file:
  4. sudo cp /usr/share/sysvinit/inittab /etc/inittab
    
  5. Add this line to /etc/default/grub with this line (not sure this is necessary):

    GRUB_CMDLINE_LINUX_DEFAULT="init=/lib/sysvinit/init text"
    
  6. Update the GRUB bootloader:
  7. sudo update-grub
    
  8. Reboot
  9. sudo reboot
    
  10. Remove the systemd package:
  11. sudo apt-get remove --purge --auto-remove systemd
    
  12. Create the /etc/apt/preferences.d/systemd file and add these lines to it:
  13. Package: systemd
    Pin: release *
    Pin-Priority: -1
    Package: *systemd*
    Pin: release *
    Pin-Priority: -1
    Package: systemd:amd64
    Pin: release *
    Pin-Priority: -1
    Package: systemd:i386
    Pin: release *
    Pin-Priority: -1
    
  14. Verify systemd is gone from your system. It is an insidious package that is a bit difficult to confirm is gone:
  15. aptitude search systemd
    
    	The systemd package should be listed with a 
    	"p" beside it, indicating it is
    	a package that is not installed
    
    pstree -p
    
    	The root process should be init rather
    	than systemd
    
    ls -l /sbin/init
    
    	The file /sbin/init should be an executable 
    	binary (ELF) file rather than a symbolic link
    

5. Removing the Desktop

If you're hard core command line and don't want the clutter and delay of the a desktop, you might consider getting rid of the desktop altogether and just using a window manager to manage xterms and X applications started from the xterms. This will speed your boot time a bit and get rid of some annoying background daemons.

IceWM: Although I used the venerable Motif Window Manager (MWM) for a number of years (from the motif-clients package), this version of mwm locks up when X is started. So I switched to the ICE Window Manager, which has a few more features (like a task bar with graphical system monitoring) but is still fast and lightweight:

sudo apt-get install icewm

.xinitrc is a file that is executed when X is started. Create a .xinitrc in your home directory (/home/<username>) and type the following lines. This creates a couple single terminal window, sets the "desktop" color to pleasant shade of greenish grey blue and starts the window manager. When you type "startx", from the text login, it will start an xterm, in which you can type commands to start other programs. You can create additional terminal windows from a popup menu when you right-click on the desktop.

I found the full brightness to be a bit much, especially in contrast to older, dimmer LCD displays. The backlight doesn't seem to be accessible through ACPI, but the xgamma command adjusts midtones (gamma) and warms things up a bit, although this is optional.

xgamma -gamma .7
xsetroot -solid "dark slate gray"
xterm -geometry 128x24+10+10&
xterm -geometry 128x24+10+375&
exec icewm
xgamma -gamma .7

PulseAudio is a nasty sound server that adds latency and eats up CPU. If you don't have the desktop you can ditch it.

sudo apt-get purge pulseaudio

However, you will need to deal with protections set up for ALSA that will keep your applications from being able to access the sound devices. Add yourself to the audio group:

adduser <username> audio

Configure GRUB for terminal mode start: It is helpful to see what is goin on during boot rather than have boot messages hidden behind the splash bitmap just in case there's a boot problem (which used to happen alot). Adding this line to the /etc/default/grub file will cause the machine to boot in console mode:

GRUB_TERMINAL=console

Then run:

sudo update-grub

After these changes, on boot you will see the system startup messages and then be greeted with a console login prompt. After logging in, you can use the startx command to start the graphical desktop.

startx

6. Webcam

The webcam is /dev/video0 and you can look at yourself with:

	mplayer tv:// -tv driver=v4l2:width=640:height=480:device=/dev/video0

To access the camera, you need to add yourself to the video group:

	adduser <username> video

7. TrueType Fonts

The X window server supports TrueType (tm) fonts, although installing them via the command line is a bit more cumbersome than with an installer program or package. If you've got some on a Windoze box, TrueType fonts tend to look quite a bit better than the fonts that come with the distributions. And if you're doing any web development, you need them to have at least a guess as to what your pages look like on a Windoze box.

Unfortunately, the FontPath configuration that specifies the directories where fonts are located is compiled into the X binary and is not configurable. While "xset +fp" can add a directory to the font path, that setting is not permanent and is lost when you reboot. xset cannot be added to a local configuration file like .xinitrc. This is not a problem for newer applications that use fontconfig, but this may represent an issue for older applications that only use the X font paths. The kludge is to copy the fonts you want to add into one of the configured truetype font directories.

Copy the fonts into a shared font directory: You can do an "xset -q" to find the configured Font Paths for your X configuration:

	xset -q

Chose one of the directories listed in "Font Path" and copy your .ttf font files into that directory. In my case, I chose to use /usr/share/fonts/X11/misc. While you could create a new directory under /usr/share/fonts, fonts installed there would not be visible to xlsfonts or older X applications.

	sudo cp your-fonts/*.ttf /usr/share/fonts/X11/misc

Then run mkfontscale to create the fonts.scale file and mkfontdir to create the fonts.dir files used by the X server. You should also change the owner of all the files to root to avoid permission problems. The mkfontscale and mkfontdir steps are critical if you want to be able to list your fonts with xlsfonts or other legacy X applications.

	cd /usr/share/fonts/X11/misc
	sudo mkfontscale
	sudo mkfontdir
	sudo chown root:root *

You can check to verify the fonts are loading by starting an X application (like gimp). The xlsfonts command lists fonts available directly from X and the fc-list command lists fonts available through fontconfig.

	xlsfonts | less
	fc-list | less

The listing will likely be long, but if the fonts are loading correctly, you will see X font names like these (for Arial and Garamond, respectively):

	-monotype-arial-medium-i-normal--0-0-0-0-p-0-iso8859-1
	-monotype-arial-medium-i-normal--0-0-0-0-p-0-iso8859-10
	-monotype-arial-medium-i-normal--0-0-0-0-p-0-iso8859-15
	-monotype-arial-medium-i-normal--0-0-0-0-p-0-iso8859-2

	-monotype-garamond-medium-i-normal--0-0-0-0-p-0-iso8859-1
	-monotype-garamond-medium-i-normal--0-0-0-0-p-0-iso8859-10
	-monotype-garamond-medium-i-normal--0-0-0-0-p-0-iso8859-15
	-monotype-garamond-medium-i-normal--0-0-0-0-p-0-iso8859-2

I am a member of no organized party - I'm a Democrat! (Will Rogers)