
It hummed too long in restless loops,
a tireless heart with no retreat.
But now, aligned, its rhythm stills—
the work is done, it sinks to sleep.
I have a WD MyBook attached via USB to my Raspberry Pi 5. It never seemed to spin down automatically, even though I only access it intermittently for backups, I always assumed it did that as it did so when connecting to my NAS. So went on to scouring the net knew it has to be a software issue. downloaded hdparm and then checking the drive state with hdparm -C /dev/sda. it found the drive but threw SCSI sense data warnings and showing the drive as “unknown”. so gpt time it was, I needed a reliable way to force and automate its standby/spindown.
1. Hdparm Install & Basic Checks
- Installed
hdparm:sudo apt-get update sudo apt-get install hdparm - Checked
/sys/block/sda/device/stateand other sysfs entries, but they remainedrunning. - Ran
hdparm -C /dev/sda, which returned “bad/missing sense data” messages and “unknown” drive state, likely from the USB-SATA bridge.
2. Verifying Background Activity
- Ensured no logs, indexing, or swap were on
/dev/sda. - Confirmed no processes were writing periodically to the drive by monitoring disk access or using
iostat/iotop. - Concluded it was likely just ignoring or partially implementing some
hdparmcommands.
3. Forcing Spindown
- Tested an immediate spindown:
sudo hdparm -y /dev/sda - Despite the same SCSI sense error, the drive physically spun down. Verified with:which reported
sudo smartctl -n standby -i /dev/sdaDevice is in STANDBY mode.
4. Setting Automatic Spindown
- Applied an idle timer:which, in theory, should spin down after 15 minutes of inactivity.
# 15 minute timer. sudo hdparm -S 180 /dev/sda - Edited
/etc/hdparm.confto persist:/dev/sda { spindown_time = 180 } - Confirmed that after ~15 minutes, the drive entered standby (though still gave sense-data warnings in logs).
5. Optional: Using hd-idle Instead
If hdparm -S does not work reliably or the drive keeps ignoring it, hd-idle is a good alternative:
- Install:
sudo apt-get update sudo apt-get install hd-idle - Configure
/etc/default/hd-idleor/etc/hd-idle.conf:This tells the daemon to spin downHD_IDLE_OPTS="-i 0 -a /dev/sda -i 900"/dev/sdaafter 900 seconds (15 minutes) of no I/O. - Enable and start:
sudo systemctl enable hd-idle sudo systemctl start hd-idle - Difference vs. hdparm:
hdparm -Ssets an internal drive firmware timeout (if the enclosure respects it). Once configured, no extra process is needed.hd-idleis a user-space daemon that watches for inactivity and manually sends the “spin down” command. It’s great when the enclosure ignores the built-in spindown timer.- hd-idle in a sense is a app you always need running for this so hdparam is a better option if possible.
hdparm worked once we forced it with hdparm -y, and then setting hdparm -S in /etc/hdparm.conf for an automatic spindown was sufficient. If that had failed, switching to hd-idle would have been the next step. In both cases, background processes or frequent accesses can keep the drive awake, so ensuring no unwanted writes or SMART polling is crucial.
Recap spindown cheat‑sheet
| Step | Commands / Config | Outcome / Notes |
|---|---|---|
| 1 Basic checks | hdparm -C /dev/sda; inspect /sys/block/sda/device/state | USB‑SATA bridge reports “bad/missing sense data”, drive state stays running |
| 2 Verify background activity | Check disk I/O with iostat, iotop; be sure logs/indexing/swap aren’t on /dev/sda | Bridge appears to ignore or only partly honor some hdparm commands |
| 3 Force immediate spindown | hdparm -y /dev/sda; verify with smartctl -n standby -i /dev/sda | Drive spins down; SMART shows Device is in STANDBY |
| 4 Set automatic spindown | hdparm -S 180 /dev/sda; in /etc/hdparm.conf: /dev/sda { spindown_time = 180 } | After ≈15 min idle the drive enters standby (still logs sense‑data warnings) |
| 5 Use hd‑idle (fallback) | Install: apt-get install hd-idle; config in /etc/hd-idle.conf: HD_IDLE_OPTS="-i 0 -a /dev/sda -i 900"; then systemctl enable hd-idle && sudo systemctl start hd-idle | hd‑idle daemon spins disk down after 900 s (15 min) when the firmware timer is ignored |
hdparm vs. hd‑idle
hdparm -Ssets a firmware‑level timeout; no extra process needed once it’s written.hd-idleis a user‑space daemon monitoring activity and manually issuing the spin‑down; ideal when the enclosure ignores-S.- Because hd‑idle must stay running, hdparm is preferable if the bridge honors the timer.
Bottom line: hdparm -y proved the bridge accepts a spin‑down command. Persisting hdparm -S 180 in /etc/hdparm.conf was sufficient. If that fails, switch to hd‑idle. In both cases, make sure nothing (logs, indexing, swap, aggressive SMART polling) keeps the drive awake.
Buy Me a Coffee