USB HDD always spin down after few minutes

  • Hi.

    I'm using version 13 night builds on my GMKtec G3 Plus (version 12 doesn's work on my box).

    I have an USB hard drive connected via USB and have no problem in general but when I pause a movie or anything I'm watching for just few minutes, HDD spins down.

    I tried to use hdparm in autostart.sh with this command: "hdparm -S 0 /dev/sda2" and also "/usr/bin/hdparm -S /dev/sda2" but with no luck: if I pause my watching, HDD spins down, always.

    If I open a shell (ssh) and run the command "hdparm -S 0 /dev/sda2" when HDD is down then it resumes so, I guess, the command is correct but when inserted in autostart.sh it doesn't work.

    If I shutdown LibreElec keeping HDD on it never spins down so I guess it's LibreElec that somehow spins HDD down in some way.

    What am I doing wrong? Is there anything else I can do to avoid the spinning down of my HDD after few minutes?

    Thanks a lot,

    Michele.

    Edited 2 times, last by myksto (July 7, 2025 at 4:20 PM).

  • Update the script to use /dev/sda and see if that resolves the issue? - the hdparm command targets a disk device and /dev/sda2 is a partition on a disk, not the disk.

  • I'll give it a try late in the evening.

    The thing that looks stange to me is the fact that if I lunch the command "hdparm -S 0 /dev/sda2" from an SSH shell when the HDD is sleeping then it start to spin up immediately.

    Thanks a lot for your advice.

  • Not working, modified script in "hdparm -S 0 /dev/sda", rebooted and after few minutes HDD spins down.

    I noted one thing, if I launch the command "hdparm -S 0 /dev/sda" from an SSH shell HDD spins UP and "Setting StanBy to 0 (off)" appears on console but after few minutes HDD spins down again.

    I really don't undestand what's going on. This is the third HDD I try and with all of them I have the same result. This must something inside LibreElec or its operative system.

    Any other idea?

  • I have an USB hard drive connected via USB and have no problem in general but when I pause a movie or anything I'm watching for just few minutes, HDD spins down.

    Most users prefer that behavior. So in general it's not a bug, but a feature. :saint:

    I tried to use hdparm in autostart.sh with this command: "hdparm -S 0 /dev/sda2" and also "/usr/bin/hdparm -S /dev/sda2" but with no luck: if I pause my watching, HDD spins down, always.

    The thing that looks stange to me is the fact that if I lunch the command "hdparm -S 0 /dev/sda2" from an SSH shell when the HDD is sleeping then it start to spin up immediately.

    The above facts result in the conclusion that your HDD firmware does the energy management, not LE.

    • The HDD firmware spins down whenever idle in mounted mode.
    • The HDD firmware takes hdparm as an abstract task, and spins up without further command interpretation.
  • Hi and thanks for your reply.

    Quote

    So in general it's not a bug, but a feature. :saint:

    I can in general agree with you but the fact that HDD spins down after 2-3 minutes as soon as I pause a movie it's not a feature but an annoyance, at least for me. It would be different if HDD would stop after say 10 or more minutes.

    Quote

    The above facts result in the conclusion that your HDD firmware does the energy management, not LE.

    • The HDD firmware spins down whenever idle in mounted mode.
    • The HDD firmware takes hdparm as an abstract task, and spins up without further command interpretation.

    I would not be so sure of that. If it's the firmware that spins down the HDD, why that firmware does not spin HDD down when LibreElec is off?

    Then I don't event think it's not a HDD type matter because I tried with 3 different HDD (and one of them is very very old): the behavouir is the same for all.

    Anyway, if hdparm does not seem to be working, what else I can do to control my HDD power management with LibreElec?

    Thanks a lot, Michele.

    Edited 3 times, last by myksto (July 9, 2025 at 9:35 AM).

  • I tried to use hdparm in autostart.sh with this command: "hdparm -S 0 /dev/sda2" and also "/usr/bin/hdparm -S /dev/sda2" but with no luck: if I pause my watching, HDD spins down, always.

    The first example should fail because the script is not providing the full path to hdparm and is addressing a partition not a disk.

    The second example should fail because the script is providing an incorrect path to hdparm and addressing a partition not a disk.

    Even if you corrected to /dev/sda as per my previous suggestion, you're still going to fail on the first points above.

    The correct path is /usr/sbin/hdparm not /usr/bin/hdparm

  • The first example should fail because the script is not providing the full path to hdparm and is addressing a partition not a disk.

    The second example should fail because the script is providing an incorrect path to hdparm and addressing a partition not a disk.

    Even if you corrected to /dev/sda as per my previous suggestion, you're still going to fail on the first points above.

    The correct path is /usr/sbin/hdparm not /usr/bin/hdparm

    I beg your pardon but it was my typo, the path I used is /usr/sbin/hdparm.

    Anyway I think the problem is not there.

    I wrote before:

    I noted one thing, if I launch the command "hdparm -S 0 /dev/sda" from an SSH shell, HDD spins UP and "Setting StandBy to 0 (off)" appears on console but after few minutes HDD spins down again.

    It seems hdparm can't manage HDD power management even when launched directly through shell

  • Check the support pages of your drive manufacturer. eg with external WD drives you have to use WD Drive Utilities on Windows to configure the sleep timer.

    I'm have connected a 14TB WD MyBook and a 4TB WD MyPassport here on my RPi5 and both power down after half an hour of inactivity (that's the default sleep timer config of those drives).

    If the drives don't shut down after shutdown check your BIOS settings and see if you can find an option to cut power to the USB ports after shutdown (disabling wake-on-USB might help, too).

    I've also seen some USB hubs to interfere with spindown after shutdown, so if you use one also try with the drive connected directly to your PC.

    so long,

    Hias

  • Unfortunately no useful BIOS setting for USB power or something of that kind.

    BIOS is new (2023) but has few settings for USB.

    Check the support pages of your drive manufacturer. eg with external WD drives you have to use WD Drive Utilities on Windows to configure the sleep timer.

    I could check support pages yes but I tried with 3 different HDD: WD-RED 12TB, SEAGATE BARRACUDA 8TB, HITACHI DESKTAR 3 TB and all of them have the same "problem": when I pause a movie from LibreElec HDD spins down after few minutes.

    Any other helpful hint?

    Thanks.

  • I could check support pages yes but I tried with 3 different HDD: WD-RED 12TB, SEAGATE BARRACUDA 8TB, HITACHI DESKTAR 3 TB and all of them have the same "problem": when I pause a movie from LibreElec HDD spins down after few minutes.

    These are all internal, not external drives.

    Which enclosure are you using? Check with the manufacturer of the enclosure, very often (and in your case very likely) it'll be the USB-SATA controller in the enclosure that's responsible for the spindown.

    so long,

    Hias

  • There is an hd-idle command, which is provided by the System Tools add-on:

    elonesna
    July 8, 2023 at 9:03 AM

    It also generates a log file, so maybe helpful for further investigations.