Hello,
when the system is suspended and resumed, hd-idle does not work correctly.
In case a disk is running during suspend, it will be immediately suspended after system resume, if the time passed is longer than the idle timeout.
More seriously, any disk that is in spun_down state during system suspend will be active (run) after the resume. But hd-idle still assumes it is spun_down and will never spin it down from this point onwards.
My solution is to just restart the hd-idle service on suspend/resume.
This is for Ubuntu 16.04 with systemd. Systemd automatically manages the /etc/init.d/hd-idle as a service.
I have created a new systemd-unit that restarts the hd-idle service, see attachment. It needs to be put into
/etc/systemd/system/
and must be activated with the command
systemctl enable hd-idle-restart-resume.service
(I guess debhelper will care for this to be added to postinst)
I created a patch to address the resume issue. The approach taken here is to identify if the sleep took longer than expected and reset the spum_down flag if we waited too long for the main loop sleep. This should capture suspend events as well as excessive machine load.
I also added a few more log functions (included in the patch). Perhaps the logging could be revised as a separate thread, or employ syslog if your platform environment includes syslog?