Loading
Jan 30, 2016

A beginner’s tutorial for mbpfan under Ubuntu

Although mbpfan is not a program for everyone (heck, I do not even provide compiled packages for distros), I received several requests for an easy, step-by-step tutorial for installing mbpfan for Ubuntu. Here is my attempt. The present tutorial was written using Ubuntu 15.10, after a fresh install.

First thing to do is to take note of the configuration parameters for mbpfan settings. Let’s start with the fan speed’s min and max values that the system was able to detect. Open a terminal, and type the following commands, one at a time.

Note down the lowest among the numbers for fan_min. For example, I got 1299.
Note down the highest among the numbers for fan_max. 
For example, I got 6199.
These two values are your min_fan_speed and max_fan_speed values for mbpfan configuration.

Now, see what are the max values that the system was able to detect for the temperature.

Note down the highest among the numbers you might obtain.
Divide the number by 1000.
The value you will obtain is max_temp value for mbpfan configuration.
For example, I got 105000. Therefore, my max_temp is 105.

Second thing to do is to obtain and install mbpfan. Download the latest .tar.gz version of the source code from mbpfan tag/release page.

Assuming that the download will land to the Downloads folder, and that the file you download is mbpfan-1.9.1.tar.gz (the -1.9.1 part will change in the future). Open the terminal, go to the downloads folder, extract mbpfan, and enter the source code directory.

Install the build-essential package, which contains what is required for compiling basic source code like the one of mbpfan.

The command sudo lets you execute commands as the root user. The first time you use sudo, you need to supply your user password. It is completely normal that you won’t see any star (***) appearing here. Just type the password and press enter.

You might receive the message that “build-essential is already the newest version”. All good if you have got it already.

Compile, install, and test mbpfan.

You should receive some text, which has to tell you that “ALL TESTS PASSED”. If not, please contact me.

Third thing to do is to configure mbpfan. Open the configuration file using a text editor (like Gedit) with root access.

The content of the file will be the following:

Change the values of min_fan_speed, max_fan_speed, and max_temp to the values that your marked down at the beginning of this tutorial.

As example, this is my resulting file.

You might note that for max_temp, I suggest to never setting the value above 90. Yet, I got 105. You can set it to any value smaller (never bigger) than the one you obtained before. This is for having a more conservative system. The max_temp value is what mbpfan considers a critical temperature, where the fans have to be set immediately at the maximum possible speed.

The low_temp option can be as low as 50-55 degrees (according to your CPU model). Feel free to try different settings for this value and for high_temp. Mbpfan attempts to keep a low fan speed if the temperature is between low_temp to high_temp.

Finally, turn mbpfan into a system service. Be sure to be back into mbpfan source directory, in the Downloads folder. Then, run the following two commands:

Reboot your system. In order to check that mbpfan is up and running, open a terminal again, and give the following command.

If there is a line ending with /usr/sbin/mbpfan -fv , you are good to go.

You can delete the files in the Downloads folder, they are not needed anymore.

Once an update of mbpfan is released, you just have to extract the new source files, enter the directory, and give the commands make, sudo make install, and sudo make tests. The configuration file does not get overwritten when updating mbpfan.

I wish you a happy, fresh Macbook. Did you find a bug? Please describe your issue at mbpfan’s Github issue tracker.

written by dgraziotin

Dr. Daniel Graziotin received his PhD in computer science, software engineering at the Free University of Bozen-Bolzano, Italy. His research interests include human aspects in empirical software engineering with psychological measurements, Web engineering, and open science. He researches, publishes, and reviews for venues in software engineering, human-computer interaction, and psychology. Daniel is the founder of the psychoempirical software engineering discipline and guidelines. He is associate editor at the Journal of Open Research Software, academic editor at the Research Ideas and Outcomes (RIO) journal, and academic editor at the Open Communications in Computer Science journal. He is the local coordinator of the Italian Open science local group for the Open Knowledge Foundation. He is a member of ACM, SIGSOFT, and IEEE.

Comments
  • Taylor Feb 19, 2016 Reply

    Great write-up. Looking forward to trying this sometime this weekend.

    I recently installed 14.04 Server on a Mac Mini 7,1 (Late 2014). After about a day of running, I noticed it was VERY hot when I came home from work. I began to look into fan controllers/daemons, but haven’t been too successful.

    I tried macfanctl, but the fan just ran at 6200 RPMs from the get go and even when I stopped the daemon, it continued to run at max speed. I’ve begun to look at macfanctld logging and seeing if I could turn off/ignore certain sensors (when reporting negative temps) as many have advised in postings/communities/forums, but haven’t had too much time to try it.

    Long story short…have you had any success with mbpfan working on a Mac Mini? This write-up makes me feel mbpfan may be a better option. Thanks in advance.

  • karananand Feb 25, 2016 Reply

    after installing build-essential when i type “make” it says “make: *** No targets specified and no makefile found. Stop.”

  • karananand Feb 25, 2016 Reply

    “sudo cp mbpfan.service /etc/systemd/system/” -this says there is no such file or directory

    • dgraziotin Feb 26, 2016 Reply

      My guess is that you are not typing both commands from within mpbfan source directory.

  • karananand Feb 26, 2016 Reply

    i typed within source but it says “cp: cannot stat ‘mbpfan.service’: No such file or directory”.Any way finally i was able to start the fan manually by typing “sudo mbpfan” Thanks author. Mbpfan works perfectly with manual start,finally i got a better solution from ur tutorial thanks.

    • dgraziotin Feb 27, 2016 Reply

      That file is in the root directory of the source file. Both that issue and the previous one you reported regarding the use of the make command show that the files are not in the directory you are in. I have also checked the tutorial again to be safe.

      In any case, glad that it is working now!

  • stíobhart May 9, 2016 Reply

    I’ve recently installed Ubuntu Mate 16.04 on an old unused MBP and the fans were continually screaming at full speed, so the thing sounded like it was about to take off.

    [Actually, I seem to remember it doing this way back when I used it with OSX too, but that’s beside the point]

    When I ran cat fan*_min and cat fan*_max I actually got results where the min speed [6200] was higher than the max speed [6000]. No wonder the wee thing was confused!

    Anyway, Macfantld didn’t make any difference, so I installed mbpfan using these excellent instructions [I’m a lazy sod. I hate having to build from source!] and my old MBP is now purring instead of doing helicopter impersonations. So thumbs up from me!

  • Aelevision May 9, 2016 Reply

    After completing the installation, I rebooted and entered the commands to check if mbpfan was running. Instead of receiving a line ending with ” /usr/sbin/mbpfan -fv”, I received this…

    “aelevis+ 2905 0.0 0.0 21296 948 pts/17 S+ 13:22 0:00 grep –color=auto mpbfan”

    Does this mean it’s not running? Thanks!

    • Aelevision May 9, 2016 Reply

      Okay, after a full shutdown and restart I received a line with that path directory. Thanks for the great tutorial. I will share!

  • Edwin May 10, 2016 Reply

    When I want to upgrade the kernel of my ubuntu, do I need to compile mbpfan again or will it stay where it is, and work as it should.

    • dgraziotin May 10, 2016 Reply

      It is supposed to keep working. There might be issues if the new kernel introduces major changes to Coretemp. It happened once, in 2014.

  • GeneralRage May 17, 2016 Reply

    hi guys from some strange reason i get that systemctl dose not work (linux mint or ubuntu)
    generalrage@generalrage-MacBookPro ~/Preuzimanja/mbpfan-1.9.1 $ sudo systemctl enable mbpfan.service
    sudo: systemctl: command not found

    • John Jul 11, 2016 Reply

      Which version of Ubuntu are you running? systemctl is the control command for systemd – the services/init daemon for Ubuntu 15.04 and up. If you’re running an older version of Ubuntu, you’re using the upstart daemon instead, which uses the initctl command. A startup file called mbpfan.upstart comes along for the ride; you’ll want to copy this to /etc/init, then restart.

  • Shane Haggerty Jun 14, 2016 Reply

    If I want to edit the configuration file after following the instructions am I able to? I’m getting the error [** (gedit:4204): WARNING **: Set document metadata failed: Setting attribute metadata::gedit-position not supported] when I try to edit it after the initial setup.

    • dgraziotin Jun 14, 2016 Reply

      This is very likely just a series of warnings that you get when launching a graphical app from the terminal. In your case, it is gedit. It is not related to mbpfan and it will never cause any issue to..anything. In other words: do not worry!

      • Shane Sep 4, 2016 Reply

        The last installation worked great, thanks for the timely reply. I’m trying to install it again only this time when I enter the “sudo systemctl enable mbpfan.service” command I am getting the response “Unknown operation enable mbpfan.service.”

        • Egene Jan 14, 2017 Reply

          same issue here

        • Egene Jan 15, 2017 Reply

          Incase anyone else has this problem, I found a solution
          just clonel it from git:
          sudo git clone https://github.com/dgraziotin/mbpfan
          then do as normal
          sudo cp mbpfan.service /etc/systemd/system/
          sudo systemctl enable mbpfan.service
          worked for me

          • Andrea May 15, 2017

            Thanks it works!!!!

  • Ben F Jun 20, 2016 Reply

    I installed this package because the one I was using before had the fan running at maximum just after boot on a MATE desktop with nothing running. Unfortunately the same is happening with this one. Only for the few minutes after purging the old one and restarting did I have silence.

    Do I have to choose between silence and the risk of overheating? How much of a risk is it? Or is there a problem with the fan itself?

    I wish I could go back in time to when I bought this MBP and just have bought something else instead. Anything would have done. Worst grand I ever spent.

  • Daniel Graziotin Jun 21, 2016 Reply

    This happens sometimes when booting GNU/Linux after a Mac OS X session. Is that your case?

    Could you clarify what you mean with

    Only for the few minutes after purging the old one and restarting did I have silence.

    Also, what happens if you leave it running at maximum speed for a couple of minutes (say, 5)? Does mbpfan eventually lower the fan speed?

  • Johnathan Lemus Jul 2, 2016 Reply

    Excellent Tutorial, but I still can’t get it to work. I have an old Mac Mini from 2009 that i outfitted with a new SSD and Ubuntu 16.04. It now runs fabulously but the fan does not spin which is a huge problem. I know that Ubuntu doesn’t have support for the Mac fan out of the box, but I can’t even take manual control of the fan. The fan has only ever turned on once randomly.

    • Daniel Graziotin Jul 4, 2016 Reply

      Hi, please open an issue here and describe your problem as much detailed as possible. Actually, your comment made me realize that I should mention the issue tracker on this post. Cheers!

  • John Jul 11, 2016 Reply

    Just installed mbpfan on a mac mini 2,1 (Core 2 Duo, 1.83 GHz) running Ubuntu 16.04. So far working a treat: fan reports as running at 2000 RPM. Will keep an eye on the output of the {{sensors}} command and see how things hold up over the next few days.

    • dgraziotin Jul 12, 2016 Reply

      Thanks, just added to the list of devices!

  • carl Jul 27, 2016 Reply

    Thanks for writing this I was a bit lost at first.

  • Jose Aug 3, 2016 Reply

    Hi,

    First, thank you for your work, and to put it at reach or everyone.
    Tested successfully on MacBookAir Early 2015 (7,2) on Arch Linux (kernel 4.6.1) using yaourt. I’ve try changing min value of fan in mbpfan.conf, restarted daemon and view changes on RPM using ‘lm_sensors’

    Bye!

  • Jason Aug 17, 2016 Reply

    Seems to be working fine on MacBook Pro mid 2009. Nice work!

  • Nicolas Sep 1, 2016 Reply

    I just installed it flawlessly on an imac 11,3 running ubuntu 16.04. Thanks.

  • snowmusicman Oct 11, 2016 Reply

    Thank you so much, running fine on MB1,1 Bodhi Linux. I can finally use this in a library!

  • Claude Oct 29, 2016 Reply

    On my MacBook Air 2012, with kernel 4.8 (Ubuntu 16.10, Fedora 25, Solus, Apricity OS) the fan is not as silent anymore. It is more often on. Like annoying. Was working better on earlier kernel, like 4.4 LTS. Not perfect as in MacOS, but really better than with latest kernel.

    • dgraziotin Oct 30, 2016 Reply

      Hi Claude,

      I suspect that there is something going on, e.g., more CPU utilization on your Air than before.

      There have not been commits to the Linux kernel that are of interest to mbpfan since 2015 (proof: applesmc and coretemp). So, unless they changed something in how the CPU gets throttled (or something similar), nothing related to the kernel is causing malfunctions to mbpfan. Also in that case there would be little I could do, because I rely on applesmc and coretemp modules only.

      • Claude Dec 5, 2016 Reply

        I’ve been runing Ubuntu 16.10 (kernel 4.8.x) for the past 3 days. The only things I add were TLP and edited the modules with applesmc and coretemp. I wanted to try without mbpfan, to see how it goes. Not sure if I’m living dangerously, but my MacBook Air 2012 doesn’t seem to be hotter than on MacOS and is as silent. The fan seems to only come on when needed. Maybe the newer kernel helps.

        • Claude Dec 5, 2016 Reply

          Forgot to say that on Ubuntu 16.10, Intel P-State is activated by default and the governors are set to Powersave. Thermald is still there. I used to enable the first 2.

          • dgraziotin Dec 7, 2016

            I am not an expert on thermald. But at a first glance, thermald looked like conflicted with mbpfan.

          • Claude Dec 9, 2016

            Hmm. Interesting about Thermald. I would have love to hear about his result when he tried to disable it. I used to always activate it. Afraid to think I was mistaking all that time.

            I didn’t know it could be configured. (Nad I don’t know how…) I wonder how well it could perform on a Mac.
            https://wiki.ubuntu.com/Kernel/PowerManagement/ThermalIssues

  • Eduardo Nov 19, 2016 Reply

    Hey Daniel, thank you so much for taking your time on this small, but useful, piece of program and these wonderful instructions for us, lazy lads.
    Tell you what, I’ve this MBP 7,1 from early 2010 and was struggling with his temperature. Not even macfanctld managed that. So I tried installing your program and everything went great, but I’ve got the same fan speed for both min and max. Is this odd or did I messed up on anything? Went down on this entire comment section and found no one with the same problem as me.
    Thank you in advance. It’s working anyway I guess.

    • dgraziotin Nov 26, 2016 Reply

      Hi Eduardo! Do you mean that you get the same numbers when you run:

      So that you need to put the same numbers in the config file?
      Also, please check that you are not running other fan managers together with mbpfan.

  • MR Dec 5, 2016 Reply

    Installed 1.9.1 on Fedora 24 using this guide and tar – Mid-2010 Mackbook pro 15 inch (6,2 I believe?)
    Tried to source build, but had problems. I think the apt-get install build-essential command just needs to be replaced with sudo dnf install gcc-c++ for fedora 24…

    • dgraziotin Dec 7, 2016 Reply

      Hi MR, this tutorial is for Ubuntu. Fedora does not use the APT system and has different names for some packages.
      I understand that the safest substitute should be:

      But I am not updated on Fedora.

    • Claude Dec 9, 2016 Reply

      sudo dnf groupinstall “Development Tools”

      from : http://tecadmin.net/install-development-tools-on-centos/#

      • Claude Dec 9, 2016 Reply

        In fact, the correct command, to get all the stuff needed on Fedora, is :

        sudo dnf groupinstall “Development Tools” “C Development Tools and Libraries”

  • JuanCalamar Feb 24, 2017 Reply

    Hello and thanks for this precise tutorial, it is very clear and simple to follow.
    Unfortunately in my case it did not do what I needed, maybe someone has a similar issue:
    I have an iMac mid2011 with Ubuntu installed (no iOs at all), and changed the HDD into SSD. Now the fan nr.2 starts rising more and more up untill it reaches aprox. 5.500. This machine has 3 fans and nr.2 is missing the signal from the HDD. I have tryed to name them in the mbpfan.conf like:
    min_fan1_speed = 1299
    max_fan1_speed = 6199
    min_fan2_speed = 1299
    max_fan2_speed = 6199
    and give them different values, but no reaction, even if I use the normal version without giving nr. to the fan, the mbpfan doesnt seem to cause any changes.
    Anyone who could help here please? Thanks in advance!

  • Valentina Feb 25, 2017 Reply

    Thanks! after having upgraded my ldme I couldn’t literally listen to any music or watch film due to noisy fan. Purged macfanctld and install and configured mbpfan. I lower the min_fan1_speed to one “bearable” and done!

  • Caleb Apr 20, 2017 Reply

    This is what I am getting is this means it is working? I dont hear my fans spinning.

    2727 0.0 0.0 14224 1028 pts/18 S+ 22:32 0:00 grep –color=auto mbpfan

    • dgraziotin Apr 20, 2017 Reply

      by this, mbpfan is not running

      • Theodore Jul 5, 2017 Reply

        Hello,
        Thanks for the easy tutorial! 🙂

        I get a similar message:
        root 4560 0.0 0.0 9536 116 ? Ss 08:50 0:00 mbpfan
        theodore 12459 0.0 0.0 29240 3732 pts/20 S+ 08:54 0:00 root mbpfan
        theodore 12460 0.0 0.2 64768 19908 pts/20 S+ 08:54 0:00 /usr/bin/root.exe -splash mbpfan
        theodore 13153 0.0 0.0 16276 980 pts/19 S+ 08:55 0:00 grep –color=auto mbpfan

        I have launched mbpfan as sudo, yet no luck…

        Any pointers?

        Thanks again,

        Theo

        • Theodore Jul 5, 2017 Reply

          Actually, after reboot, I get this:
          root 2349 0.0 0.0 9536 116 ? Ss 08:58 0:00 mbpfan
          theodore 2421 0.0 0.0 16276 1016 pts/18 S+ 08:58 0:00 grep –color=auto mbpfan

          I launched sudo mbpfan but same message…

          • dgraziotin Jul 10, 2017

            Hi, it seems to me it is working and that the output is missing the /usr/bin part.

  • Michael Apr 23, 2017 Reply

    After macfanctld would not reduce the fan speed from 5500 RPM no matter what I tried, I considered writing my own daemon. But then I found mbpfan and it works great so far. Running on a Mac Mini 1,1 with the 2,1 EFI firmware hack.

  • Nikolaus May 16, 2017 Reply

    Thanks for this program.
    I am currently running Fedora 25 on a 2013 MBP 15″
    when running the tests in verbose mode, I get:

    Starting the tests..
    It is normal for them to take a bit to finish.
    Using new sensor path for kernel >= 3.0.15 or some CentOS versions with kernel 3.10.0
    Found hwmon path at /sys/devices/platform/coretemp.0/hwmon/hwmon3/temp
    Found 5 sensors
    Found 2 fans
    Using new sensor path for kernel >= 3.0.15 or some CentOS versions with kernel 3.10.0
    Found hwmon path at /sys/devices/platform/coretemp.0/hwmon/hwmon3/temp
    Found 5 sensors
    Couldn’t open configfile, using defaults
    polling_interval is not 1
    Tests run: 5

    Since I’d really like to run my laptop a lot colder than the default, this poses a bit of a problem.
    I have tried running chmod 777 on /etc/mbpfan.conf but this hasn’t solved the problem.

    Sorry to bother you with this, but I can’t seem to figure out the problem.

  • scarpma Jun 25, 2017 Reply

    Really great post!!! You know your stuff!

  • blue phoenix Jun 29, 2017 Reply

    I was able to run the steps on using vi editor although gedit was successfully installed… also I saw the on the first line output the /usr/sbin/mbpfan -fv. I would just like to know how come my laptop is still having more than warm temperature compared when using my regular MacOS system? I have only installed openssh, build essentials and gedit… also installed xauth since I really want gedit to work…. Please help if anything I still need to do?

    • dgraziotin Jul 2, 2017 Reply

      You can tweak the system config to lower high_temp. Mbpfan will kick in earlier. Other than that, mbpfan will not mimic macOS fan system. The reason is that we do not know how macOS manages the fans. The algorithm is proprietary.

      • blue phoenix Jul 14, 2017 Reply

        low_temp = 63 # try ranges 55-63, default is 63
        high_temp = 66 # try ranges 58-66, default is 66
        max_temp = 84 #

        Do I change the low_temp from 63 to like 40?
        Do I change the high_temp from 66 to 47?
        Do I change the max_temp from 84 to 67?

        • dgraziotin Aug 3, 2017 Reply

          Try with small adjustments first. But do not expect the laptop to behave exactly like with macOS. You have installed an entirely different operating system.

  • Matt Jul 1, 2017 Reply

    Thank you for this! Running 32-bit Linux Mint 18.0 on a late 2006 iMac 20″. I can now bring this old dinosaur back to life using Mint while not burning the house down.

  • blue phoenix Jul 6, 2017 Reply

    Hi,

    Is it a normal behavior that everytime my ubuntu/mac laptop reboots, I need to enable the mbpfan service all over again? Is there something I can do that the service is automatically starting once I reboot?

    Thanks,

    • dgraziotin Jul 10, 2017 Reply

      Hi, it is not normal. Are you sure you followed the last part of the post, the part talking about systemctl?

Leave a comment