Fancontrol relies on the module load order

Bug #576602 reported by Lars Volker
90
This bug affects 19 people
Affects Status Importance Assigned to Milestone
lm-sensors
New
Unknown
lm-sensors-3 (Ubuntu)
Triaged
Medium
Unassigned

Bug Description

Fancontrol can't handle the fact that pathnames of the hwmon directories might change if modules get loaded in a different order during boot. The following error messages appear:

Device path of hwmon1 has changed
Device path of hwmon2 has changed
Device name of hwmon1 has changed
Device name of hwmon2 has changed
Configuration appears to be outdated, please run pwmconfig again

ProblemType: Bug
DistroRelease: Ubuntu 10.04
Package: fancontrol 1:3.1.2-2
ProcVersionSignature: Ubuntu 2.6.32-21.32-generic 2.6.32.11+drm33.2
Uname: Linux 2.6.32-21-generic x86_64
Architecture: amd64
Date: Thu May 6 21:48:07 2010
InstallationMedia: Xubuntu 10.04 LTS "Lucid Lynx" - Release amd64 (20100427.1)
PackageArchitecture: all
ProcEnviron:
 LANG=de_DE.utf8
 SHELL=/bin/bash
SourcePackage: lm-sensors-3

Revision history for this message
Lars Volker (lv) wrote :
Revision history for this message
Charlie Kravetz (charlie-tca) wrote :

Thank you for taking the time to report this bug and helping to make Ubuntu better. The issue that you reported is one that should be reproducible with the live environment of the Desktop CD of the development release - Maverick Meerkat. It would help us greatly if you could test with it so we can work on getting it fixed in the next release of Ubuntu. You can find out more about the development release at http://www.ubuntu.com/testing/ . Thanks again and we appreciate your help.

Changed in lm-sensors-3 (Ubuntu):
status: New → Incomplete
Revision history for this message
Vk (flo74970) wrote :

Sorry for my english i'm french ^

i've done a starting script in init.d for fancontrol to handle the different configurations :

First create fancontrol, fancontrol1, fancontrol2 configuration files for fancontrol with different configurations you can have (you can have only two or more than three conf files)

then here is the script :

*********************************************
#!/bin/sh
#
# Fancontrol start script.
#

set -e

# Defaults
DAEMON=/usr/sbin/fancontrol
PIDFILE=/var/run/fancontrol.pid
PATH=/sbin:/bin:/usr/sbin:/usr/bin
CONFIG1=/etc/fancontol
CONFIG2=/etc/fancontol1
CONFIG3=/etc/fancontol2

test -f $DAEMON || exit 0

. /lib/lsb/init-functions

case "$1" in
        start)
                log_begin_msg "Starting fancontrol config 1..."
                start-stop-daemon --start -o -b -p $PIDFILE -x $DAEMON $CONFIG2
  log_end_msg $?
  sleep 1
                if start-stop-daemon --stop -q -p $PIDFILE ; then
                log_success_msg "redémarrage configuration ok1"
  start-stop-daemon --start -o -b -p $PIDFILE -x $DAEMON $CONFIG2
                log_end_msg $?
  exit 0
  else
  rm -f $PIDFILE
  fi

  log_begin_msg "Starting fancontrol config 2..."
                start-stop-daemon --start -o -b -p $PIDFILE -x $DAEMON $CONFIG1
  log_end_msg $?
  sleep 1
                if start-stop-daemon --stop -q -p $PIDFILE ; then
                log_success_msg "redémarrage configuration ok2"
  start-stop-daemon --start -o -b -p $PIDFILE -x $DAEMON $CONFIG1
                log_end_msg $?
  exit 0
  else
  rm -f $PIDFILE
  fi

  log_begin_msg "Starting fancontrol config 3..."
                start-stop-daemon --start -o -b -p $PIDFILE -x $DAEMON $CONFIG3
  log_end_msg $?
  sleep 1
                if start-stop-daemon --stop -q -p $PIDFILE ; then
                log_success_msg "redémarrage configuration ok3"
  start-stop-daemon --start -o -b -p $PIDFILE -x $DAEMON $CONFIG3
                log_end_msg $?
  exit 0
  else
  rm -f $PIDFILE
  fi
                ;;
        stop)
                log_begin_msg "Stopping fancontrol daemon..."
                start-stop-daemon --stop -o -q -p $PIDFILE
                log_end_msg $?
                rm -f $PIDFILE
  ;;
        force-reload|restart)
                sh $0 stop
                sh $0 start
                ;;
        *)
                log_success_msg "Usage: /etc/init.d/fancontrol {start|stop|restart|force-reload}"
                log_success_msg " start - starts system-wide fancontrol service"
                log_success_msg " stop - stops system-wide fancontrol service"
                log_success_msg " restart, force-reload - starts a new system-wide fancontrol service"
                exit 1
                ;;
esac

exit 0
**************************************

For now then fancontrol daemon always starts without fails....
Hope this could be useful for others
With only one week of linux practice, i'm proud of this script ! ^^

Revision history for this message
Vk (flo74970) wrote :

for an unknomw reason, my script is not working anymore, the parameters files are not given to fancontrol, taking /etc/fancontrol all the times

Here is a script to avoid this problem :

#!/bin/sh
#
# Fancontrol start script.
#

set -e

# Defaults
DAEMON=/usr/sbin/fancontrol
PIDFILE=/var/run/fancontrol.pid
PATH=/sbin:/bin:/usr/sbin:/usr/bin

test -f $DAEMON || exit 0

. /lib/lsb/init-functions

case "$1" in
        start)
  cp /etc/fancontrol1 /etc/fancontrol
                log_begin_msg "Starting fancontrol config 1..."
                start-stop-daemon --start -b -p $PIDFILE -x $DAEMON
  log_end_msg $?
  sleep 1
                if start-stop-daemon --stop -q -p $PIDFILE ; then
                log_success_msg "redémarrage configuration ok1"
  start-stop-daemon --start -b -p $PIDFILE -x $DAEMON
                log_end_msg $?
  exit 0
  else
  rm -f $PIDFILE
  fi

  cp /etc/fancontrol2 /etc/fancontrol
  log_begin_msg "Starting fancontrol config 2..."
                start-stop-daemon --start -b -p $PIDFILE -x $DAEMON
  log_end_msg $?
  sleep 1
                if start-stop-daemon --stop -q -p $PIDFILE ; then
                log_success_msg "redémarrage configuration ok2"
  start-stop-daemon --start -b -p $PIDFILE -x $DAEMON
                log_end_msg $?
  exit 0
  else
  rm -f $PIDFILE
  fi

  cp /etc/fancontrol3 /etc/fancontrol
  log_begin_msg "Starting fancontrol config 3..."
                start-stop-daemon --start -b -p $PIDFILE -x $DAEMON
  log_end_msg $?
  sleep 1
                if start-stop-daemon --stop -q -p $PIDFILE ; then
                log_success_msg "redémarrage configuration ok3"
  start-stop-daemon --start -b -p $PIDFILE -x $DAEMON
                log_end_msg $?
  exit 0
  else
  rm -f $PIDFILE
  fi

  cp /etc/fancontrol4 /etc/fancontrol
  log_begin_msg "Starting fancontrol config 4..."
                start-stop-daemon --start -b -p $PIDFILE -x $DAEMON
  log_end_msg $?
  sleep 1
                if start-stop-daemon --stop -q -p $PIDFILE ; then
                log_success_msg "redémarrage configuration ok4"
  start-stop-daemon --start -b -p $PIDFILE -x $DAEMON
                log_end_msg $?
  exit 0
  else
  log_success_msg "échec démarrage fancontrol"
  rm -f $PIDFILE
  fi
                ;;
        stop)
                log_begin_msg "Stopping fancontrol daemon..."
                start-stop-daemon --stop -o -q -p $PIDFILE
                log_end_msg $?
                rm -f $PIDFILE
  ;;
        force-reload|restart)
                sh $0 stop
                sh $0 start
                ;;
        *)
                log_success_msg "Usage: /etc/init.d/fancontrol {start|stop|restart|force-reload}"
                log_success_msg " start - starts system-wide fancontrol service"
                log_success_msg " stop - stops system-wide fancontrol service"
                log_success_msg " restart, force-reload - starts a new system-wide fancontrol service"
                exit 1
                ;;
esac

exit 0

Revision history for this message
Vk (flo74970) wrote :

here is an enhanced script (no need to stop daemon to be sure that it works)

************************************************
#!/bin/sh
#
# Fancontrol start script.
#

set -e

# Defaults
DAEMON=/usr/sbin/fancontrol
PIDFILE=/var/run/fancontrol.pid
PATH=/sbin:/bin:/usr/sbin:/usr/bin

test -f $DAEMON || exit 0

. /lib/lsb/init-functions

case "$1" in
        start)
  cp /etc/fancontrol1 /etc/fancontrol
                log_begin_msg "Starting fancontrol config 1..."
                start-stop-daemon --start -b -p $PIDFILE -x $DAEMON
  log_end_msg $?
  sleep 1
         if [ ! -f $PIDFILE ]
         then
                log_success_msg "Erreur de configuration"
         else
  log_success_msg "Démarrage ok"
                exit 0
         fi

  cp /etc/fancontrol2 /etc/fancontrol
  log_begin_msg "Starting fancontrol config 2..."
                start-stop-daemon --start -b -p $PIDFILE -x $DAEMON
  log_end_msg $?
  sleep 1
         if [ ! -f $PIDFILE ]
         then
                log_success_msg "Erreur de configuration"
         else
  log_success_msg "Démarrage ok"
                exit 0
         fi

  cp /etc/fancontrol3 /etc/fancontrol
  log_begin_msg "Starting fancontrol config 3..."
                start-stop-daemon --start -b -p $PIDFILE -x $DAEMON
  log_end_msg $?
  sleep 1
         if [ ! -f $PIDFILE ]
         then
                log_success_msg "Erreur de configuration"
         else
  log_success_msg "Démarrage ok"
                exit 0
         fi

  cp /etc/fancontrol4 /etc/fancontrol
  log_begin_msg "Starting fancontrol config 4..."
                start-stop-daemon --start -b -p $PIDFILE -x $DAEMON
  log_end_msg $?
  sleep 1
         if [ ! -f $PIDFILE ]
         then
                log_success_msg "Erreur de configuration"
         else
  log_success_msg "Démarrage ok"
                exit 0
         fi

                ;;
        stop)
                log_begin_msg "Stopping fancontrol daemon..."
                start-stop-daemon --stop -o -q -p $PIDFILE
                log_end_msg $?
                rm -f $PIDFILE
  ;;
        force-reload|restart)
                sh $0 stop
                sh $0 start
                ;;
        *)
                log_success_msg "Usage: /etc/init.d/fancontrol {start|stop|restart|force-reload}"
                log_success_msg " start - starts system-wide fancontrol service"
                log_success_msg " stop - stops system-wide fancontrol service"
                log_success_msg " restart, force-reload - starts a new system-wide fancontrol service"
                exit 1
                ;;
esac

exit 0
********************************************************

Revision history for this message
Charlie Kravetz (charlie-tca) wrote :

Thank you for the above scripts. However, it would be better to attach them as plain text files using the "Add attachment or patch" button below. This would then allow the users to download them and place them in the necessary directories for use. Also, what directory should these scripts be used in?

Revision history for this message
Vk (flo74970) wrote :

Ok my apologies, i'll post it as text next times...

As i wrote, those scripts are located in /etc/init.d/ in order to be ran at boot time (use console utils to configure symbolics in states)

Revision history for this message
Charlie Kravetz (charlie-tca) wrote :

Thanks for the response and documentation. Since this bug has enough information provided for a developer to begin work, I'm going to mark it as confirmed and let them handle it from here. Thanks for taking the time to make Ubuntu better!

Changed in lm-sensors-3 (Ubuntu):
importance: Undecided → Medium
status: Incomplete → Triaged
Revision history for this message
rcs-34 (vaclav-kocian-gmail) wrote :

Hi, it is almost 2 years, since VK have posted the modified start/stop script, which works perfectly (tnhank you much VK). Is there any plan to fix the bug? Now I have installed Ubuntu 12.04 and it is still there.

Revision history for this message
Alex (alexkist) wrote :

Hi,
I had the same problem with fancontrol in 12.04.
VK's modified script works perfectly. Thanks

Revision history for this message
David (kosirdavid) wrote :

I can confirm same bug in 12.10 64bit.

Revision history for this message
Paul Crawford (psc-sat) wrote :

Same problem here with 64-bit 12.04.

It seems to be a rather basic flaw in the underlying design that the 'hwmon0' sort of name used is load-order-dependent for the modules. Can't that ordering be made alphabetical or similar so without a hardware/configuration change it is fixed?

My solution was to add the k10temp module to the one of the blacklists in /etc/modprobe.d/ and then add it to /etc/modules before the w83627ehf module that provides the PWM control. Hopefully it will always load the modules in the order specified by /etc/modules.

Revision history for this message
Thomas Debesse (illwieckz) wrote :

Same problem here with Ubuntu 13.4

To solve the problem I launch pwmconfig, and search those lines (may differ on your computer) :

____________________________________________
[…]
Found the following devices:
   hwmon0/device is it8721
   hwmon1/device is k10temp
   hwmon2/device is fam15h_power
[…]
____________________________________________

Then I write (as root) a config file named /etc/modprobe.d/fancontrol.conf with this content (modules names can differ a little to names given by pwmconfig, use lsmod to find them) :

____________________________________________
softdep fam15h_power pre:k10temp
softdep k10temp pre: it87
____________________________________________

Then I rebuild initramfs

____________________________________________
root@ubuntu # update-initramfs -k all -u
[…]
____________________________________________

At boot time, fam15h_power module can't be loaded before k10temp module, and k10temp module can't be loaded before it87 module. It forces module load order.

Revision history for this message
Thomas Debesse (illwieckz) wrote :

To rectify, don't forget to put a space before *and* after the keyword 'pre:'

You can test the workaround in this way (adapt with your modules names):

Checks that the modules are loaded:

root@ubuntu ~ # lsmod | grep '^it87\|^k10temp\|^fam15h_power' | cut -f1 -d' '
fam15h_power
k10temp
it87

Removes all modules:

root@ubuntu ~ # modprobe -r it87 k10temp fam15h_power

Checks that all modules are unloaded:

root@ubuntu ~ # lsmod | grep '^it87\|^k10temp\|^fam15h_power' | cut -f1 -d' '
[nothing]

Load the module to be loaded first:

root@ubuntu ~ # modprobe it87

Checks that it is alone:

root@ubuntu ~ # lsmod | grep '^it87\|^k10temp\|^fam15h_power' | cut -f1 -d' '
it87

Remove this module:

root@ubuntu ~ # modprobe -r it87

Checks that all modules are unloaded:

root@ubuntu ~ # lsmod | grep '^it87\|^k10temp\|^fam15h_power' | cut -f1 -d' '
[nothing]

Load the module to be loaded last:

root@ubuntu ~ # modprobe fam15h_power

Checks that all the other modules are loaded:

root@ubuntu ~ # lsmod | grep '^it87\|^k10temp\|^fam15h_power' | cut -f1 -d' '
fam15h_power
k10temp
it87

You can adapt this workaround to your computer, this is better than "blacklisting a module to load it succesfully", otherwise in a few years when you read your code you do not understand what it will mean. :)

Revision history for this message
Paul Crawford (psc-sat) wrote :

Thanks Thomas, that is a much better work-around method!

Revision history for this message
Darxus (darxus) wrote :

This problem still exists in ubuntu 20.04.

It looks like a good solution to this problem would be to use the contents of /sys/class/hwmon/hwmon*/name instead of the hwmon device number. fancontrol uses these name files to do the verification that results in the errors in this bug report.

I used Thomas's workaround, it worked.

My module order was slightly more complicated, because I had additional devices involved in the random ordering. I added softdeps for all of them:

$ grep -H . /sys/class/hwmon/hwmon*/name
/sys/class/hwmon/hwmon0/name:amdgpu
/sys/class/hwmon/hwmon1/name:nct6798
/sys/class/hwmon/hwmon2/name:k10temp
/sys/class/hwmon/hwmon3/name:hidpp_battery_0
/sys/class/hwmon/hwmon4/name:asus

# cat /etc/modprobe.d/fancontrol.conf
softdep nct6775 pre: amdgpu
softdep k10temp pre: nct6775
softdep asus_wmi pre: k10temp
softdep hid_logitech_hidpp pre: k10temp

To figure out which devices it wants to have which numbers, look at:
# grep DEVNAME /etc/fancontrol
DEVNAME=hwmon1=nct6798 hwmon2=k10temp

My motherboard is an Asus TUF X570. I am not entirely certain that I got the right modules for the asus and hidpp_battery_0 hwmon devices.

fancontrol and pwmconfig are in the fancontrol package. Upstream is https://hwmon.wiki.kernel.org/lm_sensors
The download link on that page is a git archive which does contain fancontrol and pwmconfig.

There is an upstream mailing list and IRC channel:
https://hwmon.wiki.kernel.org/feedbackandsupport

Revision history for this message
Darxus (darxus) wrote :

Upstream bug, which would fix this: https://github.com/lm-sensors/lm-sensors/issues/227

Changed in lmsensors:
status: Unknown → New
Revision history for this message
Ronny Svedman (ronny-ronnysvedman) wrote :

This affects me too on Asus z97P, since at least ubuntu 13.10 (when I bought this system). I sometimes hear fans not spin down after booting, and have been "rebooting until success" for the last 7 years... lucky it isnt too often I get the wrong order, maybe once in 10 boots or so. Since adding a new GPU recently made this problem worse, and I needed the it87 driver compiled from unofficial sources to support my board (IT8606 chip) in 20.04, I stumbled on this bug via the lm-sensors github.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.