Situation
I've got a WD Element Drive that behaves oddly. It took forever for the Drive to spin down, And I'm not able to set the standby (spindown) timeout for the Drive using different methods.
For example using hdparm
causes SG_IO
error:
$ sudo hdparm -S 25 /dev/sdx
dev/sdx:
setting standby to 25 (2 minutes + 5 seconds)
SG_IO: bad/missing sense data, sb[]: ...
It seems that the Drive's controller doesn't support these methods.
However, strangely I'm able to put the drive into standby mode using -y
switch:
$ sudo hdparm -y /dev/sdx
It gives the same SG_IO
error but drive spins down. And I'm fine with that.
Real problem
It seems that suspending Ubuntu, causes an effect similar to unplugging and plugging the drive.
When I want to suspend Ubuntu, say using: systemctl suspend
:
- If drive is on standby mode, it spins up and never spins down again.
- If it's not on standby mode, then it first spins down, after a second it spins up again and never spins down.
The only way to spin it down is to resume Ubuntu and run hdparm -y
on the drive manually and if I suspend Ubuntu again, the same thing happens.
What I already tried
I tried to run hdparm -y
on suspend to put the drive on standby
mode:
$ cat /usr/lib/systemd/system-sleep/suspend_drive
#!/bin/sh
case $1 in
pre)
hdparm -y /dev/sdc ;;
esac
It does not have any effect. And as I already said, while Ubuntu is going to sleep, drive first spins downs for a second anyway, and then it starts working again.
What I'm looking for...
Is there anyway to troubleshot this problem?
I'm looking for a solution to prevent the drive from spinning up in the first place when the system is going to sleep. And if the drive is already awake, it should go to standby mode with the system.
Notes:
- Running Ubuntu 20.04.
- I'm not interested in detaching the drive (or using any method that takes away the power from USB ports, as it has the same result of unplugging the drive).
- or using something like
udiskctl poweroff
. - Here is another similar question: Prevent external USB hard drive from spinning up during suspend to RAM
Updates
If I use
udisksctl power-off /dev/sdc
to safely remove the drive, suspending the Ubuntu acts like unplugging and re-pluging and I can mount and use the drive again (something that should not happen).I was able to set a standby timer for the drive using
sdparm
but it did not solved the issue, after suspending Ubuntu drive spins-up and never spins down, even if the timer is set to a small value like one minute.As I encountered different outcomes, I'm not 100% sure, but it seems that I'm only experiencing the problem while the drive is attached to a USB3 port.
- But USB2 has it's own problems too, for example after resuming Ubuntu drive spins-up.
I can confirm than I'm also experiencing the same problem in Windows.