Fan settings not applied on boot/restart

  • DietPi version |
    G_DIETPI_VERSION_CORE=8
    G_DIETPI_VERSION_SUB=8
    G_DIETPI_VERSION_RC=1
    G_GITBRANCH=‘master’
    G_GITOWNER=‘MichaIng’

  • Distro version |
    bullseye

  • Kernel version |
    5.4.199-odroidxu4 #22.05.3 SMP PREEMPT Wed Jun 22 07:29:40 UTC 2022 armv7l GNU/Linux

  • SBC model |
    Odroid XU4

The stock fan speed settings make the Odroid quiet, which is perfect, but since I need to squeeze some juice out of the device, having it get hot all the time is not ideal.
So I wanted to set a more “aggressive” policy on the fan, so I used this script graciously provided by Michalng: DietPi/dietpi-fan_control at master · MichaIng/DietPi · GitHub

Tried to set the fan speed according to CPU temperature. For some reason, no matter what values are entered, it keeps spitting out “Invalid settings found” error.
So I’ve set it to constant speed, and it works like a charm, even though it’s not ideal.

However, rebooting the SBC, DietPi reverts back to the previous settings.

Does anyone know where I can look into as to what’s causing the settings to revert or what can be done to fix this?

The script is not really ready for operation and should not be used. It was an attempt but has not been released yet as it did not cover all devices and all type of system.

Understandable, but since the always-on fan setting works, could you let me know how I could make it permanent?

You could set up a systemd service that runs the script at boot.

Make sure the script is executable:

chmod +x /usr/bin/always-on_fan.sh

Create a Unit file to define a systemd service:

nano /etc/systemd/system/always-on_fan.service

[Unit]
Description=always-on_fan systemd service.

[Service]
Type=simple
ExecStart=/bin/bash /usr/bin/always-on_fan.sh

[Install]
WantedBy=multi-user.target

Give it permissions:

chmod 644 /etc/systemd/always-on_fan.service

Start and enable the service:

systemctl start always-on_fan.service
systemctl enable always-on_fan.service

:man_shrugging: Something like that! Give it a reboot and see if the fan starts up. If not check systemctl status always-on_fan or journalctl -u always-on_fan to see if you can debug any error messages you find.

1 Like

Thank you for the suggestion @BluishHumility, I tried it, but the same default settings are applied regardless.
Checked the status of the service:

$ sudo systemctl status dietpi-fan-control.service 
● dietpi-fan-control.service - dietpi-fan-control systemd service.
     Loaded: loaded (/etc/systemd/system/dietpi-fan-control.service; enabled; vendor preset: enabled)
     Active: inactive (dead) since Mon 2022-09-19 12:53:36 EEST; 6min ago
    Process: 356 ExecStart=/bin/bash /usr/bin/dietpi-fan_control (code=exited, status=0/SUCCESS)
   Main PID: 356 (code=exited, status=0/SUCCESS)
        CPU: 158ms

Sep 19 12:53:36 Server systemd[1]: Started dietpi-fan-control systemd service..
Sep 19 12:53:36 Server systemd[1]: dietpi-fan-control.service: Succeeded.

Since the bash script launches a CLI interface much like the dietpi-software script does, I don’t think this can be used as a service. Perhaps if I use only the part of it that applies the settings in the service, that might work?
Since my knowledge of bash is worse than the one for french, I’m not sure which part(s) I should take out.

Could @MichaIng perhaps add his input on this?

What did you put in usr/bin/always-on_fan.sh?
You could have just a look into the fan script to see what it does and to which paths it is writing something.
Also it’s worth having a look here:
https://wiki.odroid.com/odroid-xu4/application_note/manually_control_the_fan

If the script has a proper shebang, remove the /bin/bash from the ExecStart.

And since it does not run forever, you can switch to Type=oneshot.

However, generally it should work, as long as the script has no interactive part.

Probably it runs too early? Then try adding After=multi-user.target to the [Unit] section.

And of course check logs:

journalctl -u always-on_fan
1 Like

Alright, followed your corrections, and also took a look at the script itself in an attempt to remove the interactive parts with the best of my knowledge, but noticed there’s an “1” argument for the script that applies settings non-interactively, so I added that to the ExecStart line. That seems to have done the trick, now it all works as intended!
Thank you guys for the help and for having patience with me!

Here’s how my service looks like currently, if anyone has the same problem as me:

[Unit]
Description=dietpi-fan-control systemd service.
After=multi-user.target

[Service]
Type=oneshot
ExecStart=/usr/bin/dietpi-fan_control 1

[Install]
WantedBy=multi-user.target
2 Likes

Ah right, that is indeed what many of our scripts have in common.