Persisting change to /sys/class/thermal/thermal_zone*/mode

My laptop (Lenovo C940) has well documented problems [1] with thermal shutdowns: for issues beyond me, it freaks out thinking that it’s overheating, and does thermal shutdowns around 60 Celcius. (usually happens a few minutes into playing any game) 5.12 kernel is supposed to help [1,2], but until then I want to set /sys/class/thermal/thermal_zone/mode* to disabled. I can easily do this with the following command:

echo “disabled” | sudo tee /sys/class/thermal/thermal_zone*/mode

This fixes my thermal shutdown issues very nicely when used in combination with latest version of thermald. In order to persist this value, I tried adding it to the superuser crontab. Unfortunately it did not help:

$ sudo crontab -l
@reboot echo “disabled” | sudo tee /sys/class/thermal/thermal_zone*/mode

Despite the crontab the value is always enabled after each boot. Any ideas on what’s switching this back and how I can make the change persist?

[1] Bug #1873083 “Lenovo Yoga C940 frequently does thermal shutdown” : Bugs : linux package : Ubuntu
[2] Lenovo IdeaPad Improvements En Route To Linux 5.12 - Phoronix

Hi @mynewlaptop :wink:

That can be made with udev rules… i explain it on my machine…

I run

 udevadm info -a /sys/class/thermal/thermal_zone0/

and get

Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

  looking at device '/devices/virtual/thermal/thermal_zone0':
    KERNEL=="thermal_zone0"
    SUBSYSTEM=="thermal"
    DRIVER==""
    ATTR{available_policies}=="power_allocator user_space step_wise bang_bang fair_share "
    ATTR{cdev0_trip_point}=="2"
    ATTR{cdev0_weight}=="0"
    ATTR{cdev1_trip_point}=="2"
    ATTR{cdev1_weight}=="0"
    ATTR{mode}=="enabled"
    ATTR{policy}=="step_wise"
    ATTR{power/async}=="disabled"
    ATTR{power/control}=="auto"
    ATTR{power/runtime_active_kids}=="0"
    ATTR{power/runtime_active_time}=="0"
    ATTR{power/runtime_enabled}=="disabled"
    ATTR{power/runtime_status}=="unsupported"
    ATTR{power/runtime_suspended_time}=="0"
    ATTR{power/runtime_usage}=="0"
    ATTR{temp}=="36000"
    ATTR{trip_point_0_temp}=="90000"
    ATTR{trip_point_0_type}=="critical"
    ATTR{trip_point_1_temp}=="85000"
    ATTR{trip_point_1_type}=="hot"
    ATTR{trip_point_2_temp}=="85000"
    ATTR{trip_point_2_type}=="passive"
    ATTR{type}=="acpitz"

Now i create a file in /etc/udev/rules.d/ lets say 10-thermalmode.rules:

sudo nano  /etc/udev/rules.d/10-thermalmode.rules

Then i put this into it:

ACTION="add|change" KERNEL=="thermal_zone0" SUBSYSTEM=="thermal"  ATTR{mode}=="disabled"

Now on every boot it toggles to disabled…

This way you can change it permanently.

More information for example here:

https://wiki.archlinux.org/index.php/Udev

4 Likes

Thanks @megavolt for the great answer! The Manjaro community is awesome!

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.