Guide: How-to setup 'hd-idle' (a HDD spin down SW) together with the OMV plugin 'Autoshutdown'.

    • OMV 2.x
    • Resolved

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Guide: How-to setup 'hd-idle' (a HDD spin down SW) together with the OMV plugin 'Autoshutdown'.

      Hi,

      I have read an learned a lot during my one week try and error sessions with my new OMV 2.2.13 system (with kernel 3.16.0-0.bpo.4-amd64). After I got my SnapRAID configuration running I tried to fine tune my little system. I was interested in 1) automatic HDD spin down as well as 2) automatic shut down (-> suspend, ACPI S3) after some idle time.
      Topic 1) was for one out of my 3 different Toshiba HDDs not running out of the box, i.e. the related OMV setting in 'Storage -> Physical Disks' was not able to spin down this disk (the used command 'hdparm' is not working). I found then several information in:
      HDD Spindown Probleme (GER)
      which refers to:
      Festplatten in den Standby-Modus versetzen unter Ubuntu Desktop/Server mit hd-idle (GER)
      which refers to:
      hd-idle on sourceforge.net (ENG)
      Out of all these information I wrote these 'how to' steps:

      *** Install 'hd-idle' in OMV (login as 'root' user) ***
      ** 0) install additional 'build / make' files **
      apt-get install debhelper
      apt-get install fakeroot
      apt-get install build-essential

      ** 1) make a download directory **
      mkdir hd-hidle_download
      ** 1.1) enter the directory **
      cd hd-hidle_download


      ** 2) download the 'hd-idle' source package file **
      wget sourceforge.net/projects/hd-idle/files/hd-idle-1.04.tgz
      ** 2.1) extract the package **
      tar xvfz hd-idle*.tgz

      ** 3) enter the extracted 'hd-idle' folder, it is one directory down **
      cd hd-hidle

      ** 4) make the '*.deb' file **
      dpkg-buildpackage -rfakeroot
      ** 4.1) goto the made *.deb file, it is one directory up **
      cd ..

      ** 5) install the '*.deb' file **
      dpkg -i hd-idle_*.deb

      *** 'hd-idle' setup ***
      ** a) disable all spin-down and power management settings in OMV ***
      'Storage -> Physical Disks'

      ** b) open the 'hd-idle' configuration file via the 'nano' editor **
      nano /etc/default/hd-idle
      ** b.1) insert for each HDD (accessed via their UUIDs) a spin-down command '-a /dev/<...> -i 600', e.g. spin-down of 3 HDDs after approx. 600 seconds **
      HD_IDLE_OPTS="-i 0 -a /dev/disk/by-uuid/bacb10a1-6dc5-48b9-a6f4-ed836b7dfa4a -i 600 -a /dev/disk/by-uuid/481b459f-aad7-468e-b0fe-9401c94eb4fc -i 610 -a /dev/disk/by-uuid/3b5e7398-d517-4477-a3b9-aa46c4347184 -i 620"
      * hint: Parameter '-i 0' at the beginning avoids spin-down of not explicitly specified HDDs. *
      ** b.2) allow hd-idle to start **
      START_HD_IDLE=true
      ** b.3) save the file and close 'nano' **

      ** c) via OMV auto-start the 'hd-idle' service (daemon) **
      'System -> Scheduled Jobs'
      * hint: use options 'reboot', user 'root' and command 'service hd-idle start' *

      ** d) do also this if the OMV plug in 'Autoshutdown' is in use **
      sourceforge.net/p/hd-idle/patches/2/
      ** PROBLEM!!! The required 'systemd' service manager is not in use on Debian 7 / OMV 2.x! **

      ** e) reboot OMV, now it should work **

      ** f) Check that 'hd-idle' is running via OMV
      'Diagnostics -> System Information -> Process List'
      ** in column 'Command' should be somewhere such an entry: **
      usr/bin/hd-idle -i 0 -a /dev/<...> -i 620


      Now I stuck with step d) because I'm not really familiar with Linux. The missing task is: How to restart the 'hd-idle' daemon after wakeup from suspend with the OMV 2.x used 'SysVinit'?
      Hint: Without d) the 'hd-idle' service is still running but no longer functional, i.e. no further HDD spin down happens.
      Could somebody help me, please?

      Thank you!

      Michael

      Addendum 1
      After some further tests it seems it has nothing directly to do with the suspend and wake-up:
      hd-idle obviously works in the following way: It reads in some interval from each HDD (or wherever these data are located) its performed reads and writes. If both counter values have not been changed in the defined spin down time (-i parameter) then a spin down will be triggered.
      Problem:
      If the HDDs have been simply restartet due to e.g. a wake-up after a suspend then these counters still deliver the same values as at the time as hd-idle last send them to spin down state. This means 1. hd-idle is NOT aware that the HDDs are no longer in spin down state and 2. a further spin down trigger will never happen due to the not changed counters.
      A workaround would be the above mentioned hd-idle daemon restart after wake-up ... (a read access would also release this blocking state but this is usually no way for the parity HDD in a SnapRAID system).

      The post was edited 4 times, last by _Michael_: Thread State set to 'solved' ().

    • my solution (I don't know if such a file change is a good idea but at least it works):

      ** d) do also this if the OMV plug in 'Autoshutdown' is in use **
      change the file '/etc/pm/sleep.d/autoshutdown-restart' as visible below:

      Shell-Script: autoshutdown-restart

      1. #!/bin/bash
      2. case "$1" in
      3. hibernate|suspend)
      4. #> 2017-01-29, hd-idle workaround, 1 of 2
      5. /etc/init.d/hd-idle stop
      6. #<
      7. logger -s -t "$USER autoshutdown [$$]" "hibernate/suspend: autoshutdown-script stop from /etc/pm/sleep.d/autoshutdown-restart"
      8. /etc/init.d/autoshutdown stop
      9. ;;
      10. thaw|resume)
      11. logger -s -t "$USER autoshutdown [$$]" "thaw/resume: autoshutdown-script restart from /etc/pm/sleep.d/autoshutdown-restart"
      12. /etc/init.d/autoshutdown restart
      13. #> 2017-01-29, hd-idle workaround, 2 of 2
      14. /etc/init.d/hd-idle start
      15. #<
      16. ;;
      17. *)
      18. logger -s -t "$USER autoshutdown [$$]" "other: autoshutdown-script call from /etc/pm/sleep.d/autoshutdown-restart"
      19. ;;
      20. esac
      Display All

      The post was edited 5 times, last by _Michael_ ().

    • hi,

      im having the same problem, only that im using a raspberry pi 3 witz raspbian (jessie). my hdd is an 4 gb wd my book (i think they put greens in it).

      using hdparm hdparm -y works and puts the drive into sleep, hdparm -s xx seems to write something to the drice, at least it sounds like it. after waiting the countdown finished, nothing happens.

      using hd-idle works but the drive starts spinning again after a short while although im pretty sure nothing is reading or writing on the drive, since the hdd stays in standby using hdparm -y.

      if i on the other hand use hd-idle and acces my hdd after spindown the counter seems to work again and hd-idle puts it to sleep after finishing its count down.

      im not sure if it is from any interest but a recognized something else:
      my my book has a led light showing its status: light on means drive is idle, fast blinking means working and slow blinking means standby.
      using hdparm -y the driv shows slow blinking as its supposed to but using hd-idle the led stays on



      im not sure if understand your script. is it stopping and starting hd-idle over and over again so it would recognize the hdd spinning after it woke up and after hd-idle puts it into standby?

      i also saw a solution using a script running hdparm -y avery 30 minutes or so. i tried hdparm -y while copying a file on the hdd and the file was still copying but i could hear my drive when i used hdparm -y. im not sure what it does exactly but i fear it might damage the drive over time.
      this sound was actually similar to the one when using hdparm -s xx



      update:
      when the drive starts spinning again after hd-idle pu it to sleep i cant unmount it via terminal using sudo umount /dev/sda1:

      pi@raspberrypi:~ $ sudo umount /dev/sda1
      umount: /media/pi/66926CEA926CBFE3: target is busy
      (In some cases useful info about processes that
      use the device is found by lsof(8) or fuser(1).)
      pi@raspberrypi:~ $ umount: /media/pi/66926CEA926CBFE3: target is busy
      -bash: umount:: Kommando nicht gefunden.
      pi@raspberrypi:~ $ (In some cases useful info about processes that
      > use the device is found by lsof(8) or fuser(1).)^C
      pi@raspberrypi:~ $


      update 2:
      sudo smartctl -d sat -a /dev/sda shows my load cycle count which increases after i ran hdparm -s xx and waited für xx seconds
      i guess it does just half the job its supposed to

      The post was edited 2 times, last by ennno ().

    • ennno wrote:

      ...
      im not sure if understand your script. is it stopping and starting hd-idle over and over again so it would recognize the hdd spinning after it woke up and after hd-idle puts it into standby?
      ...
      Sorry but I'm sure you have not really understood my problem and my solution for it ... (you have to read my two posts entirely).
      The script 'autoshutdown-restart' (it is from the plugin 'Autoshutdown') does stop the hd-idle daemon at a PC suspend event and starts it (again) at a PC wake-up (resume) event. Because of the new started daemon the current = not changed HDD read / write counters are 'valid' hd-idle start-counter values and a further HDD spin down will be triggered after the timeout period.

      The post was edited 1 time, last by _Michael_: text improved ().