Proprietary NVidia drivers with EFI on Mac, to prevent overheating

70,383

Solution 1

For me, booting Ubuntu in UEFI mode with the Nvidia drivers loaded, also always resulted in the well-known black screen when X was started.

That was until yesterday!

After running into some very promising info in another thread about installing Windows 7 in UEFI mode on a Mac. Folks over there struggled with Windows 7's required int 10h legacy support and found out that in order to work around that, one can perform an unattended installation (because display doesn't work during install). The crucial information to successfully boot Ubuntu in UEFI mode even with Nvidia drivers was that upon start of EFI boot (while handing over to grub), Apple's firmware does not actually activate the VGA card as PCI-E bus master. The Windows' guys explained how to circumvent this using an EFI shell which chainloads the Windows boot manager in order to at least run the setup in unattended mode. And here is the good news: it's easy to do this in GRUB!

In fact, I am right now typing this on a MacBook Pro 7,1 (mid-2010) running Ubuntu Vivid booted in UEFI mode (Xorg.0.log). However, it should be easy to run on or adapt this to any Linux distribution providing an EFI version of GRUB, e.g. Ubuntu 14.04.2 LTS.

~$ dmesg | grep -i efi
[    0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-3.19.0-15-generic.efi.signed root=UUID=7843c644-e6f4-4d64-9317-0b854cb524f2 ro quiet splash intremap=off acpi_osi=! acpi_osi=Darwin nomodeset vt.handoff=7
[    0.000000] efi: EFI v1.10 by Apple
[    0.000000] efi:  ACPI=0xbf96a000  ACPI 2.0=0xbf96a014  SMBIOS=0xbf71a000

To cut the long story short, we have to set two PCI-E registers: one that enables bus-mastering on the video card and the other one enabling VGA support on the PCI-E bridge of the video card. So it has actually nothing to do with the Nvidia drivers and depending on the viewpoint, not even with Apple's outdated/crippled/you name it EFI implementation.

This is how I solved it. Of course, the kudo's go primarily to the guys on the MacRumors forum. DISCLAIMER The following instructions are provided as is, without guarantees nor do I assume any liability. DO THIS AT YOUR OWN RISK!

  1. Install Ubuntu in UEFI mode with the Nvidia drivers

I will not go into details here because there are lots of articles on the web showing you how to do this and end up with the nouveau drivers running your machine hot or with the black screen after installing the Nvidia drivers (e.g. www.rodsbooks.com/ubuntu-efi).

Please note however that the following instructions assume you have successfully installed and booted in UEFI mode. You can verify that by checking for existence of the directory /sys/firmware which is only created after booting in EFI mode.

  1. Find the right PCI-E bus identifiers

We need both the IDs for the graphics card and the PCI-E bridge that it is connected to. Issue the following command in a shell:

~$ sudo lshw -businfo -class bridge -class display
pci@0000:00:00.0              bridge         MCP89 HOST Bridge
pci@0000:00:03.0              bridge         MCP89 LPC Bridge
pci@0000:00:0e.0              bridge         NVIDIA Corporation
pci@0000:00:15.0              bridge         NVIDIA Corporation
pci@0000:00:16.0              bridge         NVIDIA Corporation
pci@0000:00:17.0     >!!<     bridge         MCP89 PCI Express Bridge
pci@0000:04:00.0     >!!<     display        MCP89 GeForce 320M

Have a look at (1) the line saying display and (2) the line with bridge right before that display line. Write down the PCI-E bus ids (format XX:YY.Z) of the bridge device (here 00:17.0) and the display device (here 04:00.0) and remember which is which. Note: Those IDs may be different on your machine, depending on your Mac model and revision.

  1. Create a GRUB script for setting the PCI-E registers during boot

Fire up a text editor with sudo nano /etc/grub.d/01_enable_vga.conf and copy/paste the content below. Make sure to paste all 4 lines into that file! Replace 00:17.0 with the PCI-E ID of your bridge device noted in step 2. Replace 04:00.0 with the PCI-E ID of your display device noted in step 2.

cat << EOF
setpci -s "00:17.0" 3e.b=8
setpci -s "04:00.0" 04.b=7
EOF

Finally, make the created file executable and update your grub config files using the following TWO commands.

~$ sudo chmod 755 /etc/grub.d/01_enable_vga.conf
~$ sudo update-grub
  1. Reboot and check

If, after rebooting, the register values have been set to 8 (bridge device) and 7 (display device), everything went fine:

 ~$ sudo setpci -s "00:17.0" 3e.b
 08
 ~$ sudo setpci -s "04:00.0" 04.b
 07
  1. Install Nvidia drivers and enjoy!

Use Ubuntu's Additional drivers GUI to install the Nvidia drivers. I recommend following this article on how to enable brightness controls because it doesn't work out of the box.

Solution 2

I had a similar problem with my laptop the following worked for me I hope it helps you out.

firstly using Jupiter helped solve most over heating and battery life problems.
My Laptop runs on average 50 degrees Celsius and was running at 68 degrees Celsius before installing Jupiter.

sudo add-apt-repository ppa:webupd8team/jupiter
sudo apt-get update
sudo apt-get install jupiter

After I installed Jupiter, I installed Bumblebee to get my nvidia card to work and switch between intel and nvidea as needed to save battery life and run cooler.

add-apt-repository ppa:bumblebee/stable
sudo apt-get install nvidia-current
sudo apt-get install bumblebee bumblebee-nvidia

Reboot

Then Test to see if it works with

optirun glxspheres

To install Bumblebee GUI: https://askubuntu.com/a/170596/207851

After this My Laptop runs on average 47 degrees Celsius and my battery lasts on average 3 hours (This is with listening to music and developing/3D work like Using Blender).

Good Luck and I hope This Helps

Share:
70,383

Related videos on Youtube

stommestack
Author by

stommestack

Updated on September 18, 2022

Comments

  • stommestack
    stommestack over 1 year

    I have a dual-boot Mac OS X 10.8 and Kubuntu 12.10 64x on my white MacBook from mid-2010 installed. (Model identifier: MacBook7,1 . I have upgraded my RAM from 2GB to 8GB, if that matters.) I have the proprietary NVIDIA drivers installed on my Kubuntu.

    Judging from the temperature monitor widget in Kubuntu, my temperature seems to be ~10℃ hotter compared to under Mac OS X. In Mac OS X I use Temperature Monitor. I'm comparing the CPU Core 0 and CPU Core 1 values in Kubuntu to the CPU Core 1 and CPU Core 2 values in Mac OS X.

    10℃ more may be not a very big overheating disaster, but when I do really intense things on my computer (such as playing Team Fortress 2 a while) my CPU is at ~70℃ on OSX, and when playing it a while on Kubuntu, my CPU is ~80℃. I worry that the higher temperature may shorten the lifetime of my laptop.

    I did some research and found out that it may be that I installed it in BIOS mode, which causes the heat. I can't install it in EFI mode, because the propietary NVidia drivers don't work then (already tried that, it gave a black screen). Does anyone know how to get the propietary NVidia drivers work in EFI mode?

    Edit: Ok, even if there isn't a way to use the proprietary nvidia drivers in EFI mode (doesn't seem like there is a way to do it, I'm not getting any answers), I would already be happy if the heating could be fixed in BIOS mode. How can I at least fix the heating in BIOS mode? I tried putting this in my xorg.conf in the Device section to enable power saving:

         Option         "DPMS" "1"
         Option         "RegistryDwords" "EnableBrightnessControl=1; PowerMizerEnable=0x1; PerfLevelSrc=0x2233; PowerMizerDefault=0x3"
    

    ...but that didn't work.

    Oh, and I'm not using rEFIt by the way, could it be that?

  • stommestack
    stommestack almost 11 years
    "You will also burn your fans out pretty quickly." Does that mean this will break my fans? Or did I misunderstood? Otherwise, I'll try this.
  • coteyr
    coteyr almost 11 years
    Running at 6000 full time will burn them out pretty fast. Running them at a more normal speed (say 3000-4000) will be fine. The fans are meant to peak at 6000 not run there full time.
  • stommestack
    stommestack almost 11 years
    I tried installing that, but no results. My MacBook is still hotter. I can feel the heat.
  • coteyr
    coteyr almost 11 years
    Did you try running your fans manually at 6000 and clearing your air flow path? My CPU temp is currently at 59.5 and all four cores are at 100% It's not going to be much cooler then that.
  • stommestack
    stommestack almost 11 years
    It can't be my air flow path because under Mac OS X it is really cool. When I hold my finger against the left alt key, I can feel heat in Ubuntu. But not in Mac OS X.
  • coteyr
    coteyr almost 11 years
    Linux doesn't cool the same as OS X. It prefers "quite" over "cool" OS X prefers "cool" over "quite". So if your sitting idle and feeling warm, it's likely airflow (cause it's warmed up but not high enough to get make the fans run higher). If you want to stay cooler (there's no real point other then preference and with a 17" heat sink I feel it's a big one) then you need to tell your fans to run faster then default in Linux. I have added my test config for mbpfan to the answer. Note it will really over cool.
  • gertvdijk
    gertvdijk almost 11 years
    @coteyr I don't think these arguments make a lot of sense. Running different software raises this issue, then you can't claim hardware is to blame. It's a fact that most Linux proprietary drivers are less optimized for a lot of mobile devices in terms of power usage (resulting in more heat). On my HP notebook this has to do with the Nvidia driver mostly. Idling system in Linux 20-25W, in Windows this is 7W!
  • coteyr
    coteyr almost 11 years
    sigh -- OS X will hit jet engine mode (6000 RPM) at around 70 degrees. Linux doesn't even bother to get above 3000 RPM till the temp is much higher as the CPU can go to 105 degrees. So for a Linux box to hit a warmer temp then OS X is not uncommon. That said you can "manually" control the fan in Linux to get the same over cooling effect. This issue has nothing to do with driver optimization. It's a pure "heat" v.s. "cooling" issue. It doens't matter how "busy" your CPU is when it hits 70 the jet engines still kick on. Now if you want to compare heat generation, then you can say that Linux...
  • coteyr
    coteyr almost 11 years
    generates "Jet Engine" more frequently. However, that is not even valid, as your not comparing the same fan scaling algorithms. So if your trying to move a single metric down (temp) then run cooling more. Even if power consumption was less in Linux, it would still run warmer by default, because the fan speed picker chooses a different ideal range. It's like setting the AC on 90 and trying to blame the oven because the house is warmer. Just go turn the AC down.
  • stommestack
    stommestack almost 11 years
    Thanks for the config, will try it out. But where should I put that config? (I have mbpfan installed)
  • stommestack
    stommestack almost 11 years
    I tried that config and my fans went crazy. Seriously, at the login screen they where like 3-4-5x louder then when playing a 3D FPS game for some time under Mac OS X. Can't be good. Thanks for pointing at that config however, I'll see if I can tweak it right.
  • coteyr
    coteyr almost 11 years
    Added steps to answer
  • tomodachi
    tomodachi almost 11 years
    Actually I have used my nvidia 9400GT /9600GT card on my Mac book pro 5,1 in EFI mode. So unless you are sure this is the case for this specific model i would say its quite possible
  • coteyr
    coteyr almost 11 years
    @tomodachi, I have heard people say this but I have never gotten my MBP7.1 to do it. maybe a difference in hardware or EFI firmware or something, though I will totally agree that it could be very hardware version dependent.
  • stommestack
    stommestack almost 11 years
    @tomodachi Huh? Weird. My card is an Nvidia GeForce 320M, I get a black screen on reboot when attempting to install these drivers in EFI mode. Is it that I install through the additional drivers screen?
  • Patrick
    Patrick about 8 years
    Any chance you could link to your /etc/X11/xorg.conf file?
  • Andreas
    Andreas about 8 years
    Sorry, I sold the machine a few months after writing this article. But you might try asking on this Arch forums thread: bbs.archlinux.org/viewtopic.php?id=162289&p=4.
  • pyrho
    pyrho almost 4 years
    This totally worked for my 2010 macbook air, I was getting a black screen after suspend, and the performance was crappy. This solved my issue thank you !
  • randy rue
    randy rue over 3 years
    Update. If I remove the 01 file from /etc/grub.d the setpci -s check for 04.b still shows 07. This suggests that my 01 file wasn't loading at all. I've confirmed that it has 0755 permissions the same as the rest of the scripts in /etc/grub.d. Note that the update-grub command spits errors about a missing device /dev/sdb, which I think was the USB stick used to install Mint. Also, there's no sign of any setpic calls in /boot/grub/grub.cfg. Will solve that problem and try again.
  • randy rue
    randy rue over 3 years
    Update: update-grub error re: /dev/sdb was not the issue. It was finding a built in card reader that I had to set a filter for LVM to ignore it. But that didn't solve my problem.
  • randy rue
    randy rue over 3 years
    Solved: I was reading the above instructions wrong and had to better understand how update-grub works. The scripts in /etc/grub.d are not inserted into /boot/grub/grub.cfg, instead they actually act on it. Not knowing that, I ignored the cat << EOF lines in the 01... script above, thinking the OP was just trying to make it easy to write the file and had garbled the instructions. Doh. Changed the 01 script to all four lines, ran update-grub, rebooted. Installed the nvidia drivers and rebooted to a GUI.
  • randy rue
    randy rue over 3 years
    One last note: After rebooting as above, "setpci -s "00:17.0" 3e.b" returns "0a" instead of "8." Took a chance and rebooted anyway and all appears to be well.
  • Axel Lieber
    Axel Lieber over 3 years
    Several years later, this is still saving asses. 2010 Macbook Air here! Thank you!!
  • daviewales
    daviewales over 2 years
    The debian wiki has a write-up of this method (crediting this exact post): wiki.debian.org/InstallingDebianOn/Apple/MacBookPro/…