HDD not spinning down/idle/sleep

  • Hi everyone,

    Bit of a beginner with LE

    I have installed LE on SD card on an amlogic 905X box. Works perfectly, with the exception that the box no longer lets my external HDD go to sleep/idle/spin down (not sure exactly which term to use but it is still making noise and sounds like the hdd is active even when LE is shutdown).

    Before LE was installed on the SD, i was using KODI on android, and my external hdd would idle/sleep/spin down after a period of time, i also noticed it also does this when plugged into windows.

    I searched this forum for similar posts and found other users being told to use hd-idle, installed from the system tools addon. But even though I located this addon, installed it, i cant find hd-idle or how to use it. I have tryed using putty to get a SSH connection with LE but can't seem to find hd-idle or again how to install or run it through this terminal window.

    Can someone please give me a simple explaination of how to do this, or even how to use something else to enable the external HDD to sleep/idle/spin down after a period of time.

    :)

  • You can use either hd-idle plug in, or make use of internal command "hdparm". In both cases you need to create an "autostart.sh" script file which runs when LE boots.
    Here is the example how to do it with "hdparm" command for HDD name "sda1":

    Get your external HDD name:

    Code
    cat /proc/mounts


    Create/edit autostart script

    Code
    nano /storage/.config/autostart.sh

    Set acoustic and power management functions:

    Code
    hdparm -B 127 -M 254 -S 244 /dev/sda1


    autostart.sh script file should look like this:

    Bash
    #!/bin/sh
    (
    hdparm -B 127 -M 254 -S 244 /dev/sda1
    ) &

    where parameters are:

    -B 127 is the highest power management parameter which allows spin-down
    -M 254 is the fastest head-movement, if you want a more silent HDD, set this lower
    -S is the number that controls the time when to spin down

    Examples:

    1. hdparm -S 60 /dev/sda1 => spindown in 5min
    2. hdparm -S 120 /dev/sda1 => spindown in 10min

    (I use 2. example and am not using -B and -M parameter)

    My autostart.sh:

    Bash
    #!/bin/sh
    (sleep 60;
    hdparm -S 60 /dev/sda1
    )&

    It waits 60sec before it executes (sleep 60) to give enough time for drive to mount.

    If it does not work, check that the autostart.sh script resides in /storage/.config/ folder.

    BTW, you can create/copy (my) autostart.sh on a windows PC using Notepad++ editor, save it as autostart.sh and copy it with LE/Kodi File Manager to SD card /storage/.config/

    Note: if you'll use Notepad++ when saving file choose "Save as" and then choose "Unix script lile .sh" to get proper file format.

    Edited once, last by Sholander (April 4, 2017 at 2:18 PM).

  • Thank you so much! Your post was exactly what I needed, hddparm works a charm. I have the HDD spinning down after 30mins now, and the autostart.sh script is working great (i added that sleep function too)

    Thanks again for taking the time and effort to write such a good response :) :)

    Edited once, last by DMG (April 4, 2017 at 11:15 PM).

  • Question,

    If you already have #!/bin/sh in the Autostart.sh file at the top, do you need to put it again just before the new items you added?

    This #! is a shebang, and it tells the shell what program should be used to interpret the script when executed. -- in this case /bin/sh . If you wanted to use a different program, you could use for instance bash, and hence that line would become #!/bin/bash

    Edited once, last by morfik (August 24, 2020 at 2:07 PM).