I'm attaching a simple bash script for controlling the three fans of an iMac 10,1 (late 2009) under Linux. It should be adaptable for similar models. When replacing the original hard drive with an SSD the drive temperature sensor is no longer available resulting in the HDD fan running at full speed. The mbpfan daemon works well for a MacBook but only uses the CPU temperature to control all fan speeds and so it isn't suitable for the iMac. I also find that the default fan profile makes my machine run very hot.
It assumes that the mechanical hard drive has been replaced with a SMART capable SSD. If this isn't the case then the SSD temperature sensing can be removed.
It uses the applesmc module to access the iMac temperature sensors and the drivetemp module to access the SSD temperature sensor. It controls the fans individually based on the sensor values. The drivetemp module will probably not be loaded on your system by default so it will need to be configured to load at boot. The instructions are in the script. If you've been using a different method to control fan speed (like mbpfan) then you'll need to disable this first.
This script works well as a systemd service and the installation instructions are also in the script.
In the script there are a set of parameter variables *_HIGH_TEMP and *_MAX_TEMP for each sensor being monitored. The former sets the temperature after which the fan speed starts to rise, and the later sets the temperature at which the fans will be running at full speed. I have set these to provide the optimum cooling for my iMac under various loads. You may find you want to tweak the parameters for your system. I found the psensors application very useful for tuning these parameters. The fan speeds are calculated every 5 seconds although you can choose a different frequency in the main loop of the script.
The optical drive fan is controlled by the GPU die temperature (my optical drive is kaput). The hard disk fan is controlled by the memory proximity temperature as well as SSD temperature. The CPU fan is controlled by CPU core temperatures and PSU heatsink temperature. The memory temperature could be swapped for the Northbridge temperature (TN0H, temp 20) but they both track each other quite closely on my iMac. Bear in mind that if you are adapting the script for a different model then the physical location of the devices and their sensors with respect the fans may be different.
I'm a reluctant bash coder and I'm not a systemd expert. I welcome any improvements or comments.
It assumes that the mechanical hard drive has been replaced with a SMART capable SSD. If this isn't the case then the SSD temperature sensing can be removed.
It uses the applesmc module to access the iMac temperature sensors and the drivetemp module to access the SSD temperature sensor. It controls the fans individually based on the sensor values. The drivetemp module will probably not be loaded on your system by default so it will need to be configured to load at boot. The instructions are in the script. If you've been using a different method to control fan speed (like mbpfan) then you'll need to disable this first.
This script works well as a systemd service and the installation instructions are also in the script.
In the script there are a set of parameter variables *_HIGH_TEMP and *_MAX_TEMP for each sensor being monitored. The former sets the temperature after which the fan speed starts to rise, and the later sets the temperature at which the fans will be running at full speed. I have set these to provide the optimum cooling for my iMac under various loads. You may find you want to tweak the parameters for your system. I found the psensors application very useful for tuning these parameters. The fan speeds are calculated every 5 seconds although you can choose a different frequency in the main loop of the script.
The optical drive fan is controlled by the GPU die temperature (my optical drive is kaput). The hard disk fan is controlled by the memory proximity temperature as well as SSD temperature. The CPU fan is controlled by CPU core temperatures and PSU heatsink temperature. The memory temperature could be swapped for the Northbridge temperature (TN0H, temp 20) but they both track each other quite closely on my iMac. Bear in mind that if you are adapting the script for a different model then the physical location of the devices and their sensors with respect the fans may be different.
I'm a reluctant bash coder and I'm not a systemd expert. I welcome any improvements or comments.