External USB HDD is not spinning down

I have just replaced an external USB hard disk. The old disk (wd green 2 TB) has been spinning down with no problem, but the new one (wd elements 4 TB) is not spinning at all.
hdparm shows the following:

osmc@osmc:/$ sudo hdparm -I /dev/sda

/dev/sda:

ATA device, with non-removable media
Model Number: WDC WD40EZRZ-00WN9B0
Serial Number: WD-WCC4E5ZYESFS
Firmware Revision: 80.00A80
Transport: Serial, SATA 1.0a, SATA II Extensions, SATA Rev 2.5, SATA Rev 2.6, SATA Rev 3.0
Standards:
Supported: 9 8 7 6 5
Likely used: 9
Configuration:
Logical max current
cylinders 16383 16383
heads 16 16
sectors/track 63 63
ā€“
CHS current addressable sectors: 16514064
LBA user addressable sectors: 268435455
LBA48 user addressable sectors: 7814037168
Logical Sector size: 512 bytes
Physical Sector size: 4096 bytes
device size with M = 10241024: 3815447 MBytes
device size with M = 1000
1000: 4000787 MBytes (4000 GB)
cache/buffer size = unknown
Nominal Media Rotation Rate: 5400
Capabilities:
LBA, IORDY(can be disabled)
Queue depth: 32
Standby timer values: specā€™d by Standard, with device specific minimum
R/W multiple sector transfer: Max = 16 Current = 0
DMA: *mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 udma4 udma5 udma6
Cycle time: min=120ns recommended=120ns
PIO: pio0 pio1 pio2 pio3 pio4
Cycle time: no flow control=120ns IORDY flow control=120ns
Commands/features:
Enabled Supported:
* SMART feature set
Security Mode feature set
* Power Management feature set
* Write cache
* Look-ahead
* WRITE_BUFFER command
* READ_BUFFER command
* NOP cmd
* DOWNLOAD_MICROCODE
Power-Up In Standby feature set
* SET_FEATURES required to spinup after power up
* 48-bit Address feature set
* Device Configuration Overlay feature set
* Mandatory FLUSH_CACHE
* FLUSH_CACHE_EXT
* SMART error logging
* SMART self-test
* General Purpose Logging feature set
* 64-bit World wide name
* WRITE_UNCORRECTABLE_EXT command
* {READ,WRITE}_DMA_EXT_GPL commands
* Segmented DOWNLOAD_MICROCODE
* Gen1 signaling speed (1.5Gb/s)
* Gen2 signaling speed (3.0Gb/s)
* Gen3 signaling speed (6.0Gb/s)
* Native Command Queueing (NCQ)
* Host-initiated interface power management
* Phy event counters
* NCQ priority information
* unknown 76[15]
DMA Setup Auto-Activate optimization
Device-initiated interface power management
Software settings preservation
* SMART Command Transport (SCT) feature set
* SCT Write Same (AC2)
* SCT Features Control (AC4)
* SCT Data Tables (AC5)
unknown 206[12] (vendor specific)
unknown 206[13] (vendor specific)
unknown 206[14] (vendor specific)
Security:
Master password revision code = 65534
supported
not enabled
not locked
not frozen
not expired: security count
supported: enhanced erase
more than 508min for SECURITY ERASE UNIT. more than 508min for ENHANCED SECURITY ERASE UNIT.
Logical Unit WWN Device Identifier: 50014ee20c908f89
NAA : 5
IEEE OUI : 0014ee
Unique ID : 20c908f89
Checksum: correct

I have tried to use hdparm -S 241 /dev/sda but with no success.
What should I do?

Regards.

Even hdparm -y /dev/sda is doing nothing. :frowning:

We automatically run hdparm on external drives when they are automounted:

However not all external USB drives support this, so itā€™s highly likely that your new drive doesnā€™t support the spindown commands sent by hdparm. I have two external 2.5" drives and neither one of them supports spinning down with hdparm.

Try running the following command and see whether it reports an error:

sudo /sbin/hdparm -S 240 /dev/sda

osmc@osmc:~$ sudo /sbin/hdparm -S 240 /dev/sda

/dev/sda:
setting standby to 240 (20 minutes)

No errors.

I have read that hd-idle can help.
Can someone confirm that?

Hi everyone, can I just add that this is really bugging meā€¦

Iā€™ve got a new install of OSMC running on a Pi B+ and Iā€™m pretty happy with it. I know thereā€™s better hardware out there, but anyway I just want to use the USB ports with an externally powered HDD to store photos. Itā€™s about half full with work-related crap and I havenā€™t gotten around to putting my photos on it yet, but itā€™s been connected to the Pi and both devices have been running constantly for several days. At night when I would walk by the TV, I could hear the disk spinning, and this concerned me.

I did my due diligence and learned how to SSH into the Pi and run the command sudo hdparm -y /dev/sda which works wonderfullyā€¦ about 3 seconds after I send the command the drive is silent. But between 15 and 30 minutes later, the drive always spins up again. TV is off, no human input to the Pi, no activity whatsoever but the drive spins up for no reason. I have to log in and send the command again. Problem solved, but like I said, within a half hour itā€™s spinning again. The Pi and drive are quite difficult to reach so I have simply unplugged the power to the driveā€™s enclosure, but I would like a permanent solution.

Please investigate this issue and I strongly urge you to expose the spin-down settings in the UI, as well as some troubleshooting help for your users. Thank you.

What issue ? Something will be trying to access the drive, you need to find out what that is.

One possibility is that the Skin youā€™re using or some addon you have installed is running a periodic library scan. If this happens, the drive will obviously spin up again.

In the past hdparm has been at bit buggy so i have in the last couple of years used hd-idle and it works for more drives i thinkā€¦ some usb drives just not have the feature top spin down.

-H

Hey,

I have been struggling with a very similar issue. I am using a WD Elements HDD connected to my RPi2, with an Ext4 and an NTFS partition on it.hdparm does not support it (responded an error), so I went with hd-idle. It is doing itā€™s stuff, spinning down the HDD (I set it to 10 minutes). But after 20 minutes it spins up again. And then spins down. It is strange that this spin-up/spin-down is not logged by hd-idle.

I investigated, and seemed that calling hdparm when the disk is spun down, forces it to spin up, even if it does not support it, so I thought that it is caused by udisks-glue, removed the hdparm line from udisks-glue.conf, rebooted, the issue still occursā€¦

You said that addons and skins can scan the library periodically. It happens, even when I unmounted the partitions. Does the default OSMC skin has anything that can do that? If so, could you please tell me how to turn these off, or recommend me a skin that is very basic and surely has no library scan widgets in it?

Other things are thought about are the file system on the HDD (Ext4 and NTFS), can they cause such thing? From the apps I have Transmission and Samba installed, they are working with the HDD, but I do not know if they have any scan mechanism or not.

If you have any advice of what I should try, I would be glad to hear it!

and you have no seeding torrents running? or any transmission watch-dir function looking for new torrents??

install iotop, and se it that can catch whats going on.

sudo iotop -o -t

My torrents are stopping automatically. When these spin-ups happened I am there were no active torrents. I have checked and my transmission settings.json is lack of watch-dir-enabled configuration, but according to this wiki, it is false by default.

I have installed iotop, after a reboot, I manually spun the disk down with hd-idle. It took about half an hour when it woke up. This is the end of the log I got from it:

TIME TID PRIO USER DISK READ DISK WRITE SWAPIN IO COMMAND 17:38:38 670 be/4 root 0.00 B/s 3.71 K/s 0.00 % 0.00 % python /usr/sbin/iotop -o -t 17:38:39 Total DISK READ : 0.00 B/s | Total DISK WRITE : 0.00 B/s 17:38:39 Actual DISK READ: 0.00 B/s | Actual DISK WRITE: 0.00 B/s 17:38:40 Total DISK READ : 0.00 B/s | Total DISK WRITE : 0.00 B/s 17:38:40 Actual DISK READ: 0.00 B/s | Actual DISK WRITE: 0.00 B/s 17:38:41 Total DISK READ : 0.00 B/s | Total DISK WRITE : 103.72 K/s 17:38:41 Actual DISK READ: 0.00 B/s | Actual DISK WRITE: 111.13 K/s 17:38:41 129 be/3 root 0.00 B/s 14.82 K/s 0.00 % 0.94 % [jbd2/mmcblk0p2-] 17:38:41 566 be/4 osmc 0.00 B/s 88.91 K/s 0.00 % 0.00 % kodi.bin --standalone -fs --lircdev /var/run/lirc/lircd [EPGUpdater] 17:38:42 Total DISK READ : 0.00 B/s | Total DISK WRITE : 100.09 K/s 17:38:42 Actual DISK READ: 0.00 B/s | Actual DISK WRITE: 114.92 K/s 17:38:42 566 be/4 osmc 0.00 B/s 85.26 K/s 0.00 % 99.99 % kodi.bin --standalone -fs --lircdev /var/run/lirc/lircd [EPGUpdater] 17:38:42 129 be/3 root 0.00 B/s 11.12 K/s 0.00 % 3.24 % [jbd2/mmcblk0p2-] 17:38:42 172 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.42 % [kworker/1:2] 17:38:42 670 be/4 root 0.00 B/s 3.71 K/s 0.00 % 0.00 % python /usr/sbin/iotop -o -t 17:38:43 Total DISK READ : 0.00 B/s | Total DISK WRITE : 0.00 B/s 17:38:43 Actual DISK READ: 0.00 B/s | Actual DISK WRITE: 0.00 B/s

The line that is out of the texture is kodi.bin --standalone -fs --lircdev /var/run/lirc/lircd [EPGUpdater]. I am using an IPTV solution with PVR Simple IPTV Client addon, which has EPG address set to a URL, so I do not know why it would reach for the disk.

I am wondering if it was reaching for the HDD or the SD card for its cache? Is there any way to filter iotop monitoring only for the external USB HDD?

I donā€™t think that you can limit iotop to a certain device.
Maybe try watch "lsof | grep /media"

I have checked another itop log this morning, and it seems that it does not wakes the HDD up every time when kodi.bin --standalone -fs --lircdev /var/run/lirc/lircd [EPGUpdater] is the command.

@fzinken: thanks for the advice, I will check that too!

I have checked the total disk spin ups and spin downs, and it has grown with a huge number in very short time, so I must find some solution.

First quick and dirty solution is to disable the spin down. As any modern harddisk is more happy to run continuously instead of being stopped/started. And just enable spin down when you do troubleshooting to find the reason fro spin up.
While actually I would just leave it spinned up and just log all file access with lsof over a period.

Here is my personal take on this.

Having a drive spin down when not being used is good for saving power.

Butā€¦

How much power does that drive use while spinning? Probably not much.

So think about it this way.

If you have a good old fashioned lightbulb, and turn it off and on over and over again it will fail quicker than just leaving it on.

From my real world experience, hard drives fail more often when power cycled then when just left on. I was tech support during the W2K panic and our client insisted on lots of systems being powered off during the ā€˜catastrophicā€™ event. Well, they made their event. About 25% of the perfectly running systems failed, all with drive (or other hardware failures) died. Without the un-needed power cycles those systems would have lasted years.

How did you get the number of disk spin ups and spin downs?

Could you please provide some info on getting ā€œlsofā€ installed and setup on OSMC?

I have checked it with HD Sentinel on a Windows machine.

sudo apt-get install lsof

For anybody else having trouble with usb hard disks not spinning down (or spinning up shortly after having spun down), it all might be caused by SMART trying to read stats from the disk every x minutes.

To fix it, make a copy of /usr/lib/udisks/udisks-helper-ata-smart-collect (rename it to .orig or something) and then create a new file with the same name, where you type

#!/bin/sh 
exit 0

chmod 755 and you should be fine (at least it worked on my WD Mybook).

I can confirm that your solution works for WD Green 4TB.
Thanks a lot.

Regards.