Reduce HDD activity on RPi 2

Hi all,
I’m using OSMC Alpha 4 and a USB connected 1 TB Western Digital My Book Studio as media storage on RPi 2. Despite the RPi 2 is idle, the HDD spins up every ca. two minutes for a short time, which is somewhat annoying (due to noise) and seems pointless to me. Is there any way to put an external HDD into sleep after a while? Or to disable some process, which periodically wakes the external disk?
Thanks for a hint!

If that drive only has media files NOT the library database, it shouldn’t spin up unless you actually play something.

However it’s likely that some addon you have installed or the skin or one of the Addons the skin has installed is periodically checking something. Tracking down the cause could be difficult though.

There is nothing in a plain OSMC install in the OS itself that would keep accessing a media drive, it will almost certainly be something in Kodi itself.

Turning on debug mode in kodi and tailing the log file might give a clue.

Thanks a lot for your reply. Unfortunately, it seems that the HDD activity is caused by the drive itself (maybe it’s kind of stupid firmware?), as using a completely fresh OSMC Alpha 4 on RPi2 without any addons did not change the issue. I think, I will just buy another drive.

Have you tried hdparm ?
sudo hdparm -S 60 /dev/sda
will set disc to spin down after 5 minutes

Thanks a lot! This does, indeed, seem to work.
Is it possible to set this feature permanently?

Yes you can put it in /etc/hdparm.conf
Something like

command_line {
hdparm -S 60 /dev/sda
}

There is already a spindown command in /etc/udisks-glue.conf

filter disks {
    optical = false
    partition_table = false
    usage = filesystem
}

match disks {
    automount = true
    post_insertion_command = "udisks --mount %device_file --mount-options sync,noatime"
    post_insertion_command = "/sbin/hdparm -S 240 %device_file"
}

Can someone with an external drive confirm whether this is working or not, possibly by editing the timeout to a smaller value ?

@DBMandrake The udisks-glue.conf on my RP1 with the latest OSMC build has slightly different content:-

filter disks {
    optical = false
    partition_table = false
    usage = filesystem
}

match disks {
    automount = true
    post_insertion_command = "sudo /sbin/hdparm -S 240 %device_file"
}

…and as it stands, it doesn’t work at all with my external drive. :frowning:

Can you try this latest version of udisks-glue.conf and see if it can spin your drive down ? Download it directly to your Pi with wget and copy into place:

https://raw.githubusercontent.com/samnazarko/osmc/master/package/diskmount-osmc/files/etc/udisks-glue.conf

If this doesn’t work then it is likely that your USB doesn’t support user modifiable spindown timeout. (Many do not)

Thanks for that. Unfortunately, it appears my drive is having none of it. I tried with the amended udisks-glue.conf and it still didn’t spin down, so I tried the manual approach to see what hdparm was doing, and got this:-

osmc@osmc:~$ hdparm -S60 /dev/sda1

/dev/sda1:
 setting standby to 60 (5 minutes)
 HDIO_DRIVE_CMD(setidle) failed: Inappropriate ioctl for device

I remember playing about with this a while back and just found some posts of mine on the old Raspbmc forum. The only thing I managed to get to spin the drive down was hd-idle, but even then the drive kept spinning up at regular intervals - http://forum.osmc.tv/showthread.php?tid=16348

It’s bugging me as when the drive was connected to a little USB-NAS box, it happily obeyed the sleep timeout set on the NAS box - so it must work, it’s just a case of finding the correct command.

@DBMandrake Well… it looks as if I may have finally fixed it ! I’ve got hd-idle 1.05 to work, and (possibly due to me using OSMC this time instead of Raspbmc previously) once it’s spun down, it doesn’t restart automatically. The only problem I have now is trying to get the thing to auto-run at boot. I’m a Linux noob and this has me puzzled. According to the page I used to install it - http://forum.osmc.tv/showthread.php?tid=13486 , all I need to do is edit the /etc/default/hd-idle file to say START_HD_IDLE=true, but it doesn’t seem to make any difference to it auto-starting.

Could you oblige me with a hint as to how things are supposed to autostart in OSMC please ? I’m used to Windows processes and services, but it’s still early days for me with Linux !

Many thanks.

hi guys!

Just wanted to share this, as it solved the issue for me:

(hdparm section)

We already run hdparm on automounted drives, so if hdparm is what worked for you, it should already be working.

If it was hd-idle that you needed, we don’t yet have that.

1 Like