重拾 MacBook Pro w/ Retina

今年初,在钟爱的顶配 MacBook Air 11″ 上编译 Android 项目,8GB 的内存时不时就紧张了,加上屏幕的分辨率实在不算高,就把它出手给单位的小兄弟了。贴了一大笔,买了个新款的 MacBook 12″ 回来,分辨率当然就上了不止一个档次,硬盘仍然是 512GB,内存翻了一倍,到了 16GB。到手后就痛苦了,首先是接口,只有一个 USB type-c,其次是系统,Ubuntu 连键盘触控板都驱动不起来,无奈之下只好令其回到 macOS。

接下来寄希望于能把 Ubuntu 里的内容迁移到 macOS 中。努力若干次,成效不彰。只好又去闲鱼上寻觅。找来找去锁定一款三星的轻薄本,1080p 的屏幕,8GB 内存,无硬盘,CPU 是 i7 的 6500U,成色很好,价格不错,要 2900 元。在最后关头三太爷退缩了,因为想起自从用了 MacBook Pro w/ TouchBar 之后就一直吃灰的 MacBook Pro w/ Retina,16GB 的内存,1TB 的 SSD 硬盘,白白放着真是浪费。

把 Ubuntu 硬盘外接到其上,引导很顺利,祭出 dd 大法成功将自己克隆到了内置盘上。重启后发现无法进入图形界面。本着节省时间的原则,当机立断用另一个 Ubuntu LiveUSB 引导,以第三方的身份进行了一遍新的克隆操作。成效立显,果然正常启动,所有设备均驱动了起来。图形界面的刷新很慢,到配置里一看,竟然使用的不是 nvidia 的驱动而是开源的 nouveau 驱动,切换后就流畅许多了。

美中不足的是温控部分。根据经验判断,想必和显卡有关,于是满网寻找禁用独显的方法。找到了这个:https://askubuntu.com/questions/678572/how-to-turn-off-nvidia-graphics-on-macbook-pro。帖子里的两个回答看起来是有信息含量的。

第一个是说如何让非 macOS 系统引导时能激活集成显卡:

This is a hack and should be carefully read through in the sources but possibly this helps you:

Macbooks deactivate the intel onboard graphic if anything else than MacOS is booted. You could add a file to the efi and add a grub option to chainload it to get the efi to think its booting MacOS so all hardware ist activated during boot.

get the latest version of the binary efi file from https://github.com/0xbb/apple_set_os.efi/releases

copy it to the mounted efi partition into a new sub folder

add to /etc/grub.d/40_custom

Source: https://github.com/0xbb/apple_set_os.efi

三太爷在命令行下用 lspci | grep -i vga 查看,果然只有独显,没有集显。

另一个也见下,看起来是针对和原提问者一样的老款 MacBook Pro 的,

I happen to have the exact same computer as you. What I devised is to add a few lines to grub to disable the discrete graphics at the efi level:

I just added the outb lines in between the  insmod gzio and  linux_gfx_mode. For reference:

This disables the graphics at the pcie-link level, such that it vanishes from the system. Unlike macOS, the IronLake Intel HD Graphics can drive the external display output, but without audio.

What you described as the mac disabling igpu unless booting macOS holds true for any mac made after 2010, or any mac with a Sandy Bridge chip or later. (2010=nehalem, 1st gen 45nm.) The apple_set_os.efi trick does not work before 2011 (pre-2011, at the time, anything booted with efi would behave exactly like macOS, efi didn’t check the OS, just that it was booted natively, enabling the integrated graphics. And the only way to boot an OS with igpu disabled was to legacy boot, which we are not doing) I tried running it, and it prints that the apple_set_os protocol was not found. I run 16.04.3 stable and it is such a nice experience once you can use the computer without crashes.

About the nvidia proprietary drivers: I did some opengl testing with dolphin-emu and DRI_PRIME=1 booting without outb 0x750, therefore disabling the dGPU’s connection to the lvds display, but leaving it available headless for rendering. Nouveau and proprietary have nearly the same performance. (in fact, the majority of edge cases here were won by nouveau) The NV50/Tesla architecture is perhaps the best supported by nouveau. Therefore, I would actually recommend staying on nouveau.

Lastly, to enable intel graphics on boot permanently (as long as nvram variables are not erased) you can do this from linux:

You can also accomplish the exact same thing from macOS as well:

然而,根据 https://sasanj.wordpress.com/2014/12/03/how-to-turn-off-apple-macbook-pro-discrete-graphics-card-for-linux/,可知“On the MacBook, only when the system boots using EFI, it has access to the onboard Intel graphic card”。很显然,要能切换到 Intel 的集显,需要先把引导模式切换成 UEFI,否则是探测不到集显的存在的。而如何切换引导模式,则找到了 https://askubuntu.com/questions/509423/which-commands-to-convert-a-ubuntu-bios-install-to-efi-uefi-without-boot-repair,改天可以一试,其中的精华内容为:

Start a Ubuntu Linux (14.04) Live CD in UEFI mode. In case of a USB boot device, disable “Fast Boot” in UEFI.

Open a terminal window (Ctrl+Alt+T)

To verify that you are actually running in UEFI mode, use this bash command:

The resulting output should be:

In case it says  BIOS, reboot into your firmware and correct the boot device preference.

To do the BIOS to EFI/UEFI conversion enter these commands:

Despite ending in error message:

the next reboot already shows “ubuntu” in the firmware its boot options menu, and boots to the console as before, except for now booting in efi mode:

In case something goes wrong, https://superuser.com/questions/376470/how-to-reinstall-grub2-efi might help.

发表评论

电子邮件地址不会被公开。 必填项已用*标注