How-To: Vero 4K+ hd-idle install to spin down USB HDD's that otherwise won't

EDIT: Jimmy gave me some great feedback, and I’ve updated the how-to to use the latest version of hd-idle from GIT. Thanks @Jahey! I’ve also included a link to download the hd-idle .deb package I created for OSMC V19/Matrix to save a few steps, for those that would rather skip the compilation bit.

Hi folks,

Yesterday I got my Vero 4K+ (an upgrade from my old RP3 running OSMC) and quickly remembered that one of my two large external HDD’s (a Buffalo) does not obey the usual hdparm commands to spin down after a period of time. As the Vero is designed to be an “always on” box, this was going to be an issue as the drive is quite noisy and would burn unnecessary power (not to mention wear itself out)

When I originally setup my old RP3 with OSMC, I compiled and installed hd-idle to do the job for me and it worked really well. Despite searching the forums here, I was surprised there was no step by step guide for compiling and installing hd-idle on the Vero 4K+ so after spending some time yesterday, I got it working nicely.

I’ve put together the following guide in the hopes that somebody else may find this useful in the future (and save a bit of time). I assume basic knowledge (e.g. how to ssh to the Vero 4K+ and how to copy a file up to the Vero, as well as editing a text file using vi or nano).

The usual caveats apply to the below steps - follow them at your own risk/peril, etc. and whilst they worked perfectly for me, they may cause death, destruction or obliteration of your Vero 4K or HDD’s :smile: :smile: :smile:

The following steps worked for me on my Vero 4K+ running V19 (Matrix)

How to install hd-idle onto the Vero 4K+ to auto-spin down HDD’s (that don’t spin down under default conditions):

(Command are pre-formatted (remove the quotes!) and filenames/config parameters are bold.)

Note: If you’d like to shortcut some steps below, you can download a pre-compiled package of hd-idle that I created for OSMC V19/Matrix from here (SHA256 hash here). You then just need to then upload the file to your Vero (scp or sFTP, etc) and then install it as per Step 8 (replacing the file path with the path to the deb package you uploaded to your Vero).

Step by step:

  1. SSH to the media player as the OSMC user (eg. "ssh osmc@osmc" - default password is osmc)
  2. Install git - "sudo apt-get install git"
  3. Clone the hd-idle GIT Repository - "git clone https://github.com/adelolmo/hd-idle.git"
  4. This will create a new directory “hd-idle”. CD into this folder - "cd hd-idle"
  5. Install the required packages to build the source code - "sudo apt-get install libc6-dev build-essential fakeroot debhelper dh-golang golang-go:native dh-virtualenv"
  6. Build the package "dpkg-buildpackage -rfakeroot -us -uc -b"
  7. Check that the compilation has been successful and that the debian package has been created in the parent folder. Run "ls -la .." and you should see a “.deb” file listed similar to “hd-idle_1.15_armhf.deb” (the “1.15” part of the filename may differ depending on the latest version of hd-idle)
  8. Install the newly created deb package (which will be in the /home/osmc folder) "sudo dpkg -i ../hd-idle_X.XX_armhf.deb" (note: replace the “X” with the version from your filename in step 7 (e.g. 1.15 in this case).
  9. By default hd-idle is disabled. Edit the following file - /etc/default/hd-idle (e.g. using nano it would be "sudo nano /etc/default/hd-idle"
  10. Change the first non-comment line to read “START_HD_IDLE=true”
  11. Type Ctrl-X to exit Nano and answer “Y” to save changes.
  12. Restart hd-idle - "systemctl restart hd-idle"
  13. Run "sudo systemctl enable hd-idle" to ensure hd-idle starts on next boot.
  14. You’re done!

You can check hd-idle is running using "systemctl status hd-idle" and you should see something like:

* hd-idle.service - LSB: start hd-idle daemon (spin down idle hard disks)
   Loaded: loaded (/etc/init.d/hd-idle; generated)
   Active: active (running) since Sat 2021-08-14 19:01:51 BST; 13h ago
     Docs: man:systemd-sysv-generator(8)
  Process: 3193 ExecStart=/etc/init.d/hd-idle start (code=exited, status=0/SUCCESS)
    Tasks: 1 (limit: 1620)
   Memory: 960.0K
   CGroup: /system.slice/hd-idle.service
           `-3211 /usr/sbin/hd-idle -i 600

Aug 14 19:01:51 osmc systemd[1]: Starting LSB: start hd-idle daemon (spin down idle hard disks)...
Aug 14 19:01:51 osmc hd-idle[3193]: Starting the hd-idle daemon: hd-idle.
Aug 14 19:01:51 osmc systemd[1]: Started LSB: start hd-idle daemon (spin down idle hard disks).

By default, disks will be spun down after 10 minutes (600 seconds) but you can easily tweak this by editing the config file (see step 9) and adding the following line to the very end of the config file (replacing XXX with however many seconds you want hd-idle to wait before powering down your drives):

HD_IDLE_OPTS="-i XXX"

I hope somebody finds this guide useful!

Cheers,
Graham

4 Likes

Hi Graham, many thanks for your time and effort! :blush:

Seeing sourceforge mentioned I was immediately up in arms (they were baaad people https://www.howtogeek.com/218764/warning-don’t-download-software-from-sourceforge-if-you-can-help-it/), but it seems like they got acquired couple years ago and stopped being bad again.

That being said, this package was last updated in 2014 at SF, maybe it might be a good thing to look at a rewrite like this one on github? GitHub - adelolmo/hd-idle: Hard Disk Idle Spin-Down Utility

Thanks again, I’m sure you will help people with this!

1 Like

Hi Jimmy,

Many thanks for the great feedback and pointers!

I really liked your idea of using the later version of hd-idle from GIT, so I’ve updated my How-to (having installed and tested it just now) to remove the links to the old version on Sourceforge.

I’ve also included a link where folks can download the .deb binary package I compiled in case they want to skip the compiling steps (although obviously self-compiling is the most robust/safest way for most folk to ensure they get the latest version).

Thanks again!

Cheers,
Graham

1 Like

I realise that this is a thread for Vero 4K+ but I thought I would try it out on RPi4 because I have a USB disk that is not powering down and hdparam does not seem to to like it.

The “make” fails because:

go test: -race is only supported on linux/amd64, linux/ppc64le, linux/arm64, freebsd/amd64, netbsd/amd64, darwin/amd64 and windows/amd64

RPI4 with OSMC shows
uname -a
Linux media1 5.10.78-7-osmc #1 SMP PREEMPT Fri Sep 2 03:06:27 UTC 2022 aarch64 GNU/Linux

The Makefile has a section that says:
ifeq ($(PLATFORM),aarch64)
ARCH = arm64
endif

but a lower down part of the file that sets “GOARCH” does not have a similar test for aarch64

Is that a mistake in the Makefile ?

The userland is armv7.

You will need to set your architecture to armv7 if the Makefile is deducing the architecture from uname.

I have done some more digging but might need some more help here.

The Makefile is doing a “uname -m” to determine architecture.
This returns “aarch64”.
Then it uses that to set a variable called ARCH … which sets it to “arm64” for this value.

Then it sets a variable called GOARCH based on the value of ARCH - which in this means results in GOARCH being set to “arm64”.

Then the final line in the Makefile is:
go test ./… -race -cover

… so I experimented by removing the “-race” which is what is causing the problem.

Unfortunately this does not resolve things because:

# github.com/adelolmo/hd-idle/diskstats
diskstats/snapshot.go:183:16: undefined: os.ReadDir
note: module requires Go 1.16
# github.com/adelolmo/hd-idle/diskstats [github.com/adelolmo/hd-idle/diskstats.test]
diskstats/snapshot.go:183: undefined: os.ReadDir
diskstats/snapshot_test.go:73:52: constant 17004224768 overflows int
note: module requires Go 1.16

The version of Go installed using these instructions brings in 1.15
go1.16 was released 2021-02-16 (and the current is 1.19)
so I guess it has not made its way to the repositories used by OSMC.

So - a question - do the instructions posted here from over a year ago still work with current hd-idle and its related bits and pieces - on a Vero 4K+?

If this can be made to build properly on all supported platforms then maybe it can be included in OSMC as suggested back in 2019

I see a more recent version of Go in Debian bullseye-backports … is it safe to add that as an extra repository in /etc/apt/sources.list ?

You could try it – but I’d suggest removing that repository after updating Go.

I now have it built and working - but I had to make some source code changes to hd-idle.

My pull request was accepted - so should build more easily for the next person to try.

To get the necessary version of Go (16 or higher) …
edit /etc/apt/sources.list and add these 2 lines to the end (might only need the first one)

deb Index of /debian bullseye-backports main contrib non-free
deb-src Index of /debian bullseye-backports main contrib non-free

then
sudo apt update

sudo apt-get install “dh-golang” -t bullseye-backports
sudo apt-get install “golang-go:native” -t bullseye-backports

then type:
go version
and you should get
go version go1.19.3 linux/arm
(or higher)

Then follow the instructions in the first post in this thread.

Then, for safety, take out the lines that were just added to /etc/apt/sources
and
sudo apt update

Thanks for making the effort to do that Paul and for updating this thread to keep it complete!

I’m sure many folk will be grateful in the future! Hopefully OSMC will consider making hd-idle an integral part of OSMC at some point in the future too.

Cheers, Graham

I think most modern external drives have this built in or you can plug it into a pc and set the parameters using their software. That said this usually works for me
autostart.sh with

# Enable power management on USB HDD.
sudo hdparm -B 127 /dev/sda
# Set spindown time to 10 minutes.
sudo hdparm -S120 /dev/sda

I tried hdparm first - given that OSMC ships with it - as I would have liked the easiest solution.
But it did not work for me - APM issue.

sudo hdparm -B 127 /dev/sda

/dev/sda:
 setting Advanced Power Management level to 0x7f (127)
SG_IO: bad/missing sense data, sb[]:  70 00 05 00 00 00 00 0a 00 00 00 00 24 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 APM_level      = not supported

Seagate “Expansion HDD” 4TB part number: STKP4000400 - USB3 drive plugged into a USB3 socket on RPi4

However, I saw (or heard) last night that I am not getting 100% success with hd-idle.
So I took the drive to a Windows PC and tried various Seagate tools to see if any of them would recognise the drive as one that they could set a idle timer for.
Seatools - no
Seatools v5 - no
Seagate Drive Settings - no
Seagate Dashboard - initially would not detect the drive … but after a few tries and refreshes and reinserts … it found it and it let me set a value (I put 15 minutes so that I could tell if it was hd-idle or this change that worked)

It is now back in the RPi and I am experimenting - but i think it is not working. There is still something spinning but I can’t be 100% sure if it is just the fan.

Strange, mines a Seagate Expansion drive as well, but 12 tb so probably newer control stuff built in. I’ve got a 5 and an 8 for backup on an off site box running coreelec and they work fine as well. It’s weird most of the Seagate tools don’t work but if it’s formatted ext4 as I would on Linux machines, Windows will have trouble with it, might be worth asking their support people.

Mine shows a manufacturing date of 08/2022 and lists the firmware as being version 3 with no updates available.
I left it formatted as shipped so that I could still use it directly on Windows.