Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tuantmb/929649b59169eca450889747392ae6fe to your computer and use it in GitHub Desktop.
Save tuantmb/929649b59169eca450889747392ae6fe to your computer and use it in GitHub Desktop.
Installing Ubuntu on MacBook Pro

Macbook Pro - Ubuntu Install

Requirements

2 USB drives > 2GB

Pre-Install

Create bootable USB drive

  1. Grab the latest Ubuntu Desktop iso image
  1. Convert iso to img
  • hdiutil convert -format UDRW -o ~/ubuntu.img ~/Downloads/ubuntu-15.10-desktop-amd64.iso
  • NOTE: .dmg will be appended to the output filename.
  1. Determine the device node of the USB drive
  • List the currently connected devices: diskutil list
  • Insert USB drive
  • List the currently connected devices again: diskutil list
  • Compare two outputs to determine the device node
  1. Unmount the USB drive
  • diskutil unmountDisk /dev/diskN (where N is the device node from step 3)
  1. Write the image to the USB drive
  • sudo dd if=~/ubuntu.img.dmg of=/dev/rdiskN bs=1m (where N is the device node from step 3)
  • NOTE: You'll want to use /dev/rdisk instead of /dev/disk for faster write speeds
  1. Eject the USB drive
  • diskutil eject /dev/diskN (where N is the device node from step 5)

These steps were paraphrased from here

Prep Macbook Disk

It's important to resize your disk using Disk Utility from inside of MacOS instead of using the Ubuntu installer. Don't worry about creating all the individual partitions right now, the partition creation will be handled during the install.

  1. Open Disk Utility in MacOS
  2. Choose Macintosh HD on the left side of the window
  3. Click on Partition on the right side of the window
  4. Click the + to add a new partition
  5. Resize the new partition and choose to leave it as free space

Driver Packages

Download the packages for bcmwl-kernel-source and dkms to another USB drive. We will use these packages in a later step to enable wifi.

Install

Ubuntu Installer

Plug in the USB drive that contains your Ubuntu image and reboot your Macbook. Once the screen goes black, hold down the Alt key until you see the boot menu. Choose EFI boot from the boot menu. You will be presented with the Grub menu, select 'Install Ubuntu'.

IMPORTANT: When you reach the screen in the installer titled "Installation Type", you must choose the option "something else". This allows for custom partitioning, if you let the installer choose, you may not be happy with the result.

Create whatever partitioning scheme you'd like, for example:

swap  swap 4GB
/     ext4 10GB
/home ext4 Remainder

NOTE: I recall reading somewhere that it was important to leave the 0MB free space partition between the MacOS partitions and the linux partitions, but I have been unable to find that reference.

IMPORTANT: Under Device for bootloader, ensure the EFI partition is selected /dev/sda1

Finish up the installation and boot into Ubuntu.

Post-Install

Wireless

Insert the USB drive that you downloaded deb packages to earlier, and then install the packages.

For my machine, the command looked like this:

cd /media/charlie/MISC
sudo dpkg -i bcmwl-kernel-source_6.30.223.248+bdcom-0ubuntu7_amd64.deb dkms_2.2.0.3-2ubuntu6_all.deb

Bootloader

Add MacOS as option on Grub menu

Append the following lines to /etc/grub.d/40_custom:

menuentry "MacOS" {
 exit
}

Change these options in /etc/default/grub:

#GRUB_HIDDEN_TIMEOUT=0                  # Disable hidden Grub
#GRUB_HIDDEN_TIMEOUT_QUIET=true         # Disable hidden Grub
GRUB_TIMEOUT=5                          # [Optional] Set smaller timeout (default was 10)
GRUB_CMDLINE_LINUX="libata.force=noncq" # Linux parameter to prevent occasional SSD freezes
GRUB_DEFAULT=2                          # [Optional] Default to MacOS entry

Fix small grub fonts

On the command line execute the following:

sudo grub-mkfont -s 36 -o /boot/grub/DejaVuSansMono.pf2 /usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf

Open and edit again /etc/default/grub and add the following line at the bottom:

GRUB_FONT=/boot/grub/DejaVuSansMono.pf2

Update Grub

sudo update-grub

Common issues

Wifi stops working after suspend

This is caused by a bug in the network-manager.

You can verify this by running the following to see if wifi returns:

sudo systemctl restart network-manager.service

To automate restarting network-manager, create /etc/systemd/system/wifi-resume.service and paste the following into it:

#/etc/systemd/system/wifi-resume.service
#sudo systemctl enable wifi-resume.service
[Unit]
Description=Restart networkmanager at resume
After=suspend.target
After=hibernate.target
After=hybrid-sleep.target

[Service]
Type=oneshot
ExecStart=/bin/systemctl restart network-manager.service

[Install]
WantedBy=suspend.target
WantedBy=hibernate.target
WantedBy=hybrid-sleep.target

Finally run this to activate it:

sudo systemctl enable wifi-resume.service

Fan not working properly

The Macbook Pro's fan requires a daemon to adjust the speed.

Add the following to /etc/modules:

coretemp
applesmc

Install build-essential package: sudo apt install build-essential

Clone the mbpfan source:

git clone [email protected]:dgraziotin/mbpfan.git

Follow directions found here to build and install: A beginner's tutorial for mbpfan under Ubuntu

High CPU usage by kworker

The most important issue I have found so far is the high CPU usage by kworker (i.e. Linux Kernel worker thread), which seriously affects the battery life. Apparently this is caused by an interrupt storm on ACPI interrupt GPE06, as described here. You can verify it by checking if interrupt GPE06 contains a high value:

$ grep . -r /sys/firmware/acpi/interrupts/
...
/sys/firmware/acpi/interrupts/gpe05:       0   invalid
/sys/firmware/acpi/interrupts/gpe06: 2938373   enabled <---
/sys/firmware/acpi/interrupts/gpe07:       0   enabled
...

A quick solution for this issue is to disable this interrupt, i.e.

echo disable > /sys/firmware/acpi/interrupts/gpe06

In order to disable it on every boot, you can add the previous line to /etc/rc.local, just before exit 0.

Remap MacBook Pro keyboard keys to be standard

Create /etc/systemd/system/keyboard-map.service and paste the following into it:

#sudo systemctl enable keyboard-remap.service
[Unit]
Description=Remap keyboard keys
After=multi-user.target

[Service]
Type=oneshot
ExecStart=/usr/bin/setxkbmap -device $(/usr/bin/xinput list --id-only "keyboard:Apple Inc. Apple Internal Keyboard / Trackpad") -option "altwin:swap_alt_win"

[Install]
WantedBy=multi-user.target

Finally run this to activate it:

sudo systemctl enable keyboard-remap.service

http://askubuntu.com/questions/29731/rebind-alt-key-to-win-using-setxkbmap https://lampjs.wordpress.com/2015/06/26/remapchange-your-secondaryusb-keyboard-keys/

References

Installing Ubuntu 15.04 on a Macbook Pro 11,2

Arch - MacBookPro

Installing Ubuntu 15.10 - Wily Werewolf on a Macbook Pro 12-1 (2015)

Wifi doesn't work after suspend after 16.05 upgrade

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment