A simple daemon to control fan speed on all MacBook/MacBook Pros (probably all Apple computers) for Linux Kernel 3 and newer
Find a file
Ati Sharma 968133eb10 Add support for many processors (not just cores)
* Add support for many processors (not just cores)

Add an outer loop in mbpfan.c:retrieve_sensors to loop over all coretemp
directories. Also increase hard-coded limits from 10 to 12 or 16 since
the temp endpoints are sometimes indexed that high.

For example, this is required for supporting a Mac Pro with two processors
of 16 cores, requiring
/sys/devices/platform/coretemp.0/hwmon/hwmon0/temp{1..12}
/sys/devices/platform/coretemp.1/hwmon/hwmon1/temp{1..12}

This solves issue #152 "Mac pro with two processors".
2018-09-20 01:53:21 +05:30
src Add support for many processors (not just cores) 2018-09-20 01:53:21 +05:30
.gitignore Added Eclipse project files to .gitignore 2012-07-05 01:06:40 +02:00
AUTHORS Add gaul to AUTHORS 2018-08-21 02:25:59 -07:00
COPYING Create COPYING 2016-02-07 13:44:30 +01:00
Makefile Allow overriding CC with environment variable 2018-08-20 15:19:04 -07:00
mbpfan.8.gz [80] little changes to man page 2016-08-31 09:39:53 +02:00
mbpfan.conf Removed autoconfig with suggested procedure because has been integrated on mbpfan. Commented auto detect values from config file. 2018-09-11 03:09:35 +05:30
mbpfan.conf.test0 Update unit tests for fan speed auto-detection 2018-09-13 10:29:48 -07:00
mbpfan.conf.test1 Fixes #4. Adds some tests for #28 2012-11-18 22:16:49 +01:00
mbpfan.init.debian Fixes #18. Seems ready for v1.4.0 2012-08-23 22:32:49 +02:00
mbpfan.init.gentoo [Fix #98] runscript-> openrc-run gentoo init 2016-12-29 19:03:10 +01:00
mbpfan.init.redhat Fixes #18. Seems ready for v1.4.0 2012-08-23 22:32:49 +02:00
mbpfan.service remove "-v" flag from systemd service file. 2017-08-14 17:38:29 +04:30
mbpfan.spec Removed autoconfig with suggested procedure because has been integrated on mbpfan. Commented auto detect values from config file. 2018-09-11 03:09:35 +05:30
mbpfan.upstart Change upstart to respawn forever 2013-10-13 12:05:00 +02:00
README.md Improve capitalization, spelling, and whitespace 2018-08-20 22:18:55 -07:00

mbpfan

This is an enhanced version of Allan McRae mbpfan

mbpfan is a daemon that uses input from coretemp module and sets the fan speed using the applesmc module. This enhanced version assumes any number of processors and fans (max. 10).

  • It only uses the temperatures from the processors as input.
  • It requires coretemp and applesmc kernel modules to be loaded.
  • It requires root use
  • It daemonizes or stays in foreground
  • Verbose mode for both syslog and stdout
  • Users can configure it using the file /etc/mbpfan.conf

Table Of Contents

Supported GNU/Linux Distributions

We provide scripts to to load mbpfan daemon at system boot for many distros. Please note that the support is provided by volunteers. mbpfan needs tests and bug reports.

Supported distributions:

  • Ubuntu
  • Debian
  • Archlinux
  • Fedora
  • RedHat
  • CentOS
  • Gentoo
  • Alpine
  • Trisquel
  • Solus

Tested MacBook Models

This section reports those models where mbpfan was tested successfully. It does not necessarily mean that the daemon does not work on non-listed models.

  • MacBook Pro 12,1 13" (Intel i5 - Linux 4.20)
  • MacBook Pro 11,4 15" (Intel i7 - Linux 4.9.41)
  • MacBook Pro 11,1 13" (Intel i5 - Linux 3.14, Linux 3.15)
  • MacBook Pro 9,2 13" (Intel i5/i7 - Linux 3.10)
  • MacBook Pro 8,2 15" (Intel i7 - Linux 3.6.2)
  • MacBook Pro 8,1 13" (Intel i7 - Linux 3.2.0)
  • MacBook Pro 7,1 15" (Intel Core 2 Duo - Linux 3.13)
  • MacBook Pro 6,2 15" (Intel i7 - Linux 3.5.0)
  • MacBook Pro 6,2 15" (Intel i7 - Linux 3.2.0)
  • MacBook Pro 2,2 15" (Intel Core 2 Duo - Linux 3.4.4)
  • MacBook Air 6,1 13" (Intel i7 - Linux 3.13)
  • MacBook Air 5,2 13" (Intel i5 - Linux 3.16)
  • MacBook Air 1,1 13" (Intel Core Duo - Linux 4.4, Linux 4.8)
  • MacBook Air 7,2 13" (Intel Core Duo - Linux 4.10)
  • MacBook 1,1 (Intel Core Duo - Linux 3.16)

Tested iMac/Mac mini Models

This section reports the iMac/Mac mini models where mbpfan was tested successfully.

  • iMac Retina 16.2 21.5" (Intel i5 - Linux 4.4.0 Ubuntu 16.04)
  • iMac 12,1 21.5" (Intel i7 - Linux 4.6.4)
  • iMac 5,1 17" (Intel T7400 (Core 2 Duo) - Linux 14.04 Ubuntu)
  • Mac mini 2,1 (Core 2 Duo - Linux 4.4.0)
  • Mac mini 5,3 (Core i7 2.0 - Linux 4.4.0 elementary/Ubuntu)
  • Mac mini 6,1 (Core i7 2.3 - Linux 4.7.3-4-ck Archlinux)

Requirements

Be sure to load the kernel modules applesmc and coretemp.

These modules are often automatically loaded when booting up GNU/Linux on a MacBook. If that is not the case, you should make sure to load them at system startup.

How do I know if applesmc and coretemp are loaded?

In most distributions, you can run the following command:

lsmod | grep -e applesmc -e coretemp

If you see coretemp and applesmc listed, you are all set.

If you do not see coretemp and applesmc listed, you must load them.

This is usually achieved by inserting the following two lines in the file /etc/modules

coretemp
applesmc

Please check the relevant documentation of your GNU/Linux distribution.

Installation

Arch Linux

See mbpfan-git at AUR. Otherwise, please refer to the Generic Instructions.

Ubuntu

Install the build-essential package. Then, refer to the Generic Install Instructions.

Otherwise, a step-by-step tutorial for beginners is available on my website.

Gentoo

Install the mbpfan package with:

sudo emerge -av app-laptop/mbpfan

Generic Install Instructions (All Other Operating Systems)

Compile with

make

Install with

sudo make install

It copies mbpfan to /usr/sbin, mbpfan.conf to /etc (and overwrites existing files), README.md to /usr/share/doc/mbpfan, and mbpfan.8.gz to /usr/share/man/man8

Run the tests now, see two sections below.

If you would like to compile with Clang instead of GCC, simply set your system's default compiler to be Clang. Tested with Clang 3.8 and 3.9. Tested with Clang 4.0 along with llvm-lld (The LLVM Linker).

It is recommended to run the tests after installing the program. Please run the following command from within the source directory.

sudo ./bin/mbpfan -t

or

sudo make tests

Run Instructions

If not installed, run with

sudo bin/mbpfan

If installed, manually run with

sudo mbpfan

If installed and using the init file, run with (Ubuntu example)

sudo service mbpfan start

Starting at boot

Ubuntu

For systemd based init systems (Ubuntu 16.04+), see the systemd section below.

For upstart based init systems (Ubuntu before 16.04), an example upstart job has been provided. For using it, execute:

sudo cp mbpfan.upstart /etc/init/mbpfan.conf
sudo start mbpfan

Debian An init file suitable for /lib/lsb/init-functions (Debian) is located in the main folder of the source files, called mbpfan.init.debian Rename it to mbpfan, give it execution permissions (chmod +x mbpfan) and move it to /etc/init.d Then, add it to the default runlevels with (as root):

sudo update-rc.d mbpfan defaults

Redhat, CentOS, Fedora An init file suitable for /etc/rc.d/init.d/functions (RHEL/CentOS & Fedora) is also located at the same place, this file is called mbpfan.init.redhat. Also rename it to mbpfan, give it execution permissions and move it to /etc/init.d To add the script to the default runlevels, run the following as root:

chkconfig --level 2345 mbpfan on && chkconfig --level 016 mbpfan off

Gentoo

To automatically run mbpfan at boot, run as root:

rc-update add mbpfan default

systemd As a special bonus, a service file for systemd is also included. To use it, execute the following (as root):

sudo cp mbpfan.service /etc/systemd/system/
sudo systemctl enable mbpfan.service
sudo systemctl daemon-reload
sudo systemctl start mbpfan.service

Usage

Usage: ./mbpfan OPTION(S)

-h Show the help screen
-f Run in foreground
-t Run the tests
-v Be (a lot) verbose

License

GNU General Public License version 3

This Project Is Based On:

Credits

This Project uses following library: