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.
Thanks to adelolmo on Github for rewriting and keeping hd-idle alive.
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.
Follow the instructions posted by the developer to add his repository:
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.
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
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:
- -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.
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.
I recommend enabling the log because can help troubleshooting if your server’s drives don’t sleep.
However the log can grow a lot over time but logrotate can solve this problem.
NOTE: This new version of hd-idle also writes spin-down/wake-up events in syslog.
Browse to /etc/logrotate.d/ and create a new file called hd-idle containing
Logrotate will pick up the new configuration automatically.
- 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
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.