{"slug": "linux-on-macbook-pro-late-2016-and-mid-2017-with-touchbar", "title": "Linux on MacBook Pro Late 2016 and Mid 2017 (with Touchbar)", "summary": "This article documents the process of installing Linux on 2016 and 2017 MacBook Pro models with Touch Bar, focusing on Fedora 27 with kernel 4.14.x. It provides detailed instructions for partitioning, booting, and driver support, noting that an external USB keyboard is required for initial setup since the internal keyboard and touchpad need custom drivers. The guide also lists which hardware components are functional (such as USB, Thunderbolt, and HiDPI detection) and which are not fully supported (including WiFi on certain models, suspend/resume, and audio).", "body_md": "# Introduction\n\nThis is about documenting getting Linux running on the late 2016 and mid 2017 MPB's; the focus is mostly on the MacBookPro13,3 and MacBookPro14,3 (15inch models), but I try to make it relevant and provide information for MacBookPro13,1, MacBookPro13,2, MacBookPro14,1, and MacBookPro14,2 (13inch models) too. I'm currently using Fedora 27, but most the things should be valid for other recent distros even if the details differ. The kernel version is 4.14.x (after latest update).\n\nThe state of linux on the MBP (with particular focus on MacBookPro13,2) is also being tracked on https://github.com/Dunedan/mbp-2016-linux . And for Ubuntu users there are a couple tutorials ([here](https://github.com/chisNaN/ubuntu-on-macbook12) and [here](https://nixaid.com/linux-on-macbookpro/)) focused on that distro and the MacBook.\n\n**Note**: For those who have followed these instructions ealier, and in particular for those who have had problems with the custom DSDT, modifying the DSDT is not necessary anymore - see the updated instructions below and make sure to update your clone of the roadrunner2/macbook12-spi-driver repo to get the latest drivers. \n\n# Summary Of Current State\n## What works\n* Booting (i.e Grub etc)\n* Recognizes disk on all models (older kernels may need patch for some models, though)\n* Keyboard, touchpad, and basic touchbar functionality\n* HiDPI detection\n* Accelerated video\n* Screen brightness control\n* Keyboard backlight\n* USB\n* Sensors (install ```lm_sensors``` package)\n* Camera\n* Bluetooth (older kernels need patches)\n* WiFi on MBP13,1 and MBP14,1\n* Thunderbolt\n* DisplayPort\n\n## What doesn't work\n* WiFi on ,2 and ,3 models (though some folks have had success with some of the workarounds)\n* Suspend/Resume (works partially on 13,3 models)\n* Audio (two cards show up, and intel driver is loaded, but no sound)\n\n# Details\n\n## Partitioning\n\nIf you want to keep your MacOS installation (generally a good idea if you can afford the disk space, because that's the only way to get/install firmware updates), then first boot into MacOS and resize the partition there, creating a new partition for the Linux installation. If you also want to have a Windows partition, see [this comment](#gistcomment-2164350) below.\n\n**Warning**: If you're not going to keep MacOS, either back up the EFI System Partition (and restore its contents to the new ESP after installation) or leave it intact (i.e. don't do a full disk install, but just use the space after the ESP). This partition (it's the first one) contains drivers/firmware/etc needed by Apple's EFI loader during boot, in particular to initialize the Touchbar.\n\n## Initial Installation\n\nSince the internal keyboard and touchpad won't work until you have built and loaded the drivers, you'll need to plug in an external USB keyboard to do the initial setup and installation.\n\n## Booting\n\nIf you're booting a 4.11 or later kernel, no special params or patches are needed.\n\nIf you're booting a kernel < 4.11 and have a MacBookPro13,1, MacBookPro13,2, MacBookPro14,1 or MacBookPro14,2 (13inch models), which have the Apple NVMe controller, you'll need the [kernel-nvme-controller.patch](#file-kernel-nvme-controller-patch) from this gist in order for the disk to be correctly recognized (MacBookPro13,3 uses a Samsung NVMe controller which is automatically detected correctly). Alternatively, instead of patching you can also do the following (for distros using something other than dracut to create the initrd you'll need to adjust the 2nd and 3rd lines appropriately):\n```\necho 'install nvme /sbin/modprobe --ignore-install nvme $CMDLINE_OPTS; echo 106b 2003 > /sys/bus/pci/drivers/nvme/new_id' | sudo tee /etc/modprobe.d/nvme.conf\necho 'force_drivers+=\"nvme\"' | sudo tee /etc/dracut.conf.d/disk.conf\nsudo dracut --force --kver <kernel-version>\n```\n\nIf you're booting a kernel < 4.10 then you'll need the following kernel param to boot properly: `intremap=nosid`. E.g.\n```\nsudo sed -i 's/\\(GRUB_CMDLINE_LINUX=.*\\)\"/\\1 intremap=nosid\"/' /etc/default/grub\nsudo grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg\n```\n\nLastly, if you are booting a live CD or similar with a kernel < 4.9 then you will also need to add the ```nomodeset``` kernel parameter to your kernel line; you will then not have proper HiDPI detection or accelerated graphics.\n\n## Keyboard/Touchpad/Touchbar\n\nFor this we need the drivers from https://github.com/roadrunner2/macbook12-spi-driver.git (a clone of https://github.com/cb22/macbook12-spi-driver which includes a preliminary touchbar driver and keyboard fixes). The following commands set this up.\n\nFirst some extra packages:\n```\nsudo dnf install git kernel-devel dkms\n```\n\nNext we need to prepare for the modules to be included in the ramdisk (so they are loaded early during boot):\n```\ncat <<EOF | sudo tee /etc/dracut.conf.d/keyboard.conf\n# load all drivers needed for the keyboard+touchpad\nadd_drivers+=\"applespi intel_lpss_pci spi_pxa2xx_platform apple-ib-tb\"\nEOF\n```\nOn distros using ```mkinitramfs``` instead of ```dracut``` you'll want to do the following instead:\n```\ncat <<EOF | sudo tee -a /etc/initramfs-tools/modules\n# drivers for keyboard+touchpad\napplespi\napple-ib-tb\nintel_lpss_pci\nspi_pxa2xx_platform\nEOF\n```\n\nNow get and build the drivers:\n```\ngit clone https://github.com/roadrunner2/macbook12-spi-driver.git\npushd macbook12-spi-driver\ngit checkout touchbar-driver-hid-driver\nsudo ln -s `pwd` /usr/src/applespi-0.1\nsudo dkms install applespi/0.1\npopd\n```\n\nNext we need to set the proper dpi for the touchpad and adjust the sensitivity (download the [61-evdev-local.hwdb](#file-61-evdev-local-hwdb), [61-libinput-local.hwdb](#file-61-libinput-local-hwdb), and [local-overrides.quirks](#file-local-overrides-quirks) from this gist - the `61-evdev-local.hwdb` is only needed for udev < 242, the `61-libinput-local.hwdb` is needed for libinput versions < 1.12, the `local-overrides.quirks` for libinput versions >= 1.12):\n```\n# if 'udevadm --version' less than 242:\nsudo cp ...the-downloaded-61-evdev-local.hwdb... /etc/udev/hwdb.d/61-evdev-local.hwdb\n# if 'libinput --version' less than 1.12:\nsudo cp ...the-downloaded-61-libinput-local.hwdb... /etc/udev/hwdb.d/61-libinput-local.hwdb\n# if 'libinput --version' 1.12 or later:\nsudo cp ...the-downloaded-local-overrides.quirks... /etc/libinput/local-overrides.quirks\nsudo systemd-hwdb update\n```\n\nYou can test the drivers by loading them and their dependencies:\n```\nsudo modprobe intel_lpss_pci spi_pxa2xx_platform applespi apple-ib-tb\n```\n\nFinally, reboot to make sure it all works correctly:\n```\nsudo reboot\n```\n\n### Screen Brightness Control\n\nScreen brightness control works out of the box on MacBookPro13,1 and MacBookPro13,2 (all kernels), and MacBookPro13,3 with recent kernels, but requires a kernel patch on MacBookPro13,3 with older kernels (see also https://github.com/Dunedan/mbp-2016-linux/issues/2). Specifically, if you have any of these kernels you need to patch: < 4.14, 4.14 - 4.14.21, 4.15 - v4.15.5 (i.e. the issue was fixed in 4.14.21, 4.15.5, and 4.16). The following will create and install the patched `apple-gmux`:\n```\nmkdir apple-gmux\npushd apple-gmux\n\ncurl -o apple-gmux.patch 'https://bugzilla.kernel.org/attachment.cgi?id=192601'\ncurl -o apple-gmux.c 'https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/plain/drivers/platform/x86/apple-gmux.c?id=refs/tags/v4.9.11'\n\npatch < apple-gmux.patch\n\necho -e '\nobj-m += apple-gmux.o\n\nall:\n\\tmake -C /lib/modules/`uname -r`/build M=`pwd` modules\n' > Makefile\nmake\n\nmod=$(ls /lib/modules/`uname -r`/kernel/drivers/platform/x86/apple-gmux.ko*)\nsudo mv $mod{,.orig}\nsudo cp apple-gmux.ko /lib/modules/`uname -r`/kernel/drivers/platform/x86/\nsudo depmod\n\npopd\n\nsudo reboot\n```\n\n### Other\n\nThe touchpad defaults to using the bottom-left corner for right-clicks - to get 2-finger right click, install the Gnome tweak tool and change it in there.\n\n## WiFi\n\nWiFi works fine on MBP13,1 and MBP14,1. But the other models use a different chipset, and while on those the ```brcmfmac``` driver is automatically loaded, there are a number of issues with it, making it for all practical purposes unusable:\n* it only does 2.4GHz - no 5GHz channels are visible\n* it has an extremely low sensitivity - you must be within a few feet of the base station, and even at 5 feet distance it shows a weak signal.\n* it stops working after 10 or 15 or so minutes; turning WiFi off, waiting a several minutes, and then turning it back on generally gets it working again. Maybe a thermal issue?\n\nBug report: https://bugzilla.kernel.org/show_bug.cgi?id=193121\n\nIn the mean time some folks have that one or both of the following hacks make the WiFi work well enough them (personally, while they do improve the situation, I have not found them to be sufficient enough for actual work, i.e. I still see many packet drops and connection failures - YMMV):\n* reduce the transmit power: `sudo iwconfig wlp3s0 txpower 10`\n* edit the firmware blob (`/lib/firmware/brcm/brcmfmac43602-pcie.bin`) and modify the `regrev` and `ccode` values (see the above bugreport for details)\n\n## Display\n\nThe amdgpu driver works well and is automatically loaded on MacBookPro13,3. On the 13 inch models the use of the ```intel``` Xorg driver may need to be forced (see first comment below).\n\n## Using the iGPU (\\*,3 models only)\n\nThe \\*,3 models have both an iGPU (intel) as well as a dGPU (amd). By default the dGPU is used. While this works well, it does use a lot more power than the iGPU. The following will set things up so the machine uses the iGPU upon boot (but see the caveats below):\n```sh\nmkdir gpu-switch\ncd gpu-switch\n\n# Enable the iGPU at boot\ncurl -O -L https://github.com/0xbb/apple_set_os.efi/releases/download/v1/apple_set_os.efi\n\nsudo mkdir /boot/efi/EFI/custom\nsudo cp apple_set_os.efi /boot/efi/EFI/custom\n\nconfig_dir=$(dirname $(sudo find /boot -name grub.cfg))\ncat <<\"EOF\" | sudo tee \"$config_dir\"/custom.cfg > /dev/null\ninsmod chain\nsearch --no-floppy --set=cuspart --file /EFI/custom/apple_set_os.efi\nchainloader (${cuspart})/EFI/custom/apple_set_os.efi\nboot\nEOF\n\n# Switch the default gpu on boot to iGPU\ncurl -O -L https://raw.githubusercontent.com/0xbb/gpu-switch/master/gpu-switch\nchmod +x gpu-switch\n\n./gpu-switch -i\n\n# Service to disable the dGPU\ncat <<EOF | sudo tee /etc/systemd/system/disable-dgpu.service > /dev/null\n[Unit]\nDescription=Disable the dGPU\n\n[Service]\nType=oneshot\nExecStart=/bin/sh -c 'echo OFF > /sys/kernel/debug/vgaswitcheroo/switch'\nExecStop=/bin/sh -c 'echo ON > /sys/kernel/debug/vgaswitcheroo/switch'\nRemainAfterExit=yes\n\n[Install]\nWantedBy=multi-user.target\nEOF\n\nsudo chmod 644 /etc/systemd/system/disable-dgpu.service\n\ncd -\n```\n\nOnce you then disable the dGPU this will save save you about 5W - 6W, or ⅓ of the power. However, there are several caveats to aware of:\n* The dGPU needs to be manually disabled after each boot and first login with `sudo systemctl start disable-dgpu` - trying to have it run automatically at boot via `systemctl enable disable-gpu` leads to hangs.\n* In order to use an external display (via Thunderbolt/DisplayPort) the dGPU needs to be enabled again (the iGPU is not wired up for that): `sudo systemctl disable disable-dgpu`\n* The amd driver does not handle disabling and re-enabling the of the dGPU very well. In particular system shutdown may hang or just take several minutes, and you may see various errors in the kernel logs when disabling and re-enabling.\n* If you boot into MacOS, then when booting back into Linux you'll need to change the default gpu back to the iGPU again: boot, run `gpu-switch/gpu-switch -i`, and reboot.\n\n## Camera\n\nMacBookPro13,3/14,3: works out of the box on kernels 4.13 and later; on earlier kernels you need the following:\n```\necho \"options uvcvideo quirks=0x100\" > /etc/modprobe.d/uvcvideo.conf\n```\n\nFor MacBookPro[13,14],[12] you need the [bcwc_pcie](https://github.com/patjak/bcwc_pcie) driver (mainline branch) - see also https://github.com/Dunedan/mbp-2016-linux/issues/15.\n\n## Bluetooth\n\nAs of kernel 4.16 bluetooth works out of the box; older kernels need patches - see https://github.com/Dunedan/mbp-2016-linux/issues/29#issuecomment-331693489 and following discussion for details. But in short you'll need to:\n* Ensure your kernel is configured with `CONFIG_BT_HCIUART_BCM=y`\n* apply the patches from [hci_bcm-4.13](https://github.com/roadrunner2/linux/tree/hci_bcm-4.13), [hci_bcm-4.14](https://github.com/roadrunner2/linux/tree/hci_bcm-4.14), or [hci_bcm-4.15](https://github.com/roadrunner2/linux/tree/hci_bcm-4.15), depending on whether you have a 4.13 or earlier, 4.14, or 4.15 kernel.\n* build and reboot\n* on 4.14 and earlier apply the service patch from the above comment and start the service as described there (not necessary on 4.15 and later).\n\nNote that as of 4.16 there are still issues on MacBookPro13,1 and MacBookPro14,1 - see the above bug for details on what additional patches are needed.", "url": "https://wpnews.pro/news/linux-on-macbook-pro-late-2016-and-mid-2017-with-touchbar", "canonical_source": "https://gist.github.com/roadrunner2/1289542a748d9a104e7baec6a92f9cd7", "published_at": "2017-01-16 10:43:34+00:00", "updated_at": "2026-05-22 17:11:27.701056+00:00", "lang": "en", "topics": ["open-source", "hardware", "developer-tools", "products", "research"], "entities": ["Fedora", "MacBookPro", "Dunedan", "Ubuntu", "roadrunner2", "macbook12-spi-driver", "lm_sensors", "Linux"], "alternates": {"html": "https://wpnews.pro/news/linux-on-macbook-pro-late-2016-and-mid-2017-with-touchbar", "markdown": "https://wpnews.pro/news/linux-on-macbook-pro-late-2016-and-mid-2017-with-touchbar.md", "text": "https://wpnews.pro/news/linux-on-macbook-pro-late-2016-and-mid-2017-with-touchbar.txt", "jsonld": "https://wpnews.pro/news/linux-on-macbook-pro-late-2016-and-mid-2017-with-touchbar.jsonld"}}