[How-To] Spin-down hard drives with hd-idle

  • INTRODUCTION

    If you like to spin-down your hard drives but you’re having trouble in doing so, you’re not alone.


    Not all hard drives like hdparm, the utility used by Debian and OpenMediaVault. There’s an alternative called hd-idle which does the job but introduces another issue: it will eventually fail if you use standby/hibernation on your server, plus other inconveniences.


    Hd-idle has been abandoned many years ago and was left in a buggy state, but we finally have a solution: a re-implementation of hd-idle with this bug fixed, along with many other improvements.


    CREDITS

    This guide would not exist without _Michael_ and his work in the original thread about hd-idle.


    Thanks to adelolmo on Github for rewriting and keeping hd-idle alive.

    INSTALLATION

    The new hd-idle can be installed in two ways: via an external repository or manually. I recommend the repository approach because it’s easier and will keep the program updated when you’ll run omv-update.


    REPOSITORY INSTALL

    Follow the instructions posted by the developer to add his repository:


    Code
    sudo apt-get install apt-transport-https
    wget -O - http://adelolmo.github.io/andoni.delolmo@gmail.com.gpg.key | sudo apt-key add -
    echo "deb http://adelolmo.github.io/$(lsb_release -cs) $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/adelolmo.github.io.list


    Update apt with apt-get update, then you're ready to install hd-idle with apt-get install hd-idle. You don’t have to worry about the old and buggy version that is still in Debian’s repo, apt will install the new version.


    Note: If you manually installed hd-idle and now you want to use the repo, just uninstall the package and start over. The config file should not be removed, but always make a copy before uninstalling.

    MANUAL INSTALL

    Download the latest package, linked here wget https://github.com/adelolmo/hd-idle/releases/download/v1.12/hd-idle_1.12_amd64.deb

    Install the package dpkg -i hd-idle_1.12_amd64.deb



    CONFIGURATION OPTIONS

    Before you begin, disable any spin-down in the OMV Web interface. Browse to Storage > Disks, edit each disks and ensure

    • Spindown time is set to Disabled
    • Advanced Power Management is set between 128 and 255. Lower values may interfere with hd-idle.


    The configuration file is placed in /etc/default/hd-idle. Edit this file with your favourite file editor.


    There's a lot to be said about hd-idle but this guide will only cover the basics. Check out the full documentation here.


    To actually enable hd-idle, change START_HD_IDLE=false to START_HD_IDLE=true.

    The default (commented) configuration is very simple:

    Code
    HD_IDLE_OPTS="-i 180 -l /var/log/hd-idle.log”
    • -i 180 sets the spin-down time in seconds
    • -l /var/log/hd-idle.log sets the log location, which is optional

    When using this configuration, all drives will be put in spin-down after 3 minutes of inactivity. It’s a bit aggressive: I would rather use a more conventional amount of 20 minutes (1200 seconds) to avoid stressing your drives.


    You may still want to use a short spin-down time if you have a very very very inactive drive such as a SnapRAID parity drive that is woken up only once per day for the sync job. If this is the case, you can further customize the configuration by using disk UUID or label. Do not use device name (eg:/dev/sda1) because they can change and things can get messy.


    Code
    HD_IDLE_OPTS="-i 0 -a /dev/disk/by-label/HDD1 -i 180 -a /dev/disk/by-label/HDD2 -i 1200 -a /dev/disk/by-label/HDD3 -i 1200 -l /var/log/hd-idle.log"

    In this example I've set the spindown time for HDD1 to 3 minutes, and other drives to 20.

    Trick: use the parameter -i 0 at the beginning (like above) to disable spin-down of not explicitly specified HDDs.


    LOGROTATE

    After writing this guide, I suggested to integrate logrotate: has been added in version 1.14.

    Just enable logs in your hd-idle config.


    What follows is the original section for archival purposes.


    SERVICE SETUP

    • Run this command to enable the new hd-idle at boot systemctl enable hd-idle
    • Run this command to start hd-idle right away systemctl start hd-idle


    If you get the error service is masked when trying to configure hd-idle, run the following commands

    Code
    systemctl unmask hd-idle
    systemctl start hd-idle
    systemctl enable hd-idle


    CONCLUSION

    You're ready to finally enjoy hard disk spin down! (done properly)

    Please note the full hd-idle documentation is available here. The new developer has done a great job explaining configuration options and log entries.


    If you need help with hd-idle, please write a post in the original discussion since you can't reply to this guide.

    OMV BUILD - MY NAS KILLER - OMV 5.x + omvextrasorg


    Core i3-8300 - ASRock H370M-ITX/ac - 8GB RAM - Sandisk Ultra Flair 32GB (OMV), 256GB NVME SSD (Docker), 3x4TB HDD (Data) - Fractal Design Node 304 - Be quiet! Pure Power 11 350W

    Edited 2 times, last by auanasgheps: manual logrotate is no longer required ().

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!