Hi there! π This is my first post on dev.to. I didn't know what to write about so I just decided to talk about what I'm doing right now, installing Linux on my MacBook Pro 2016 (model 13,3 - dual gpu with touchbar). This might also help anyone trying to install Linux on any MacBook without T2 chip (2017 or older).
π Context
It all started a few months ago when I became curious about tiling window managers and how I could increase my day to day productivity. I'm a software developer and I have A LOT of open windows and programs running at the same time, so I decided to give tiling window managers a shot. Unfortunately there are not a lot of choices available for macOS, I found yabai which is great! but as I started to tweak config files to be more comfortable working with my laptop I started to feel that it wasn't enough.
After a month or so of using yabai I met i3-wm, and fell in love with it. The only problem... it's only for linux. So I though, what the heck, let's install Linux on my MacBook... and so the journey began.
β οΈ Disclaimer
There are a lot of well written guides on GitHub on how to do this (I'll put the links below), so I'm just going to write down the steps I followed in my particular case and the problems I faced.
π What you'll need
- MacBook Pro 13,3 2016 (with touchbar - no T2 chip)
- USB stick of at least 8GB
- macOS. It doesn't really matter which version but it's important to keep it installed to make the touchbar and some other stuff work.
This MacBook has a few components that will make things a bit more complicated than usual, that is the Touchbar and the AMD dedicated GPU.
Some amazing people worked on drivers to make everything work the best way possible, so fear not, they got us covered πͺ
π§ Distro
I have an i7 CPU, 16 GB of RAM. I've tried Manjaro, Ubuntu and Linux Mint and stayed with the latter, it's much more stable in my opinion, but you can pick whatever you want as long as the kernel is 5.0.0 or greater, this is important because some stuff already work out of the box. Also, amdgpu seems not to be working on 5.6, read more here.
πΏ Partitioning & Linux installation
1. Disable System Integrity Protection (SIP)
In order to perform some future steps required to install and boot Linux properly, we need to disable SIP (System Integrity Protection).
- Reboot your Mac. When the startup screen shows up, press and hold the
Command + R
until the Apple logo appears on your screen. - Once it finishes loading and brings you to Recovery Mode, click βUtilities -> Terminal.β
- In the Terminal window, type in
csrutil disable
and press Enter. - Restart your Mac.
2. Create a new partition
I've taken all the images from this amazing guide since it's beautifully explained and since I'm not writing this from macOS
- Open Disk Utility from the β/Applications/Utilitiesβ folder.
- Select your boot disk in the sidebar and click the βPartitionβ button.
- Click βPartitionβ in the dialog box to confirm.
- Click the β+β button to add a partition
- Set the size and name. Choose βMS-DOS (FAT)β for your partition type. This will be erased by the Ubuntu installer.
- Click βApply,β then βPartitionβ to execute.
3. Creating a bootable USB with Linux
- Download the ISO file from the Linux Mint page or your distro of preference.
- Download and Install Etcher in order to burn the ISO in our USB stick.
- Now plug the USB stick, open Etcher and select the ISO file to burn it.
4. Booting from the USB stick
Now we have Linux on our USB stick, it's time to begin the installation. I didn't need to use any external keyboard / mouse but keep in mind that you might require them if for some reason the built-in set doesn't work with the live USB.
- Restart the Mac with the USB stick inserted while the
Option/alt
(β₯) key is pressed. This will launch Appleβs βStartup Managerβ which shows bootable devices connected to the machine. Your USB stick should appear as gold/yellow and labelled βEFI Bootβ. Selecting this will lead you to the distro boot menu.
5. Running the installer
- Connect to your wireless network (if you can) and choose to install third-party software.
- At the installation selection screen, choose βSomething Elseβ from the bottom.
- Select the FAT-32 partition you created earlier. Click the βββ button to delete it.
- With the free space selected, click the β+β to create a new partition.
- Set the size to 4000 MB and βUse asβ to βswap.β (Some people say that for hibernation to work properly, the size of your swap should be around 1.5 times the size of your RAM. Not sure if this is the case, but hibernation didn't work for me anyway).
- Create another new partition with the β+β button. Use all the available free space. Set βUse asβ to βExt4 journaling file system.β Set the mount point to β/.β
- Choose the ext4 partition under βdevice for bootloader installation.β
- Click through the remaining steps to create your user and finish the installation.
π§ Linux tweaks
So far you should have Linux installed on your MacBook just fine, the built-in display, keyboard and trackpad should be working out of the box. Now we're going to fix the following:
- πΆ Wifi
- π΅οΈ Spoof macOS
- πΌ Switch to the iGPU
- π Audio
- π Touchbar
Keep in mind that Wifi won't work until you reboot.
1. Wifi
This MacBook model uses a Broadcom wireless board which is not great but at least we'll get decent wifi. There's an issue with the brcmfmac module used by the kernel. Here's how to fix it.
- Download this file
- And then
cp brcmfmac43602-pcie.txt /lib/firmware/brcm
Wifi works generally ok, but there are a few issues you should be aware of:
- Connectivity signal is not the best.
- After suspend/wake 5 GHz networks are not visible, and even if they are you cannot connect to them. 2.4 GHz works fine.
2. Spoof macOS
We need to make the laptop thinks she's going to boot macOS, otherwise there are some components that don't get powered, included the integrated Intel GPU. For this we'll use a custom EFI file like this:
cd /tmp
# See more at https://github.com/0xbb/apple_set_os.efi/issues/20#issuecomment-557352747
wget https://github.com/0xbb/apple_set_os.efi/files/3877561/apple_set_os.zip
unzip apple_set_os.zip
# As root...
sudo su
mkdir -p /boot/efi/EFI/custom
mv /tmp/apple_set_os.efi /boot/efi/EFI/custom
Now we need to edit GRUB
sudo su
nano /etc/grub.d/40_default
# Add the following lines:
search --no-floppy --set=root --label EFI
chainloader (${root})/EFI/custom/apple_set_os.efi
boot
# Update grub
update-grub
**Note:* If you prefer using rEFInd, that's totally fine. Just remember to uncomment the "spoof_osx_version" line in refind.conf. See more at rEFInd's documentation site.*
3. Switch to the iGPU
This laptop has two GPU boards, one is the integrated Intel Graphics card and the other one is the dedicated ATI Radeon card. Since there are no drivers for this card to work properly we'll have to switch to the integrated one and then power off the dedicated GPU.
sudo su
# Blacklist amdgpu
echo "blacklist amdgpu" > /etc/modprobe.d/blacklist-amdgpu.conf
# Switch to integrated GPU
cd && git clone https://github.com/0xbb/gpu-switch
cd gpu-switch
sudo ./gpu-switch -i
- Reboot
- Now we'll load amdgpu module and turn the card off properly. ```bash
sudo su
gpu-manager | grep 'amdgpu loaded? no' && sudo modprobe amdgpu || echo 'AMD GPU already loaded'
echo OFF > /sys/kernel/debug/vgaswitcheroo/switch
See more at https://github.com/Dunedan/mbp-2016-linux/issues/6#issuecomment-416015734
***Note:** Repeat last three steps every time you reboot (can be automated)*
## 4. Audio
Audio doesn't work out of the box, here's how to fix it.
```bash
sudo su
cd /tmp
sudo apt-get install wget make gcc linux-headers-generic
git clone https://github.com/leifliddy/snd_hda_macbookpro.git
cd snd_hda_macbookpro
./install.cirrus.driver.sh
**Note:* Changes won't take effect unless you reboot the system.*
5. Touchbar
sudo apt-get install git dkms
cd /tmp
echo -e "\n# macbook12-spi-drivers\napplespi\napple_ib_tb\nspi_pxa2xx_platform\nintel_lpss_pci" >> /etc/initramfs-tools/modules
git clone https://github.com/roadrunner2/macbook12-spi-driver.git
cd macbook12-spi-driver
git checkout touchbar-driver-hid-driver
dkms add .
uname -r # check kernel version
dkms install -m applespi -v 0.1 -k 5.3.0-24-generic # replace this with your kernel version
# lsinitramfs /boot/initrd.img-5.3.0-24-generic | grep -i "dkms/apple"
lib/modules/5.3.0-24-generic/updates/dkms/apple-ibridge.ko
lib/modules/5.3.0-24-generic/updates/dkms/apple-ib-tb.ko
lib/modules/5.3.0-24-generic/updates/dkms/applespi.ko
If you want the F-keys to be always on by default and the Fn button for switching from F-keys to special keys, then use the following command (if not, fnmode=1):
echo 'options apple_ib_tb fnmode=2' | sudo tee /etc/modprobe.d/apple_ib_tb.conf
echo 'options apple_ib_tb idle_timeout=60' | sudo tee /etc/modprobe.d/apple_ib_tb.conf
update-initramfs -u -k 5.3.0-24-generic # replace this with your kernel version
You can also swap fn
and a control
keys:
echo 'options applespi fnremap=1' | tee /etc/modprobe.d/applespi.conf
update-initramfs -u -k 5.3.0-24-generic # replace this with your kernel version
Or remap it to any other key:
# modinfo applespi | grep -w fnremap
parm: fnremap:Remap fn key ([0] = no-remap; 1 = left-ctrl, 2 = left-shift, 3 = left-alt, 4 = left-meta, 6 = right-shift, 7 = right-alt, 8 = right-meta) (uint)
π Bonus #1 - Keyboard
Here's a guide on how to remap your keyboard.
https://medium.com/@petrstepanov/a-macos-like-keyboard-remap-on-ubuntu-linux-cae1d108a97
π Bonus #2 - Trackpad
Trackpad is not very good on Linux, here's how to improve it.
https://int3ractive.com/2018/09/make-the-best-of-MacBook-touchpad-on-Ubuntu.html
What doesn't work
- Built-in microphone
- Hibernation
- Audio after suspend
- 5 GHz wifi networks after suspend
Status
Check out https://github.com/Dunedan/mbp-2016-linux for an updated status of each component.
That's all Folks!
I hope you enjoyed this guide. Don't hesitate on commenting if you have any questions or you have any new findings regarding this topic.
Big thanks to all the people that made this possible. It's unbelievable the amount of people spending time on this without any retribution whatsoever π
Sources
- https://github.com/Dunedan/mbp-2016-linux
- https://www.maketecheasier.com/install-dual-boot-ubuntu-mac/ (also took the cover image from here).
- https://ubuntu.com/tutorials/tutorial-create-a-usb-stick-on-macos#5-etcher-configuration
- https://ubuntu.com/tutorials/tutorial-create-a-usb-stick-on-macos#7-boot-your-mac
- https://bugzilla.kernel.org/show_bug.cgi?id=193121#c62
Top comments (13)
Cris, I've been following your very helpful guide. Only issue is that every time the Mint install finishes followed by a reboot, the new Linux install doesn't appear as an option in the Apple boot menu.
Any ideas?
Hi Tom! Sorry for the delay on the response. Have you been able to figure this out?. It sounds like there's something wrong with the partitions (maybe?). Are you using rEFInd?
Let me know!
Thank you so much! I have installed Ubuntu 20.04 on Macbook Pro 2017 and no sound from the speakers. I have followed you guide and work perfectly now. Thank you, thank you, thank you
Hi, just wanted to say thanks and to say that of Kernel 6.8 the audio and touchbar fixes no longer work. But this is still the best tutorial I've found for getting the install set up and wifi working on a 2016-2017 macbook pro.
Hey I got stuck in the spoof MacOS section. My laptop is stuck booting forever with the apple logo.
I have access to grub or uefi menu? when I plug in my Linux USB drive and select it on startup
I have the same problem.
Hey Cris, thanks for this guide! Question, do you have problems waking up your macbook pro 13,3 even after switching to intel on graphics I cannot get mind to wake up after suspend? I'm on 20.04
Hey! I disabled suspend because I never got it working properly :(
Some comments may only be visible to logged-in visitors. Sign in to view all comments.