This are notes for configuration thinkfan for Fedora. This configuration procedure was followed on a Lenovo Thinkpad X1 Carbon (5th Gen) running Fedora 25.
Non standard (default) configuration was required for this machine as the default sensors are not available. Eg: /proc/acpi/ibm/thermal does not exist for this model.
An annoted configuration file has been included below. However, there is no guarentee that this will work as-is on every machine.
dnf -y install thinkfanThis step might not be required, but can be performed nonetheless. This is usually required if you cannot fine coretemp listed in your loaded modules. You can check for this with the folllowing;
lsmod | grep coretempIf not found, execute the following command. You can skip --auto flag if you want to run in interactive mode.
dnf -y install lm_sensors
sensors-detect --autoOnce completed, you have to either restart the machine or load the kernel modules determined by sensors-detect. For the latter, you can execute the following command.
systemctl restart systemd-modules-loadOnce the module is loaded, you can identify the sensors with the help of find.
find /sys/devices -type f -name 'temp*_input'You should see an output similar to what is shown below.
# find /sys/devices -type f -name 'temp*_input'
/sys/devices/platform/coretemp.0/hwmon/hwmon4/temp2_input
/sys/devices/platform/coretemp.0/hwmon/hwmon4/temp3_input
/sys/devices/platform/coretemp.0/hwmon/hwmon4/temp1_input
/sys/devices/virtual/hwmon/hwmon2/temp1_input
/sys/devices/virtual/hwmon/hwmon0/temp1_input
/sys/devices/virtual/hwmon/hwmon3/temp1_input
The sensors need to be added to /etc/thinkfan.conf, but prefixed with hwmon. You can append to the config with the following one-liner as root, or manually append it yourself.
find /sys/devices -type f -name 'temp*_input' | xargs -I {} echo "hwmon {}" >> /etc/thinkfan.confIn order to suppress the warning that it is using the default fan control mechanism, you may also wish to uncomment the following line from the default configuration.
tp_fan /proc/acpi/ibm/fanThis is pretty self explanatory. We want the thinkfan daemon to start at boot.
systemctl enable thinkfanIf you want to start it immediately you can systemctl start thinkfan.
This is useful since the files in /sys/devices can go away and be recreated under certain conditions (eg: system suspend). This, with the default configuration causes the services to crash and require manual intervention. In order to make this a bit less annoying, we can add a systemd drop-in file to tweak the default service specification. For this you need to add a conf file at /etc/systemd/system/thinkfan.service.d. Execute the following as root.
mkdir -p /etc/systemd/system/thinkfan.service.d
cat > /etc/systemd/system/thinkfan.service.d/10-restart-on-failure.conf << EOF
[Unit]
StartLimitIntervalSec=30
StartLimitBurst=3
[Service]
Restart=on-failure
RestartSec=3
EOFOnce this is done, reload systemd.
systemctl daemon-reloadThe drop-in configuration, tells systemd to restart the service on-failure and wait 3 seconds before restarting. The Unit section configuration limits restarts to 3 times every 30 seconds.
The configuration methodology of using find to dump all your sensor files from sysfs could, in certain cases be affected by the order in which modules are loaded by the kernel. For example, on my machine the sensors for coretemp and iwlwifi swaps between hwmon3 and hwmon4 when the machine is awakened after being suspended. To make matters worse, this is inconsistent. This causes the thinkfan daemon to crash and keep crashing until the configuration is updated.
To work around this issue, I hacked together the thinkfan-config script. This uses a template embedded in the script to generate and replace the configuration at /etc/thinkfan.conf. Note that this is specific to my system and may not work for other configurations. But you could tweak it based on your needs.
In order to avoid any manual intervention, we can trigger the script before starting the daemon. This can be configured as follows, assuming the thinkfan-config script is installed at /usr/bin/thinkfan-config and set to be an executable.
cat > /etc/systemd/system/thinkfan.service.d/00-generate-config.conf << EOF
[Service]
ExecStartPre=-/usr/bin/thinkfan-config
EOF- The man page for thinkfan
man thinkfanis a good resource. - The troubleshooting session at http://thinkwiki.de/Thinkfan is the source for majority of the details above.
The issues that required the use of thinkfan is listed below. This has been resolved since 4.12.4-1 of the kernel.
Thanks a lot @abn for this guide! I have the same machine and I wonder why there are only two cores reported (Core 0 and Core 1):
The laptop should have 4 cores. But your config files have only two so I suspect you know what is happening here and I am missing something.
Also do you know what "Package id 0:" represents?
Thanks!